Skip to content

Commit

Permalink
mpsl: clock_ctrl: Use new nrf2 clock ctrl HFXO zli api
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ppryga-nordic committed Dec 16, 2024
1 parent 77d283a commit 10bb5d8
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions subsys/mpsl/clock_ctrl/mpsl_clock_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down

0 comments on commit 10bb5d8

Please sign in to comment.