[U-Boot] [PATCH v3 3/6] dm: x86: Update timer_get_boot_us to work before DM is ready
Simon Glass
sjg at chromium.org
Wed Sep 6 01:49:47 UTC 2017
Use the new separate init function so that we can make use of the timer
before driver model is started up.
At some point we should consider adding the microsecond timer to the timer
uclass interface since it would reduce the amount of plumbing here
slightly.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v3: None
Changes in v2:
- Rebase on top of early timer code and simplify slightly
drivers/timer/tsc_timer.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c
index 0012fecde0..db49de87a2 100644
--- a/drivers/timer/tsc_timer.c
+++ b/drivers/timer/tsc_timer.c
@@ -295,11 +295,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();
@@ -374,6 +369,20 @@ u64 notrace timer_early_get_count(void)
return rdtsc() - gd->arch.tsc_base;
}
+ulong timer_get_boot_us(void)
+{
+ if (!gd->timer) {
+ u64 now_tick;
+
+ tsc_timer_ensure_setup();
+ now_tick = rdtsc() - 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.14.1.581.gf28d330327-goog
More information about the U-Boot
mailing list