@@ -192,6 +192,16 @@ static int sunxi_wdt_start(struct watchdog_device *wdt_dev)
return 0;
}
+static int sunxi_wdt_enabled(struct sunxi_wdt_dev *wdt)
+{
+ u32 reg;
+ void __iomem *wdt_base = wdt->wdt_base;
+ const struct sunxi_wdt_reg *regs = wdt->wdt_regs;
+
+ reg = readl(wdt_base + regs->wdt_mode);
+ return (reg & WDT_MODE_EN);
+}
+
static const struct watchdog_info sunxi_wdt_info = {
.identity = DRV_NAME,
.options = WDIOF_SETTIMEOUT |
@@ -268,6 +278,11 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
sunxi_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT;
sunxi_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT;
sunxi_wdt->wdt_dev.parent = dev;
+ if (sunxi_wdt_enabled(sunxi_wdt)) {
+ set_bit(WDOG_HW_RUNNING, &sunxi_wdt->wdt_dev.status);
+ } else {
+ clear_bit(WDOG_HW_RUNNING, &sunxi_wdt->wdt_dev.status);
+ }
watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, dev);
watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout);
@@ -275,7 +290,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
watchdog_set_drvdata(&sunxi_wdt->wdt_dev, sunxi_wdt);
- sunxi_wdt_stop(&sunxi_wdt->wdt_dev);
+ if (watchdog_hw_running(&sunxi_wdt->wdt_dev))
+ sunxi_wdt_start(&sunxi_wdt->wdt_dev);
+ else
+ sunxi_wdt_stop(&sunxi_wdt->wdt_dev);
watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev);
err = devm_watchdog_register_device(dev, &sunxi_wdt->wdt_dev);