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 <s...@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 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot