diff mbox series

[U-Boot,v3,3/6] dm: x86: Update timer_get_boot_us to work before DM is ready

Message ID 20170906014950.132960-4-sjg@chromium.org
State Rejected
Delegated to: Bin Meng
Headers show
Series x86: bootstage: Fix bootstage operation on link | expand

Commit Message

Simon Glass Sept. 6, 2017, 1:49 a.m. UTC
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@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(-)

Comments

Bin Meng Sept. 16, 2017, 6:29 a.m. UTC | #1
On Wed, Sep 6, 2017 at 9:49 AM, Simon Glass <sjg@chromium.org> wrote:
> 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@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(-)
>

Drop this patch as it is not needed. thanks!

Regards,
Bin
diff mbox series

Patch

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,
 };