mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org, Sascha Hauer <s.hauer@pengutronix.de>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH 2/2] watchdog: gpio: support reset-from-wdt gpio
Date: Fri, 30 Oct 2026 17:03:17 +0100	[thread overview]
Message-ID: <20261030-v2026-10-0-topic-gpio-wdt-v1-2-e81eb3470f62@pengutronix.de> (raw)
In-Reply-To: <20261030-v2026-10-0-topic-gpio-wdt-v1-0-e81eb3470f62@pengutronix.de>

Support the new reset-from-wdt-gpios device tree binding.

This gpio connection signals, that the last reset was issued by this
watchdog.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/watchdog/gpio_wdt.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index 3270c15ed1..6a0df75326 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <driver.h>
 #include <watchdog.h>
+#include <reset_source.h>
 #include <superio.h>
 #include <linux/gpio/consumer.h>
 
@@ -18,6 +19,7 @@ enum {
 
 struct gpio_wdt_priv {
 	struct gpio_desc *gpiod;
+	struct gpio_desc *wdt_reset;
 	bool		state;
 	bool		always_running;
 	bool		started;
@@ -122,6 +124,20 @@ static int gpio_wdt_probe(struct device *dev)
 	if (IS_ERR(priv->gpiod))
 		return PTR_ERR(priv->gpiod);
 
+	priv->wdt_reset = gpiod_get_optional(dev, "reset-from-wdt", GPIOD_IN);
+	if (IS_ERR(priv->wdt_reset))
+		return dev_errp_probe(dev, priv->wdt_reset, "no reset-from-wdt found");
+
+	if (priv->wdt_reset) {
+		int val = gpiod_get_value(priv->wdt_reset);
+
+		if (val < 0)
+			return val;
+
+		if (val)
+			reset_source_set_device(dev, RESET_WDG, 200);
+	}
+
 	priv->always_running = of_property_read_bool(dev->of_node, "always-running");
 
 	priv->wdd.hwdev		= dev;

-- 
2.52.0




      parent reply	other threads:[~2026-10-30 16:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 16:03 [PATCH 0/2] watchdog: gpio-wdt: add support for more dt-bindings Steffen Trumtrar
2026-10-30 16:03 ` [PATCH 1/2] watchdog: gpio: support always-running Steffen Trumtrar
2026-10-30 16:03 ` Steffen Trumtrar [this message]

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=20261030-v2026-10-0-topic-gpio-wdt-v1-2-e81eb3470f62@pengutronix.de \
    --to=s.trumtrar@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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