kernel: update linux 3.8 to 3.8.3
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.8 / 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 @@ -33,6 +33,7 @@ struct twd_local_timer name __initdata =
33 };
34
35 int twd_local_timer_register(struct twd_local_timer *);
36 +unsigned long twd_timer_get_rate(void);
37
38 #ifdef CONFIG_HAVE_ARM_TWD
39 void twd_local_timer_of_register(void);
40 --- a/arch/arm/kernel/smp_twd.c
41 +++ b/arch/arm/kernel/smp_twd.c
42 @@ -10,6 +10,7 @@
43 */
44 #include <linux/init.h>
45 #include <linux/kernel.h>
46 +#include <linux/export.h>
47 #include <linux/clk.h>
48 #include <linux/delay.h>
49 #include <linux/device.h>
50 @@ -376,6 +377,13 @@ int __init twd_local_timer_register(stru
51 return twd_local_timer_common_register();
52 }
53
54 +/* Needed by mpcore_wdt */
55 +unsigned long twd_timer_get_rate(void)
56 +{
57 + return twd_timer_rate;
58 +}
59 +EXPORT_SYMBOL_GPL(twd_timer_get_rate);
60 +
61 #ifdef CONFIG_OF
62 const static struct of_device_id twd_of_match[] __initconst = {
63 { .compatible = "arm,cortex-a9-twd-timer", },
64 --- a/drivers/watchdog/mpcore_wdt.c
65 +++ b/drivers/watchdog/mpcore_wdt.c
66 @@ -101,9 +101,7 @@ static void mpcore_wdt_keepalive(struct
67
68 spin_lock(&wdt_lock);
69 /* Assume prescale is set to 256 */
70 - count = __raw_readl(wdt->base + TWD_WDOG_COUNTER);
71 - count = (0xFFFFFFFFU - count) * (HZ / 5);
72 - count = (count / 256) * mpcore_margin;
73 + count = (twd_timer_get_rate() / 256) * mpcore_margin;
74
75 /* Reload the counter */
76 writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);