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