U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: timer: Fix M-Mode timer
@ 2026-09-04  6:12 Nikita Shubin
  2026-09-04 19:17 ` Yao Zi
  0 siblings, 1 reply; 4+ messages in thread
From: Nikita Shubin @ 2026-09-04  6:12 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Nikita Shubin

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 <nikita.shubin@maquefel.me>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-07  9:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  6:12 [PATCH] riscv: timer: Fix M-Mode timer Nikita Shubin
2026-09-04 19:17 ` Yao Zi
2026-09-07  7:22   ` Nikita Shubin
2026-09-07  9:09     ` Yao Zi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox