From 379cb4dccb2da47c23bdb2ff815516517f9e6df0 Mon Sep 17 00:00:00 2001 From: Piotr Pryga Date: Fri, 6 Dec 2024 15:07:26 +0100 Subject: [PATCH] mpsl: clock_ctrl: Use new nrf2 clock ctrl HFXO zli api There were no API in nrf2 clock control that allows to requrest the HFXO from zero latency interrupts. That was a blocker for MPSL. Since the API was added, change the implementation of clock control integration layer to use it. Mind that the new API is similar to nRF52/nRF53 APIs: z_nrf_clock_bt_ctlr_hf_request and z_nrf_clock_bt_ctlr_hf_release. It does not provide feedback if the HFXO ramp-up is done. Signed-off-by: Piotr Pryga --- subsys/mpsl/clock_ctrl/mpsl_clock_ctrl.c | 26 ++---------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/subsys/mpsl/clock_ctrl/mpsl_clock_ctrl.c b/subsys/mpsl/clock_ctrl/mpsl_clock_ctrl.c index 13e42b7958a..e7c6332f433 100644 --- a/subsys/mpsl/clock_ctrl/mpsl_clock_ctrl.c +++ b/subsys/mpsl/clock_ctrl/mpsl_clock_ctrl.c @@ -169,8 +169,6 @@ static int32_t m_lfclk_release(void) * configured LFCLK. */ #define MPSL_LFCLK_ACCURACY_PPM 500 -/* Must be global because of use of nrf_clock_control_cancel_or_release in hfclk_release. */ -static struct onoff_client m_radio_cli; static const struct nrf_clock_spec m_lfclk_specs = { .frequency = 32768, @@ -228,26 +226,15 @@ static int32_t m_lfclk_release(void) static void m_hfclk_request(void) { - const struct device *radio_clk_dev = - DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio))); - int err; - if (atomic_inc(&m_hfclk_refcnt) > 0) { return; } - sys_notify_init_spinwait(&m_radio_cli.notify); - - err = nrf_clock_control_request(radio_clk_dev, NULL, &m_radio_cli); - __ASSERT_NO_MSG(err >= 0); + nrf_clock_control_hfxo_request(); } static void m_hfclk_release(void) { - int err; - const struct device *radio_clk_dev = - DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_NODELABEL(radio))); - if (m_hfclk_refcnt < 1) { return; } @@ -256,24 +243,15 @@ static void m_hfclk_release(void) return; } - err = nrf_clock_control_cancel_or_release(radio_clk_dev, NULL, &m_radio_cli); - __ASSERT_NO_MSG(err >= 0); + nrf_clock_control_hfxo_release(); } static bool m_hfclk_is_running(void) { - int res; - int err; - if (m_hfclk_refcnt < 1) { return false; } - err = sys_notify_fetch_result(&m_radio_cli.notify, &res); - if (err < 0 || res != 0 ) { - return false; - } - return true; } #else