ar71xx: avoid spurious restarts caused by the watchdog on AR934x
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-3.10 / 104-watchdog-ath79-wdt-avoid-spurious-restarts-on-AR934x.patch
1 From 2ff030d44672d745c5327b72463af43f5103e99b Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Tue, 25 Mar 2014 17:07:46 +0100
4 Subject: [PATCH] watchdog: ath79-wdt: avoid spurious restarts on AR934x
5
6 On some AR934x based systems, where the frequency of
7 the AHB bus is relatively high, the built-in watchdog
8 causes a spurious restart when it gets enabled.
9
10 The possible cause of these restarts is that the timeout
11 value written into the TIMER register does not reaches
12 the hardware in time.
13
14 Add an explicit delay into the ath79_wdt_enable function
15 to avoid the spurious restarts.
16
17 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
18 Cc: <stable@vger.kernel.org>
19 ---
20 drivers/watchdog/ath79_wdt.c | 10 ++++++++++
21 1 file changed, 10 insertions(+)
22
23 --- a/drivers/watchdog/ath79_wdt.c
24 +++ b/drivers/watchdog/ath79_wdt.c
25 @@ -20,6 +20,7 @@
26 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27
28 #include <linux/bitops.h>
29 +#include <linux/delay.h>
30 #include <linux/errno.h>
31 #include <linux/fs.h>
32 #include <linux/init.h>
33 @@ -91,6 +92,15 @@ static inline void ath79_wdt_keepalive(v
34 static inline void ath79_wdt_enable(void)
35 {
36 ath79_wdt_keepalive();
37 +
38 + /*
39 + * Updating the TIMER register requires a few microseconds
40 + * on the AR934x SoCs at least. Use a small delay to ensure
41 + * that the TIMER register is updated within the hardware
42 + * before enabling the watchdog.
43 + */
44 + udelay(2);
45 +
46 ath79_wdt_wr(WDOG_REG_CTRL, WDOG_CTRL_ACTION_FCR);
47 /* flush write */
48 ath79_wdt_rr(WDOG_REG_CTRL);