RISC-V timer is missing timer_early_get_rate() for M-Mode. Also timer_early_get_count() is guarded by RISCV_SMODE for no clear reason.
Make timer_early_get_rate() use RISCV_MMODE_TIMER_FREQ in M-Mode and move timer_early_get_count() out of define. Signed-off-by: Nikita Shubin <[email protected]> --- drivers/timer/riscv_timer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c index 1f4980ceb38..65f174fb879 100644 --- a/drivers/timer/riscv_timer.c +++ b/drivers/timer/riscv_timer.c @@ -33,14 +33,22 @@ static u64 notrace riscv_timer_get_count(struct udevice *dev) return ((u64)hi << 32) | lo; } -#if CONFIG_IS_ENABLED(RISCV_SMODE) && IS_ENABLED(CONFIG_TIMER_EARLY) /** * timer_early_get_rate() - Get the timer rate before driver model */ +#if IS_ENABLED(CONFIG_TIMER_EARLY) +#if CONFIG_IS_ENABLED(RISCV_SMODE) unsigned long notrace timer_early_get_rate(void) { return RISCV_SMODE_TIMER_FREQ; } +#elif CONFIG_IS_ENABLED(RISCV_MMODE) +unsigned long notrace timer_early_get_rate(void) +{ + return RISCV_MMODE_TIMER_FREQ; +} +#endif +#endif /** * timer_early_get_count() - Get the timer count before driver model @@ -50,7 +58,6 @@ u64 notrace timer_early_get_count(void) { return riscv_timer_get_count(NULL); } -#endif #if CONFIG_IS_ENABLED(RISCV_SMODE) && CONFIG_IS_ENABLED(BOOTSTAGE) ulong timer_get_boot_us(void) --- base-commit: cc557af4553382f6f50e3ed62b9577054e7bc54f change-id: 20260904-riscv_fix_early_timer_mmode-174f3ee4e106 Best regards, -- Nikita Shubin
