Skip to content

Commit a6ce0b0

Browse files
[nrf fromlist] drivers: timer: grtc: Add LFPRC as the source of GRTC
This commit allows to switch the GRTC clock source to an RC oscillator. Upstream PR #: 80622 Signed-off-by: Adam Kondraciuk <[email protected]>
1 parent a735c24 commit a6ce0b0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/timer/nrf_grtc_timer.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,12 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
426426
nrfy_grtc_timeout_get(NRF_GRTC) * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 32768 +
427427
MAX_CC_LATCH_WAIT_TIME_US;
428428
k_busy_wait(wait_time);
429-
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lfxo), okay) && NRF_GRTC_HAS_CLKSEL
429+
#if NRF_GRTC_HAS_CLKSEL
430+
#if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC)
431+
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFLPRC);
432+
#elif DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lfxo))
430433
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO);
434+
#endif
431435
#endif
432436
k_spin_unlock(&lock, key);
433437
return 0;
@@ -501,11 +505,15 @@ static int sys_clock_driver_init(void)
501505
z_nrf_clock_control_lf_on(mode);
502506
#endif
503507

504-
#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \
505-
DT_NODE_HAS_STATUS(DT_NODELABEL(lfxo), okay) && NRF_GRTC_HAS_CLKSEL
508+
#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && NRF_GRTC_HAS_CLKSEL
509+
#if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC)
510+
/* Switch to LFPRC as the low-frequency clock source. */
511+
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFLPRC);
512+
#elif DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(lfxo))
506513
/* Switch to LFXO as the low-frequency clock source. */
507514
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO);
508515
#endif
516+
#endif
509517

510518
#if defined(CONFIG_NRF_GRTC_ALWAYS_ON)
511519
nrfx_grtc_active_request_set(true);

0 commit comments

Comments
 (0)