Home Home > GIT Browse > openSUSE-42.3
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYadan Fan <ydfan@suse.com>2018-07-11 18:24:01 +0800
committerYadan Fan <ydfan@suse.com>2018-07-11 18:24:10 +0800
commit0387addd2c7ae4194a69117adb6b694b9a753813 (patch)
tree0217debe0d632ee8da16095a6ab8b7d6225b1c15
parent1edbab2fb35c19b1ed7101913e52e0e1755cb728 (diff)
watchdog: da9063: Fix setting/changing timeout (bsc#1100843).
-rw-r--r--drivers/watchdog/da9063_wdt.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 6bf130bd863d..e531c1c6a3f4 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -54,8 +54,31 @@ static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs)
return DA9063_TWDSCALE_MAX;
}
+static int da9063_wdt_disable_timer(struct da9063 *da9063)
+{
+ return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
+ DA9063_TWDSCALE_MASK,
+ DA9063_TWDSCALE_DISABLE);
+}
+
static int _da9063_wdt_set_timeout(struct da9063 *da9063, unsigned int regval)
{
+ int ret;
+
+ /*
+ * The watchdog triggers a reboot if a timeout value is already
+ * programmed because the timeout value combines two functions
+ * in one: indicating the counter limit and starting the watchdog.
+ * The watchdog must be disabled to be able to change the timeout
+ * value if the watchdog is already running. Then we can set the
+ * new timeout value which enables the watchdog again.
+ */
+ ret = da9063_wdt_disable_timer(da9063);
+ if (ret)
+ return ret;
+
+ usleep_range(150, 300);
+
return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
DA9063_TWDSCALE_MASK, regval);
}
@@ -80,8 +103,7 @@ static int da9063_wdt_stop(struct watchdog_device *wdd)
struct da9063_watchdog *wdt = watchdog_get_drvdata(wdd);
int ret;
- ret = regmap_update_bits(wdt->da9063->regmap, DA9063_REG_CONTROL_D,
- DA9063_TWDSCALE_MASK, DA9063_TWDSCALE_DISABLE);
+ ret = da9063_wdt_disable_timer(da9063);
if (ret)
dev_alert(wdt->da9063->dev, "Watchdog failed to stop (err = %d)\n",
ret);