Skip to content

Commit b6ca9db

Browse files
piotrkoziarkartben
authored andcommitted
modules: hal_nordic: use CLOCK_CONTROL_NRF2 for HFCLK request/release
Makes 802.15.4 use the API under CONFIG_CLOCK_CONTROL_NRF2 in nrf_clock_control.h to request/release HFCLK. Previous HFCLK requesting/releasing on nRF54H20 was more of a workaround and could produce issues when comes to sharing the resources. Signed-off-by: Piotr Koziar <piotr.koziar@nordicsemi.no>
1 parent ef7a0a4 commit b6ca9db

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111

1212
#include <compiler_abstraction.h>
1313
#include <zephyr/kernel.h>
14-
#if defined(CONFIG_CLOCK_CONTROL_NRF)
1514
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
16-
#include <zephyr/drivers/clock_control.h>
17-
#elif !defined(NRF54H_SERIES)
18-
#error No implementation to start or stop HFCLK due to missing clock_control.
19-
#endif
2015

2116
static bool hfclk_is_running;
2217

@@ -35,7 +30,6 @@ bool nrf_802154_clock_hfclk_is_running(void)
3530
return hfclk_is_running;
3631
}
3732

38-
#if defined(CONFIG_CLOCK_CONTROL_NRF)
3933

4034
static struct onoff_client hfclk_cli;
4135

@@ -48,6 +42,7 @@ static void hfclk_on_callback(struct onoff_manager *mgr,
4842
nrf_802154_clock_hfclk_ready();
4943
}
5044

45+
#if defined(CONFIG_CLOCK_CONTROL_NRF)
5146
void nrf_802154_clock_hfclk_start(void)
5247
{
5348
int ret;
@@ -75,40 +70,22 @@ void nrf_802154_clock_hfclk_stop(void)
7570
hfclk_is_running = false;
7671
}
7772

78-
#elif defined(NRF54H_SERIES)
79-
80-
#define NRF_LRCCONF_RADIO_PD NRF_LRCCONF010
81-
/* HF clock time to ramp-up. */
82-
#define MAX_HFXO_RAMP_UP_TIME_US 550
83-
84-
static void hfclk_started_timer_handler(struct k_timer *dummy)
85-
{
86-
hfclk_is_running = true;
87-
nrf_802154_clock_hfclk_ready();
88-
}
89-
90-
K_TIMER_DEFINE(hfclk_started_timer, hfclk_started_timer_handler, NULL);
73+
#elif defined(CONFIG_CLOCK_CONTROL_NRF2)
9174

9275
void nrf_802154_clock_hfclk_start(void)
9376
{
94-
/* Use register directly, there is no support for that task in nrf_lrcconf_task_trigger.
95-
* This code might cause troubles if there are other HFXO users in this CPU.
96-
*/
97-
NRF_LRCCONF_RADIO_PD->EVENTS_HFXOSTARTED = 0x0;
98-
NRF_LRCCONF_RADIO_PD->TASKS_REQHFXO = 0x1;
77+
sys_notify_init_callback(&hfclk_cli.notify, hfclk_on_callback);
78+
int ret = nrf_clock_control_request(DEVICE_DT_GET(DT_NODELABEL(hfxo)), NULL, &hfclk_cli);
9979

100-
k_timer_start(&hfclk_started_timer, K_USEC(MAX_HFXO_RAMP_UP_TIME_US), K_NO_WAIT);
80+
__ASSERT_NO_MSG(ret >= 0);
10181
}
10282

10383
void nrf_802154_clock_hfclk_stop(void)
10484
{
105-
/* Use register directly, there is no support for that task in nrf_lrcconf_task_trigger.
106-
* This code might cause troubles if there are other HFXO users in this CPU.
107-
*/
108-
NRF_LRCCONF_RADIO_PD->TASKS_STOPREQHFXO = 0x1;
109-
NRF_LRCCONF_RADIO_PD->EVENTS_HFXOSTARTED = 0x0;
85+
int ret = nrf_clock_control_cancel_or_release(DEVICE_DT_GET(DT_NODELABEL(hfxo)),
86+
NULL, &hfclk_cli);
11087

111-
hfclk_is_running = false;
88+
__ASSERT_NO_MSG(ret >= 0);
11289
}
11390

11491
#endif

0 commit comments

Comments
 (0)