ARM: tegra: clock: Register arch timer delay early
Alex Frid [Wed, 4 Sep 2013 22:54:27 +0000 (15:54 -0700)]
Registered ARM arch timer as delay timer early, so that udelay() calls
provide proper delays for initial clock table settings.

Bug 1356220

Change-Id: I98021507d0bcf129179c97ce395cb7edf2c682e4
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/270411
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bo Yan <byan@nvidia.com>

arch/arm/mach-tegra/cpu_timer_arch.c

index f6d1aaa..bb027ea 100644 (file)
@@ -33,6 +33,7 @@
 #include <asm/system.h>
 #include <asm/arch_timer.h>
 #include <asm/sched_clock.h>
+#include <asm/delay.h>
 
 #include "clock.h"
 #include "iomap.h"
@@ -47,6 +48,7 @@ static u32 arch_timer_us_mult, arch_timer_us_shift;
        __raw_readl(timer_reg_base + (reg))
 
 bool arch_timer_initialized;
+static struct delay_timer arch_delay_timer;
 
 #ifdef CONFIG_TEGRA_PRE_SILICON_SUPPORT
 #ifndef CONFIG_TRUSTED_FOUNDATIONS
@@ -79,6 +81,14 @@ static int local_timer_is_architected(void)
 #endif
 }
 
+static unsigned long arch_timer_read_current_timer(void)
+{
+       cycle_t cval = 0;
+
+       asm volatile("mrrc p15, 0, %Q0, %R0, c14" : "=r" (cval));
+       return cval;
+}
+
 void __init tegra_cpu_timer_init(void)
 {
        u32 tsc_ref_freq;
@@ -121,6 +131,12 @@ void __init tegra_cpu_timer_init(void)
 #endif
        clocks_calc_mult_shift(&arch_timer_us_mult, &arch_timer_us_shift,
                                tsc_ref_freq, USEC_PER_SEC, 0);
+
+       /* register arch timer as delay timer */
+       arch_delay_timer.read_current_timer = &arch_timer_read_current_timer;
+       arch_delay_timer.freq = tsc_ref_freq;
+       register_current_timer_delay(&arch_delay_timer);
+
        return;
 }