@@ -417,13 +417,6 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
417
417
nrfy_grtc_timeout_get (NRF_GRTC ) * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 32768 +
418
418
MAX_CC_LATCH_WAIT_TIME_US ;
419
419
k_busy_wait (wait_time );
420
- #if NRF_GRTC_HAS_CLKSEL
421
- #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC )
422
- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFLPRC );
423
- #elif DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (lfxo ))
424
- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFXO );
425
- #endif
426
- #endif
427
420
k_spin_unlock (& lock , key );
428
421
return 0 ;
429
422
}
@@ -463,6 +456,18 @@ static int sys_clock_driver_init(void)
463
456
IRQ_CONNECT (DT_IRQN (GRTC_NODE ), DT_IRQ (GRTC_NODE , priority ), nrfx_isr ,
464
457
nrfx_grtc_irq_handler , 0 );
465
458
459
+ #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT ) && NRF_GRTC_HAS_CLKSEL
460
+ #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC )
461
+ /* Switch to LFPRC as the low-frequency clock source. */
462
+ nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFLPRC );
463
+ #elif DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (lfxo ))
464
+ /* Switch to LFXO as the low-frequency clock source. */
465
+ nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFXO );
466
+ #else
467
+ nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFCLK );
468
+ #endif
469
+ #endif
470
+
466
471
err_code = nrfx_grtc_init (0 );
467
472
if (err_code != NRFX_SUCCESS ) {
468
473
return - EPERM ;
@@ -496,16 +501,6 @@ static int sys_clock_driver_init(void)
496
501
z_nrf_clock_control_lf_on (mode );
497
502
#endif
498
503
499
- #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT ) && NRF_GRTC_HAS_CLKSEL
500
- #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC )
501
- /* Switch to LFPRC as the low-frequency clock source. */
502
- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFLPRC );
503
- #elif DT_NODE_HAS_STATUS_OKAY (DT_NODELABEL (lfxo ))
504
- /* Switch to LFXO as the low-frequency clock source. */
505
- nrfx_grtc_clock_source_set (NRF_GRTC_CLKSEL_LFXO );
506
- #endif
507
- #endif
508
-
509
504
#if defined(CONFIG_NRF_GRTC_ALWAYS_ON )
510
505
nrfx_grtc_active_request_set (true);
511
506
#endif
0 commit comments