[U-Boot] [PATCH 3/5] dm: x86: Update timer_get_boot_us to work before DM is ready

Simon Glass sjg at chromium.org
Sat Jul 15 23:41:13 UTC 2017


Use the new separate init function so that we can make use of the timer
before driver model is started up.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/timer/tsc_timer.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index 9f1cfb1242..91e5cb11c1 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -301,11 +301,6 @@ ulong notrace timer_get_us(void)
 	return get_ticks() / get_tbclk_mhz();
 }
 
-ulong timer_get_boot_us(void)
-{
-	return timer_get_us();
-}
-
 void __udelay(unsigned long usec)
 {
 	u64 now = get_ticks();
@@ -368,6 +363,21 @@ static int tsc_timer_probe(struct udevice *dev)
 	return 0;
 }
 
+ulong timer_get_boot_us(void)
+{
+	if (!gd->timer) {
+		u64 now_tick;
+
+		tsc_timer_ensure_setup();
+		now_tick = rdtsc();
+
+		now_tick -= gd->arch.tsc_base;
+		return now_tick / (gd->arch.clock_rate / 1000000);
+	}
+
+	return timer_get_us();
+}
+
 static const struct timer_ops tsc_timer_ops = {
 	.get_count = tsc_timer_get_count,
 };
-- 
2.13.2.932.g7449e964c-goog



More information about the U-Boot mailing list