11
11
12
12
#include <compiler_abstraction.h>
13
13
#include <zephyr/kernel.h>
14
- #if defined(CONFIG_CLOCK_CONTROL_NRF )
15
14
#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
20
15
21
16
static bool hfclk_is_running ;
22
17
@@ -35,7 +30,6 @@ bool nrf_802154_clock_hfclk_is_running(void)
35
30
return hfclk_is_running ;
36
31
}
37
32
38
- #if defined(CONFIG_CLOCK_CONTROL_NRF )
39
33
40
34
static struct onoff_client hfclk_cli ;
41
35
@@ -48,6 +42,7 @@ static void hfclk_on_callback(struct onoff_manager *mgr,
48
42
nrf_802154_clock_hfclk_ready ();
49
43
}
50
44
45
+ #if defined(CONFIG_CLOCK_CONTROL_NRF )
51
46
void nrf_802154_clock_hfclk_start (void )
52
47
{
53
48
int ret ;
@@ -75,40 +70,22 @@ void nrf_802154_clock_hfclk_stop(void)
75
70
hfclk_is_running = false;
76
71
}
77
72
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 )
91
74
92
75
void nrf_802154_clock_hfclk_start (void )
93
76
{
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 );
99
79
100
- k_timer_start ( & hfclk_started_timer , K_USEC ( MAX_HFXO_RAMP_UP_TIME_US ), K_NO_WAIT );
80
+ __ASSERT_NO_MSG ( ret >= 0 );
101
81
}
102
82
103
83
void nrf_802154_clock_hfclk_stop (void )
104
84
{
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 );
110
87
111
- hfclk_is_running = false ;
88
+ __ASSERT_NO_MSG ( ret >= 0 ) ;
112
89
}
113
90
114
91
#endif
0 commit comments