Linux Watchdog driver development
 help / color / mirror / Atom feed
From: Andrej Picej <andrej.picej@norik.com>
To: support.opensource@diasemi.com, wim@linux-watchdog.org,
	linux@roeck-us.net, linux-watchdog@vger.kernel.org
Cc: andrej.picej@norik.com, y.bas@phytec.de, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] watchdog: da9062: reset board on watchdog timeout
Date: Wed, 24 Nov 2021 09:32:58 +0100	[thread overview]
Message-ID: <20211124083258.2606511-2-andrej.picej@norik.com> (raw)
In-Reply-To: <20211124083258.2606511-1-andrej.picej@norik.com>

From: Stefan Christ <s.christ@phytec.de>

In the default fuse configuration the watchdog poweroffs the system
instead of resetting it on a watchdog timeout. This patch changes the
behavior. Now the board is reseted and reboots.

Note: This patch requires that the config register CONFIG_I is
configured as writable in the da9062 multi function device.

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
---
 drivers/watchdog/da9062_wdt.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c
index f02cbd530538..a04613e68f4a 100644
--- a/drivers/watchdog/da9062_wdt.c
+++ b/drivers/watchdog/da9062_wdt.c
@@ -87,6 +87,20 @@ static int da9062_wdt_start(struct watchdog_device *wdd)
 	unsigned int selector;
 	int ret;
 
+	/*
+	 * Use da9062's SHUTDOWN mode instead of POWERDOWN for watchdog reset.
+	 * On timeout the PMIC should reset the system, not powering it
+	 * off.
+	 */
+	ret = regmap_update_bits(wdt->hw->regmap,
+				 DA9062AA_CONFIG_I,
+				 DA9062AA_WATCHDOG_SD_MASK,
+				 DA9062AA_WATCHDOG_SD_MASK);
+	if (ret)
+		dev_err(wdt->hw->dev,
+			"failed to set wdt reset mode. Expect poweroff on watchdog reset: %d\n",
+			ret);
+
 	selector = da9062_wdt_timeout_to_sel(wdt->wdtdev.timeout);
 	ret = da9062_wdt_update_timeout_register(wdt, selector);
 	if (ret)
-- 
2.25.1


  reply	other threads:[~2021-11-24  8:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  8:32 [PATCH 1/2] mfd: da9062: make register CONFIG_I writable Andrej Picej
2021-11-24  8:32 ` Andrej Picej [this message]
2021-11-26 13:28   ` [PATCH 2/2] watchdog: da9062: reset board on watchdog timeout Adam Thomson
2021-11-29 12:12     ` Andrej Picej
2021-11-30  9:41       ` Adam Thomson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211124083258.2606511-2-andrej.picej@norik.com \
    --to=andrej.picej@norik.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=support.opensource@diasemi.com \
    --cc=wim@linux-watchdog.org \
    --cc=y.bas@phytec.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox