kernel: update linux 3.2 to 3.2.12
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.2 / 992-mpcore_wdt_fix_watchdog_counter_loading.patch
1 Although the commit "98af057092f8f0dabe63c5df08adc2bbfbddb1d2
2 ARM: 6126/1: ARM mpcore_wdt: fix build failure and other fixes"
3 resolved long standing mpcore_wdt driver build problems, it
4 introduced an error in the relationship between the MPcore watchdog
5 timer clock rate and mpcore_margin, "MPcore timer margin in seconds",
6 such that watchdog timeouts are now arbitrary rather than the number
7 of seconds specified by mpcore_margin.
8
9 This change restores mpcore_wdt_keepalive() to its equivalent
10 implementation prior to commit 98af057 such that watchdog timeouts now
11 occur as specified by mpcore_margin.
12
13 The variable 'mpcore_timer_rate' which caused that build failure was
14 replaced by 'twd_timer_rate'. Adding exported function to obtain
15 'twd_timer_rate' value in mpcore_wdt driver.
16
17 MPCORE_WATCHDOG needed to build 'mpcore_wdt' already depends on
18 HAVE_ARM_TWD needed to build 'smp_twd', so from the point of view of
19 'mpcore_wdt' driver the exported function will always exist.
20
21 Signed-off-by: Valentine Barshak <vbarshak@mvista.com>
22 Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
23 ---
24
25 arch/arm/include/asm/smp_twd.h | 1 +
26 arch/arm/kernel/smp_twd.c | 7 +++++++
27 drivers/watchdog/mpcore_wdt.c | 4 +---
28 3 files changed, 9 insertions(+), 3 deletions(-)
29
30 --- a/arch/arm/include/asm/smp_twd.h
31 +++ b/arch/arm/include/asm/smp_twd.h
32 @@ -24,5 +24,6 @@ extern void __iomem *twd_base;
33
34 void twd_timer_setup(struct clock_event_device *);
35 void twd_timer_stop(struct clock_event_device *);
36 +unsigned long twd_timer_get_rate(void);
37
38 #endif
39 --- a/arch/arm/kernel/smp_twd.c
40 +++ b/arch/arm/kernel/smp_twd.c
41 @@ -185,3 +185,10 @@ void __cpuinit twd_timer_setup(struct cl
42
43 enable_percpu_irq(clk->irq, 0);
44 }
45 +
46 +/* Needed by mpcore_wdt */
47 +unsigned long twd_timer_get_rate(void)
48 +{
49 + return twd_timer_rate;
50 +}
51 +EXPORT_SYMBOL_GPL(twd_timer_get_rate);
52 --- a/drivers/watchdog/mpcore_wdt.c
53 +++ b/drivers/watchdog/mpcore_wdt.c
54 @@ -99,9 +99,7 @@ static void mpcore_wdt_keepalive(struct
55
56 spin_lock(&wdt_lock);
57 /* Assume prescale is set to 256 */
58 - count = __raw_readl(wdt->base + TWD_WDOG_COUNTER);
59 - count = (0xFFFFFFFFU - count) * (HZ / 5);
60 - count = (count / 256) * mpcore_margin;
61 + count = (twd_timer_get_rate() / 256) * mpcore_margin;
62
63 /* Reload the counter */
64 writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);