[generic]: add 3.7-rc6 support (patch 820 still has to be fixed)
[openwrt.git] / target / linux / generic / patches-3.7 / 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 @@ -352,6 +352,13 @@ int __init twd_local_timer_register(stru
43         return twd_local_timer_common_register();
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 +
53  #ifdef CONFIG_OF
54  const static struct of_device_id twd_of_match[] __initconst = {
55         { .compatible = "arm,cortex-a9-twd-timer",      },
56 --- a/drivers/watchdog/mpcore_wdt.c
57 +++ b/drivers/watchdog/mpcore_wdt.c
58 @@ -102,9 +102,7 @@ static void mpcore_wdt_keepalive(struct
59  
60         spin_lock(&wdt_lock);
61         /* Assume prescale is set to 256 */
62 -       count =  __raw_readl(wdt->base + TWD_WDOG_COUNTER);
63 -       count = (0xFFFFFFFFU - count) * (HZ / 5);
64 -       count = (count / 256) * mpcore_margin;
65 +       count = (twd_timer_get_rate() / 256) * mpcore_margin;
66  
67         /* Reload the counter */
68         writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);