[PATCH 05/10] timer: omap-timer: Add timer_early functions

Stefan Roese sr at denx.de
Wed Sep 21 16:06:20 CEST 2022


Currently this timer driver provides timer_get_boot_us() to support the
BOOTSTAGE functionality. This patch adds the timer_early functions so
that the "normal" timer functions can be used, when CONFIG_TIMER_EARLY
is enabled.

timer_get_boot_us() will get removed in a follow-up patch, once the
BOOTSTAGE interface is migrated to timer_get_us().

Signed-off-by: Stefan Roese <sr at denx.de>
Cc: Christian Gmeiner <christian.gmeiner at gmail.com>
Cc: Dario Binacchi <dariobin at libero.it>
---
 drivers/timer/omap-timer.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c
index aa2e4360c1bb..315dbb634aa7 100644
--- a/drivers/timer/omap-timer.c
+++ b/drivers/timer/omap-timer.c
@@ -106,6 +106,31 @@ ulong timer_get_boot_us(void)
 }
 #endif
 
+unsigned long notrace timer_early_get_rate(void)
+{
+	return 1;
+}
+
+u64 notrace timer_early_get_count(void)
+{
+	u64 ticks = 0;
+	u32 rate = 1;
+	u64 us;
+	int ret;
+
+	ret = dm_timer_init();
+	if (!ret) {
+		/* The timer is available */
+		rate = timer_get_rate(gd->timer);
+		timer_get_count(gd->timer, &ticks);
+	} else {
+		return 0;
+	}
+
+	us = (ticks * 1000) / rate;
+	return us;
+}
+
 static const struct timer_ops omap_timer_ops = {
 	.get_count = omap_timer_get_count,
 };
-- 
2.37.3



More information about the U-Boot mailing list