[ARM] twd: Always calibrate local timer
authorColin Cross <ccross@android.com>
Wed, 22 Sep 2010 06:12:19 +0000 (23:12 -0700)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:28:46 +0000 (16:28 -0700)
Change-Id: I075f883739d0eeea3b6b10da003119431cf3c2d2
Signed-off-by: Colin Cross <ccross@android.com>
arch/arm/kernel/smp_twd.c

index c05e88a753544d00549070018c66b414c606bcf9..014862ae170c22eccfa58be45134cda5c687c56a 100644 (file)
@@ -112,48 +112,49 @@ static void __cpuinit twd_calibrate_rate(unsigned long target_rate,
         * If this is the first time round, we need to work out how fast
         * the timer ticks
         */
-       if (twd_timer_rate == 0) {
-               printk(KERN_INFO "Calibrating local timer... ");
+       printk(KERN_INFO "Calibrating local timer... ");
 
-               /* Wait for a tick to start */
-               waitjiffies = get_jiffies_64() + 1;
+       /* Wait for a tick to start */
+       waitjiffies = get_jiffies_64() + 1;
 
-               while (get_jiffies_64() < waitjiffies)
-                       udelay(10);
+       while (get_jiffies_64() < waitjiffies)
+               udelay(10);
 
-               /* OK, now the tick has started, let's get the timer going */
-               waitjiffies += 5;
+       /* OK, now the tick has started, let's get the timer going */
+       waitjiffies += 5;
 
-                                /* enable, no interrupt or reload */
-               __raw_writel(0x1, twd_base + TWD_TIMER_CONTROL);
+                        /* enable, no interrupt or reload */
+       __raw_writel(0x1, twd_base + TWD_TIMER_CONTROL);
 
-                                /* maximum value */
-               __raw_writel(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER);
+                        /* maximum value */
+       __raw_writel(0xFFFFFFFFU, twd_base + TWD_TIMER_COUNTER);
 
-               while (get_jiffies_64() < waitjiffies)
-                       udelay(10);
+       while (get_jiffies_64() < waitjiffies)
+               udelay(10);
 
-               count = __raw_readl(twd_base + TWD_TIMER_COUNTER);
+       count = __raw_readl(twd_base + TWD_TIMER_COUNTER);
 
-               twd_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5);
+       twd_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5);
 
-               /*
-                * If a target rate has been requested, adjust the TWD prescaler
-                * to get the closest lower frequency.
-                */
-               if (target_rate) {
-                       twd_periphclk_prescaler = periphclk_prescaler;
-                       twd_target_rate = target_rate;
-
-                       cpu_rate = twd_timer_rate * periphclk_prescaler;
-                       twd_timer_rate = twd_target_rate;
-                       twd_recalc_prescaler(cpu_rate);
-               }
+       /*
+        * If a target rate has been requested, adjust the TWD prescaler
+        * to get the closest lower frequency.
+        */
+       if (target_rate) {
+               twd_periphclk_prescaler = periphclk_prescaler;
+               twd_target_rate = target_rate;
 
-               printk("%lu.%02luMHz.\n", twd_timer_rate / 1000000,
+               printk("%lu.%02luMHz, setting to ",
+                       twd_timer_rate / 1000000,
                        (twd_timer_rate / 10000) % 100);
+               cpu_rate = twd_timer_rate * periphclk_prescaler;
+               twd_timer_rate = twd_target_rate;
+               twd_recalc_prescaler(cpu_rate);
        }
 
+       printk("%lu.%02luMHz.\n", twd_timer_rate / 1000000,
+               (twd_timer_rate / 10000) % 100);
+
        load = twd_timer_rate / HZ;
 
        __raw_writel(load, twd_base + TWD_TIMER_LOAD);