Skip to content

Commit

Permalink
[nrf fromlist] drivers: timer: grtc: Switch GRTC clock source to LFXO
Browse files Browse the repository at this point in the history
GRTC needs to use direct clock source path instead of system clock path
to support ELV mode for nRF54L targets.

Upstream PR: zephyrproject-rtos/zephyr#78082

Signed-off-by: Adam Kondraciuk <[email protected]>
  • Loading branch information
adamkondraciuk committed Sep 10, 2024
1 parent 83195a3 commit d2f587a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/timer/nrf_grtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
nrfy_grtc_timeout_get(NRF_GRTC) * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 32768 +
MAX_CC_LATCH_WAIT_TIME_US;
k_busy_wait(wait_time);
#if NRF_GRTC_HAS_CLKSEL
#if DT_NODE_HAS_STATUS(DT_NODELABEL(lfxo), okay) && NRF_GRTC_HAS_CLKSEL
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO);
#endif
k_spin_unlock(&lock, key);
Expand Down Expand Up @@ -464,7 +464,7 @@ static int sys_clock_driver_init(void)

#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \
(defined(NRF_GRTC_HAS_CLKSEL) && (NRF_GRTC_HAS_CLKSEL == 1))
/* Use System LFCLK as the low-frequency clock source. */
/* Use System LFCLK as the low-frequency clock source during initialization. */
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFCLK);
#endif

Expand Down Expand Up @@ -504,6 +504,12 @@ static int sys_clock_driver_init(void)
z_nrf_clock_control_lf_on(mode);
#endif

#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \
DT_NODE_HAS_STATUS(DT_NODELABEL(lfxo), okay) && NRF_GRTC_HAS_CLKSEL
/* Switch to LFXO as the low-frequency clock source. */
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO);
#endif

return 0;
}

Expand Down

0 comments on commit d2f587a

Please sign in to comment.