]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
watchdog: orion: Make sure the watchdog is initially stopped
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Mon, 10 Feb 2014 23:00:23 +0000 (20:00 -0300)
committerJason Cooper <jason@lakedaemon.net>
Sat, 22 Feb 2014 03:43:01 +0000 (03:43 +0000)
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>
drivers/watchdog/orion_wdt.c

index 67460337808cce028a8c34c8d16e19f29845cd20..e10b0b1accceeee8cc3eb73d746b2dc36ac6033a 100644 (file)
@@ -77,6 +77,16 @@ static int orion_wdt_stop(struct watchdog_device *wdt_dev)
        return 0;
 }
 
+static int orion_wdt_enabled(void)
+{
+       bool enabled, running;
+
+       enabled = readl(RSTOUTn_MASK) & WDT_RESET_OUT_EN;
+       running = readl(wdt_reg + TIMER_CTRL) & WDT_EN;
+
+       return enabled && running;
+}
+
 static unsigned int orion_wdt_get_timeleft(struct watchdog_device *wdt_dev)
 {
        return readl(wdt_reg + WDT_VAL) / wdt_tclk;
@@ -142,6 +152,15 @@ static int orion_wdt_probe(struct platform_device *pdev)
        orion_wdt.max_timeout = wdt_max_duration;
        watchdog_init_timeout(&orion_wdt, heartbeat, &pdev->dev);
 
+       /*
+        * Let's make sure the watchdog is fully stopped, unless it's
+        * explicitly enabled. This may be the case if the module was
+        * removed and re-insterted, or if the bootloader explicitly
+        * set a running watchdog before booting the kernel.
+        */
+       if (!orion_wdt_enabled())
+               orion_wdt_stop(&orion_wdt);
+
        watchdog_set_nowayout(&orion_wdt, nowayout);
        ret = watchdog_register_device(&orion_wdt);
        if (ret)