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(NRF54H_SERIES )  &&  defined( CONFIG_CLOCK_CONTROL_NRF2 ) )
1818#error  No implementation to start or stop HFCLK due to missing clock_control.
1919#endif 
2020
@@ -35,7 +35,6 @@ bool nrf_802154_clock_hfclk_is_running(void)
3535	return  hfclk_is_running ;
3636}
3737
38- #if  defined(CONFIG_CLOCK_CONTROL_NRF )
3938
4039static  struct  onoff_client  hfclk_cli ;
4140
@@ -48,6 +47,7 @@ static void hfclk_on_callback(struct onoff_manager *mgr,
4847	nrf_802154_clock_hfclk_ready ();
4948}
5049
50+ #if  defined(CONFIG_CLOCK_CONTROL_NRF )
5151void  nrf_802154_clock_hfclk_start (void )
5252{
5353	int  ret ;
@@ -77,38 +77,26 @@ void nrf_802154_clock_hfclk_stop(void)
7777
7878#elif  defined(NRF54H_SERIES )
7979
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 );
80+ const  struct  nrf_clock_spec  spec  =  {
81+ 	.frequency  =  NRF_CLOCK_CONTROL_FREQUENCY_MAX ,
82+ 	.accuracy  =  NRF_CLOCK_CONTROL_ACCURACY_MAX ,
83+ 	.precision  =  NRF_CLOCK_CONTROL_PRECISION_HIGH ,
84+ };
9185
9286void  nrf_802154_clock_hfclk_start (void )
9387{
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 ;
88+ 	sys_notify_init_callback (& hfclk_cli .notify , hfclk_on_callback );
89+ 	int  ret  =  nrf_clock_control_request (DEVICE_DT_GET (DT_NODELABEL (hfxo )), & spec , & hfclk_cli );
9990
100- 	k_timer_start ( & hfclk_started_timer ,  K_USEC ( MAX_HFXO_RAMP_UP_TIME_US ),  K_NO_WAIT );
91+ 	__ASSERT_NO_MSG ( ret  >=  0 );
10192}
10293
10394void  nrf_802154_clock_hfclk_stop (void )
10495{
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 ;
96+ 	int  ret  =  nrf_clock_control_cancel_or_release (DEVICE_DT_GET (DT_NODELABEL (hfxo )),
97+ 						      & spec , & hfclk_cli );
11098
111- 	hfclk_is_running   =  false ;
99+ 	__ASSERT_NO_MSG ( ret  >=  0 ) ;
112100}
113101
114102#endif 
0 commit comments