Skip to content

Commit 2c63115

Browse files
aaronyegxkartben
authored andcommitted
drivers: bluetooth: hci: add close function for Ambiq Apollo4 series
This commit adds close function support for Ambiq Apollo4 series SoC so the bt_disable() API can be used. Signed-off-by: Aaron Ye <[email protected]>
1 parent 8bbc05d commit 2c63115

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

drivers/bluetooth/hci/apollox_blue.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,23 @@ int bt_apollo_controller_init(spi_transmit_fun transmit)
343343

344344
int bt_apollo_controller_deinit(void)
345345
{
346-
int ret = -ENOTSUP;
346+
int ret = 0;
347347

348-
#if (CONFIG_SOC_SERIES_APOLLO3X)
348+
#if (CONFIG_SOC_SERIES_APOLLO4X)
349+
/* Keep the Controller in resetting state */
350+
gpio_pin_set_dt(&rst_gpio, 1);
351+
352+
/* Disable XO32MHz */
353+
clock_control_off(clk32m_dev, (clock_control_subsys_t)CLOCK_CONTROL_AMBIQ_TYPE_HFXTAL_BLE);
354+
/* Disable XO32kHz */
355+
clock_control_off(clk32k_dev, (clock_control_subsys_t)CLOCK_CONTROL_AMBIQ_TYPE_LFXTAL);
356+
357+
/* Disable GPIOs */
358+
gpio_pin_configure_dt(&irq_gpio, GPIO_DISCONNECTED);
359+
gpio_pin_configure_dt(&clkreq_gpio, GPIO_DISCONNECTED);
360+
gpio_remove_callback(clkreq_gpio.port, &clkreq_gpio_cb);
361+
gpio_remove_callback(irq_gpio.port, &irq_gpio_cb);
362+
#elif (CONFIG_SOC_SERIES_APOLLO3X)
349363
irq_disable(DT_IRQN(SPI_DEV_NODE));
350364

351365
ret = am_apollo3_bt_controller_deinit();
@@ -355,7 +369,9 @@ int bt_apollo_controller_deinit(void)
355369
ret = -EPERM;
356370
LOG_ERR("BT controller deinitialization fails");
357371
}
358-
#endif /* CONFIG_SOC_SERIES_APOLLO3X */
372+
#else
373+
ret = -ENOTSUP;
374+
#endif /* CONFIG_SOC_SERIES_APOLLO4X */
359375

360376
return ret;
361377
}

0 commit comments

Comments
 (0)