From 0d2beae1042fcc080e6e172598cf9d1dd863befe Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 21 Sep 2010 23:12:19 -0700 Subject: [PATCH] [ARM] twd: Always calibrate local timer Change-Id: I075f883739d0eeea3b6b10da003119431cf3c2d2 Signed-off-by: Colin Cross --- arch/arm/kernel/smp_twd.c | 59 ++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index c05e88a75354..014862ae170c 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -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); -- 2.34.1