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>
15+ #if defined(CONFIG_CLOCK_CONTROL_NRF )
1616#include <zephyr/drivers/clock_control.h>
17- #elif !defined(NRF54H_SERIES )
17+ #elif (defined(CONFIG_CLOCK_CONTROL_NRF2 ) && defined(NRF54H_SERIES ))
18+ #define NRF_802154_HFCLK_CLOCK_FREQUENCY 32000000
19+ #else
1820#error No implementation to start or stop HFCLK due to missing clock_control.
1921#endif
2022
@@ -35,7 +37,6 @@ bool nrf_802154_clock_hfclk_is_running(void)
3537 return hfclk_is_running ;
3638}
3739
38- #if defined(CONFIG_CLOCK_CONTROL_NRF )
3940
4041static struct onoff_client hfclk_cli ;
4142
@@ -48,6 +49,7 @@ static void hfclk_on_callback(struct onoff_manager *mgr,
4849 nrf_802154_clock_hfclk_ready ();
4950}
5051
52+ #if defined(CONFIG_CLOCK_CONTROL_NRF )
5153void nrf_802154_clock_hfclk_start (void )
5254{
5355 int ret ;
@@ -77,38 +79,26 @@ void nrf_802154_clock_hfclk_stop(void)
7779
7880#elif defined(NRF54H_SERIES )
7981
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 );
82+ const struct nrf_clock_spec spec = {
83+ .frequency = NRF_802154_HFCLK_CLOCK_FREQUENCY ,
84+ .accuracy = NRF_CLOCK_CONTROL_ACCURACY_MAX ,
85+ .precision = NRF_CLOCK_CONTROL_PRECISION_HIGH ,
86+ };
9187
9288void nrf_802154_clock_hfclk_start (void )
9389{
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 ;
90+ sys_notify_init_callback (& hfclk_cli .notify , hfclk_on_callback );
91+ int ret = nrf_clock_control_request (DEVICE_DT_GET (DT_NODELABEL (hfxo )), & spec , & hfclk_cli );
9992
100- k_timer_start ( & hfclk_started_timer , K_USEC ( MAX_HFXO_RAMP_UP_TIME_US ), K_NO_WAIT );
93+ __ASSERT_NO_MSG ( ret >= 0 );
10194}
10295
10396void nrf_802154_clock_hfclk_stop (void )
10497{
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 ;
98+ int ret = nrf_clock_control_cancel_or_release (DEVICE_DT_GET (DT_NODELABEL (hfxo )),
99+ & spec , & hfclk_cli );
110100
111- hfclk_is_running = false ;
101+ __ASSERT_NO_MSG ( ret >= 0 ) ;
112102}
113103
114104#endif
0 commit comments