linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: da9063: Disable watchdog before changing timeout
@ 2017-03-15 18:17 Michael Tretter
  2017-03-15 18:54 ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Tretter @ 2017-03-15 18:17 UTC (permalink / raw)
  To: linux-watchdog; +Cc: support.opensource, wim, linux, p.zabel, Michael Tretter

The DA9063 watchdog always resets the system when systemd changes the
timeout value after Barebox already set a timeout value.

If the watchdog is disabled before setting a new timeout, the system is
not reset and the watchdog is still enabled.

This patch is based on a previous patch by Philipp Zabel [1], but does
not wait for 150 us, because the DA9063 does not require a delay after
disabling the watchdog.

[1] https://www.spinics.net/lists/linux-watchdog/msg07143.html

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/watchdog/da9063_wdt.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 4691c5509129..fcdc12d14d03 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -55,8 +55,19 @@ static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs)
 
 static int _da9063_wdt_set_timeout(struct da9063 *da9063, unsigned int regval)
 {
-	return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
-				  DA9063_TWDSCALE_MASK, regval);
+	int ret;
+
+	ret = regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
+			         DA9063_TWDSCALE_MASK, DA9063_TWDSCALE_DISABLE);
+	if (ret)
+		dev_warn(da9063->dev,
+			 "Failed to disable watchdog before setting new timeout\n");
+
+	if (regval)
+		ret = regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
+				DA9063_TWDSCALE_MASK, regval);
+
+	return ret;
 }
 
 static int da9063_wdt_start(struct watchdog_device *wdd)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-23 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-15 18:17 [PATCH] watchdog: da9063: Disable watchdog before changing timeout Michael Tretter
2017-03-15 18:54 ` Guenter Roeck
2017-03-16  9:34   ` Michael Tretter
2017-03-16 11:34     ` Steve Twiss
2017-03-23 16:52       ` Michael Tretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).