From d8e3ea6bc287c544729be0fc429708759bdfcfa8 Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Tue, 4 Dec 2018 14:23:29 +0100 Subject: [PATCH] drivers: clock_control: Enable LFSTARTED event for nrf5 The LFSTARTED event was disabled so it was impossible to wake the CPU up on LF clock being ready. The Bluetooth stack was putting the CPU to sleep, expecting to be woken up on LFSTARTED event. As the event never triggered, the CPU was woken up seconds later by a different event introducing a multi-second startup delay. Bug introduced by 23c92100ac5. Signed-off-by: Krzysztof Chruscinski --- drivers/clock_control/nrf5_power_clock.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/clock_control/nrf5_power_clock.c b/drivers/clock_control/nrf5_power_clock.c index beb1ffd2fda..c89de0e0636 100644 --- a/drivers/clock_control/nrf5_power_clock.c +++ b/drivers/clock_control/nrf5_power_clock.c @@ -212,6 +212,7 @@ static int _k32src_start(struct device *dev, clock_control_subsys_t sub_system) /* NOTE: LFCLK will initially start running from the LFRC if LFXO is * selected. */ + nrf_clock_int_enable(NRF_CLOCK_INT_LF_STARTED_MASK); nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); #endif /* !CONFIG_CLOCK_CONTROL_NRF5_K32SRC_BLOCKING */ @@ -344,8 +345,11 @@ static void _power_clock_isr(void *arg) */ NRF_CLOCK->INTENCLR = CLOCK_INTENCLR_LFCLKSTARTED_Msk; - /* Start HF Clock */ - ctto = 1; + /* Start HF Clock if LF RC is used. */ + if ((NRF_CLOCK->LFCLKSRCCOPY & CLOCK_LFCLKSRCCOPY_SRC_Msk) == + CLOCK_LFCLKSRCCOPY_SRC_RC) { + ctto = 1; + } } }