@@ -429,13 +429,6 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
429429 nrfy_grtc_timeout_get (NRF_GRTC ) * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 32768 +
430430 MAX_CC_LATCH_WAIT_TIME_US ;
431431 k_busy_wait (wait_time );
432- #if NRF_GRTC_HAS_CLKSEL
433- #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC )
434- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFLPRC );
435- #elif DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (lfxo ))
436- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFXO );
437- #endif
438- #endif
439432 k_spin_unlock (& lock , key );
440433 return 0 ;
441434}
@@ -475,6 +468,18 @@ static int sys_clock_driver_init(void)
475468 IRQ_CONNECT (DT_IRQN (GRTC_NODE ), DT_IRQ (GRTC_NODE , priority ), nrfx_isr ,
476469 nrfx_grtc_irq_handler , 0 );
477470
471+ #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT ) && NRF_GRTC_HAS_CLKSEL
472+ #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC )
473+ /* Switch to LFPRC as the low-frequency clock source. */
474+ nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFLPRC );
475+ #elif DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (lfxo ))
476+ /* Switch to LFXO as the low-frequency clock source. */
477+ nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFXO );
478+ #else
479+ nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFCLK );
480+ #endif
481+ #endif
482+
478483 err_code = nrfx_grtc_init (0 );
479484 if (err_code != NRFX_SUCCESS ) {
480485 return - EPERM ;
@@ -508,16 +513,6 @@ static int sys_clock_driver_init(void)
508513 z_nrf_clock_control_lf_on (mode );
509514#endif
510515
511- #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT ) && NRF_GRTC_HAS_CLKSEL
512- #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC )
513- /* Switch to LFPRC as the low-frequency clock source. */
514- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFLPRC );
515- #elif DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (lfxo ))
516- /* Switch to LFXO as the low-frequency clock source. */
517- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFXO );
518- #endif
519- #endif
520-
521516#if defined(CONFIG_NRF_GRTC_ALWAYS_ON )
522517 nrfx_grtc_active_request_set (true);
523518#endif
0 commit comments