diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2014-02-10 18:00:23 -0500 |
---|---|---|
committer | Jason Cooper <jason@lakedaemon.net> | 2014-02-21 22:43:01 -0500 |
commit | d9d0c53dac7757aa198b1bd60c56f996c78c7ff7 (patch) | |
tree | e3d7a17fe3d464ec6d2e311a212e0f642a47f1cb | |
parent | e0e931ac15bb977dcfd690cdfd6f5b1d44a5155d (diff) |
watchdog: orion: Make sure the watchdog is initially stopped
Having the watchdog initially fully stopped is important to avoid
any spurious watchdog triggers, in case the registers are not in
its reset state.
If the watchdog rstout is enabled and the watchdog counter running,
this initial stop is not performed, to comply with the 'nowayout'
parameter.
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Tested-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Acked-by: Wim Van Sebroeck <wim@iguana.be>
Tested-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
-rw-r--r-- | drivers/watchdog/orion_wdt.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index 67460337808c..e10b0b1accce 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c | |||
@@ -77,6 +77,16 @@ static int orion_wdt_stop(struct watchdog_device *wdt_dev) | |||
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
79 | 79 | ||
80 | static int orion_wdt_enabled(void) | ||
81 | { | ||
82 | bool enabled, running; | ||
83 | |||
84 | enabled = readl(RSTOUTn_MASK) & WDT_RESET_OUT_EN; | ||
85 | running = readl(wdt_reg + TIMER_CTRL) & WDT_EN; | ||
86 | |||
87 | return enabled && running; | ||
88 | } | ||
89 | |||
80 | static unsigned int orion_wdt_get_timeleft(struct watchdog_device *wdt_dev) | 90 | static unsigned int orion_wdt_get_timeleft(struct watchdog_device *wdt_dev) |
81 | { | 91 | { |
82 | return readl(wdt_reg + WDT_VAL) / wdt_tclk; | 92 | return readl(wdt_reg + WDT_VAL) / wdt_tclk; |
@@ -142,6 +152,15 @@ static int orion_wdt_probe(struct platform_device *pdev) | |||
142 | orion_wdt.max_timeout = wdt_max_duration; | 152 | orion_wdt.max_timeout = wdt_max_duration; |
143 | watchdog_init_timeout(&orion_wdt, heartbeat, &pdev->dev); | 153 | watchdog_init_timeout(&orion_wdt, heartbeat, &pdev->dev); |
144 | 154 | ||
155 | /* | ||
156 | * Let's make sure the watchdog is fully stopped, unless it's | ||
157 | * explicitly enabled. This may be the case if the module was | ||
158 | * removed and re-insterted, or if the bootloader explicitly | ||
159 | * set a running watchdog before booting the kernel. | ||
160 | */ | ||
161 | if (!orion_wdt_enabled()) | ||
162 | orion_wdt_stop(&orion_wdt); | ||
163 | |||
145 | watchdog_set_nowayout(&orion_wdt, nowayout); | 164 | watchdog_set_nowayout(&orion_wdt, nowayout); |
146 | ret = watchdog_register_device(&orion_wdt); | 165 | ret = watchdog_register_device(&orion_wdt); |
147 | if (ret) | 166 | if (ret) |