Home Home > GIT Browse > SLE15
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYadan Fan <ydfan@suse.com>2018-07-11 18:25:13 +0800
committerYadan Fan <ydfan@suse.com>2018-07-11 18:25:40 +0800
commit816c6084089006ba90934ff6ef1294e1346f162f (patch)
tree01657981231c7cea4a143560193b4424be061cbc
parentb19dc7439ea49292298ab0eefb499905e0bb6419 (diff)
watchdog: da9063: Fix timeout handling during probe
(bsc#1100843). suse-commit: 5377bd872e139fd4de30f16dfb40adfeaf40a16c
-rw-r--r--drivers/watchdog/da9063_wdt.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index f0b1430cb10c..99997777c2d0 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -53,6 +53,18 @@ static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs)
return DA9063_TWDSCALE_MAX;
}
+/*
+ * Return 0 if watchdog is disabled, else non zero.
+ */
+static unsigned int da9063_wdt_is_running(struct da9063 *da9063)
+{
+ unsigned int val;
+
+ regmap_read(da9063->regmap, DA9063_REG_CONTROL_D, &val);
+
+ return val & DA9063_TWDSCALE_MASK;
+}
+
static int da9063_wdt_disable_timer(struct da9063 *da9063)
{
return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
@@ -216,6 +228,14 @@ static int da9063_wdt_probe(struct platform_device *pdev)
watchdog_set_drvdata(&wdt->wdtdev, wdt);
+ /* Change the timeout to the default value if the watchdog is running */
+ if (da9063_wdt_is_running(da9063)) {
+ unsigned int timeout;
+
+ timeout = da9063_wdt_timeout_to_sel(DA9063_WDG_TIMEOUT);
+ _da9063_wdt_set_timeout(da9063, timeout);
+ set_bit(WDOG_HW_RUNNING, &wdd->status);
+ }
return devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev);
}