Home Home > GIT Browse
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
commit928db1f56a4306b025b2a674b6a30a130103017f (patch)
tree13deb33d0821b6de8408d1afb5fd2a256a8f7c50
parent19dda0e4a99487f7360980746a39ffd01fb0b297 (diff)
watchdog: da9063: Fix setting/changing timeout (bsc#1100843).
-rw-r--r--patches.fixes/watchdog-da9063-Fix-setting-changing-timeout.patch78
-rw-r--r--series.conf3
2 files changed, 81 insertions, 0 deletions
diff --git a/patches.fixes/watchdog-da9063-Fix-setting-changing-timeout.patch b/patches.fixes/watchdog-da9063-Fix-setting-changing-timeout.patch
new file mode 100644
index 0000000000..9dbb7d37c0
--- /dev/null
+++ b/patches.fixes/watchdog-da9063-Fix-setting-changing-timeout.patch
@@ -0,0 +1,78 @@
+From ca074b63caeaf675017a8e3d0734d4a04cf6ad61 Mon Sep 17 00:00:00 2001
+From: Marco Felsch <m.felsch@pengutronix.de>
+Date: Mon, 28 May 2018 08:45:44 +0200
+Subject: [PATCH] watchdog: da9063: Fix setting/changing timeout
+Patch-mainline: v4.18-rc1
+Git-commit: e46bb55dbc94b06f5ee466e2f50723b56781e661
+References: bsc#1100843
+
+If the timeout value is set more than once the DA9063 watchdog triggers
+a reset signal which reset the system.
+
+To update the timeout value we have to disable the watchdog, clear the
+watchdog counter value and write the new timeout value to the watchdog.
+Clearing the counter value is a feature to be on the safe side because the
+data sheet doesn't describe the behaviour of the watchdog counter value
+after a watchdog disabling-enable-sequence.
+
+The patch is based on Philipp Zabel's previous patch.
+
+Fixes: 5e9c16e37608 ("watchdog: Add DA9063 PMIC watchdog driver.")
+Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
+Reviewed-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
+Acked-by: Yadan Fan <ydfan@suse.com>
+---
+ drivers/watchdog/da9063_wdt.c | 26 ++++++++++++++++++++++++--
+ 1 file 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);
+--
+2.17.1
+
diff --git a/series.conf b/series.conf
index bbfb1d8984..9785bc0a67 100644
--- a/series.conf
+++ b/series.conf
@@ -23886,6 +23886,9 @@
# bsc#1097501
patches.drivers/scsi-qla2xxx-Spinlock-recursion-in-qla_target.patch
+ # watchdog da9063
+ patches.fixes/watchdog-da9063-Fix-setting-changing-timeout.patch
+
########################################################
# You'd better have a good reason for adding a patch
# below here.