Bluetooth: Controller: Add deinit() infrastructure
Allow the controller to be deinitialized, adding the whole chain of calls: - ll_deinit() - lll_deinit() - lll_clock_deinit() in order to be able to turn everything off, including the controller's refcount of the LF clock. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
11da95bb4d
commit
4349a475a8
7 changed files with 61 additions and 8 deletions
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
int ll_init(struct k_sem *sem_rx);
|
||||
int ll_deinit(void);
|
||||
void ll_reset(void);
|
||||
|
||||
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value);
|
||||
|
|
|
|||
|
|
@ -537,6 +537,7 @@ struct node_tx_iso;
|
|||
void lll_done_score(void *param, uint8_t result);
|
||||
|
||||
int lll_init(void);
|
||||
int lll_deinit(void);
|
||||
int lll_reset(void);
|
||||
void lll_resume(void *param);
|
||||
void lll_disable(void *param);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
int lll_clock_init(void);
|
||||
int lll_clock_deinit(void);
|
||||
int lll_clock_wait(void);
|
||||
int lll_hfclock_on(void);
|
||||
int lll_hfclock_on_wait(void);
|
||||
|
|
|
|||
|
|
@ -202,16 +202,38 @@ int lll_init(void)
|
|||
irq_enable(RADIO_IRQn);
|
||||
irq_enable(RTC0_IRQn);
|
||||
irq_enable(HAL_SWI_RADIO_IRQ);
|
||||
#if defined(CONFIG_BT_CTLR_LOW_LAT) || \
|
||||
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)
|
||||
irq_enable(HAL_SWI_JOB_IRQ);
|
||||
#endif
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) ||
|
||||
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)) {
|
||||
irq_enable(HAL_SWI_JOB_IRQ);
|
||||
}
|
||||
|
||||
radio_setup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lll_deinit(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Release clocks */
|
||||
err = lll_clock_deinit();
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Disable IRQs */
|
||||
irq_disable(RADIO_IRQn);
|
||||
irq_disable(RTC0_IRQn);
|
||||
irq_disable(HAL_SWI_RADIO_IRQ);
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) ||
|
||||
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)) {
|
||||
irq_disable(HAL_SWI_JOB_IRQ);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lll_csrand_get(void *buf, size_t len)
|
||||
{
|
||||
return entropy_get_entropy(dev_entropy, buf, len);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,14 @@ int lll_clock_init(void)
|
|||
return onoff_request(mgr, &lf_cli);
|
||||
}
|
||||
|
||||
int lll_clock_deinit(void)
|
||||
{
|
||||
struct onoff_manager *mgr =
|
||||
z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_LF);
|
||||
|
||||
return onoff_release(mgr);
|
||||
}
|
||||
|
||||
int lll_clock_wait(void)
|
||||
{
|
||||
struct onoff_manager *mgr;
|
||||
|
|
|
|||
|
|
@ -155,10 +155,10 @@ int lll_init(void)
|
|||
irq_enable(LL_RADIO_IRQn);
|
||||
irq_enable(LL_RTC0_IRQn);
|
||||
irq_enable(HAL_SWI_RADIO_IRQ);
|
||||
#if defined(CONFIG_BT_CTLR_LOW_LAT) || \
|
||||
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)
|
||||
irq_enable(HAL_SWI_JOB_IRQ);
|
||||
#endif
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) ||
|
||||
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)) {
|
||||
irq_enable(HAL_SWI_JOB_IRQ);
|
||||
}
|
||||
|
||||
/* Call it after IRQ enable to be able to measure ISR latency */
|
||||
radio_setup();
|
||||
|
|
@ -166,6 +166,20 @@ int lll_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lll_deinit(void)
|
||||
{
|
||||
/* Disable IRQs */
|
||||
irq_disable(LL_RADIO_IRQn);
|
||||
irq_disable(LL_RTC0_IRQn);
|
||||
irq_disable(HAL_SWI_RADIO_IRQ);
|
||||
if (IS_ENABLED(CONFIG_BT_CTLR_LOW_LAT) ||
|
||||
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)) {
|
||||
irq_disable(HAL_SWI_JOB_IRQ);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lll_csrand_get(void *buf, size_t len)
|
||||
{
|
||||
return entropy_get_entropy(dev_entropy, buf, len);
|
||||
|
|
|
|||
|
|
@ -699,6 +699,12 @@ int ll_init(struct k_sem *sem_rx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ll_deinit(void)
|
||||
{
|
||||
ll_reset();
|
||||
return lll_deinit();
|
||||
}
|
||||
|
||||
void ll_reset(void)
|
||||
{
|
||||
int err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue