Skip to content

Commit 60af28e

Browse files
adamkondraciukjhedberg
authored andcommitted
drivers: timer: nrf_grtc: Move GRTC initialization to early init
GRTC is used by the logger, so it must be initialized as early as possible. On the other hand, clock requests are allowed once the clock control API has been initialized. This PR introduces a two-stage GRTC initialization to meet these requirements. Signed-off-by: Adam Kondraciuk <[email protected]>
1 parent 7faf692 commit 60af28e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/timer/nrf_grtc_timer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ static int sys_clock_driver_init(void)
517517
system_timeout_set_relative(CYC_PER_TICK);
518518
}
519519

520+
return 0;
521+
}
522+
523+
static int grtc_post_init(void)
524+
{
520525
#if defined(CONFIG_CLOCK_CONTROL_NRF)
521526
static const enum nrf_lfclk_start_mode mode =
522527
IS_ENABLED(CONFIG_SYSTEM_CLOCK_NO_WAIT)
@@ -590,5 +595,6 @@ int nrf_grtc_timer_clock_driver_init(void)
590595
return sys_clock_driver_init();
591596
}
592597
#else
593-
SYS_INIT(sys_clock_driver_init, PRE_KERNEL_2, CONFIG_SYSTEM_CLOCK_INIT_PRIORITY);
598+
SYS_INIT(sys_clock_driver_init, EARLY, CONFIG_SYSTEM_CLOCK_INIT_PRIORITY);
599+
SYS_INIT(grtc_post_init, PRE_KERNEL_2, CONFIG_SYSTEM_CLOCK_INIT_PRIORITY);
594600
#endif

0 commit comments

Comments
 (0)