From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: "Pali Rohár" <pali@kernel.org>, "Marek Behún" <kabel@kernel.org>,
"Tzung-Bi Shih" <tzungbi@kernel.org>,
"Marc Zyngier" <maz@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Madhavan Srinivasan" <maddy@linux.ibm.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
"Shrikanth Hegde" <sshegde@linux.ibm.com>,
linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH v4 2/3] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO
Date: Tue, 24 Nov 2026 06:01:17 +0100 [thread overview]
Message-ID: <20261124050118.87944-3-pepe.schlehofer@gmail.com> (raw)
In-Reply-To: <20261124050118.87944-1-pepe.schlehofer@gmail.com>
From: Pali Rohár <pali@kernel.org>
On some boards the WDI (watchdog input) pin of the chip is connected to
a GPIO, and only the SET pins are mapped to the register.
Take the GPIO from the optional wdi-gpios property. When it is present,
ping the watchdog through it instead of the register.
Signed-off-by: Pali Rohár <pali@kernel.org>
[pepe.schlehofer@gmail.com: use wdi-gpios, request the GPIO as an output
with devm_gpiod_get_optional(), ping without the lock, include
linux/delay.h, update the header comment]
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
Notes:
Changes in v4:
- take the GPIO from wdi-gpios
- request it with devm_gpiod_get_optional() (Tzung-Bi) and
GPIOD_OUT_LOW. v3 passed GPIOD_FLAGS_BIT_DIR_OUT alone, which sets
no direction
- ping without the lock, with gpiod_set_value_cansleep() (Tzung-Bi,
Guenter)
- include linux/delay.h (Tzung-Bi)
- print the error once (Tzung-Bi)
- say in the commit message that the GPIO replaces the register for
the ping (Tzung-Bi)
- update the comment at the top of the file
Changes in v3:
* Use gpiod_set_value()
Changes in v2:
* Usage of dev_err_probe()
* Fixing assignment of wdt->ping
* Remove clearing of wdt->gpio_wdi
* Move YAML change to separate patch
drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
index 9e46b86b9b20..482cf9f6bd6e 100644
--- a/drivers/watchdog/max63xx_wdt.c
+++ b/drivers/watchdog/max63xx_wdt.c
@@ -7,8 +7,9 @@
* Copyright (C) 2009 Marc Zyngier <maz@misterjones.org>
*
* This driver assumes the watchdog pins are memory mapped (as it is
- * the case for the Arcom Zeus). Should it be connected over GPIOs or
- * another interface, some abstraction will have to be introduced.
+ * the case for the Arcom Zeus). The WDI pin can be connected to a GPIO
+ * instead. Should the other pins be connected over GPIOs or another
+ * interface, some abstraction will have to be introduced.
*/
#include <linux/err.h>
@@ -18,6 +19,8 @@
#include <linux/kernel.h>
#include <linux/watchdog.h>
#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/io.h>
@@ -50,6 +53,9 @@ struct max63xx_wdt {
void __iomem *base;
spinlock_t lock;
+ /* optional GPIO connected to the WDI pin */
+ struct gpio_desc *gpio_wdi;
+
/* WDI and WSET bits write access routines */
void (*ping)(struct max63xx_wdt *wdt);
void (*set)(struct max63xx_wdt *wdt, u8 set);
@@ -155,6 +161,13 @@ static const struct watchdog_info max63xx_wdt_info = {
.identity = "max63xx Watchdog",
};
+static void max63xx_gpio_ping(struct max63xx_wdt *wdt)
+{
+ gpiod_set_value_cansleep(wdt->gpio_wdi, 1);
+ udelay(1);
+ gpiod_set_value_cansleep(wdt->gpio_wdi, 0);
+}
+
static void max63xx_mmap_ping(struct max63xx_wdt *wdt)
{
u8 val;
@@ -226,6 +239,13 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
if (err)
return err;
+ wdt->gpio_wdi = devm_gpiod_get_optional(dev, "wdi", GPIOD_OUT_LOW);
+ if (IS_ERR(wdt->gpio_wdi))
+ return dev_err_probe(dev, PTR_ERR(wdt->gpio_wdi),
+ "failed to get the WDI GPIO\n");
+ if (wdt->gpio_wdi)
+ wdt->ping = max63xx_gpio_ping;
+
platform_set_drvdata(pdev, &wdt->wdd);
watchdog_set_drvdata(&wdt->wdd, wdt);
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-24 5:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 5:01 [PATCH v4 0/3] watchdog: max63xx_wdt: Support a WDI pin connected to a GPIO Josef Schlehofer
2026-11-24 5:01 ` [PATCH v4 1/3] dt-bindings: watchdog: maxim,max63xx: Add wdi-gpios Josef Schlehofer
2026-12-01 5:59 ` Krzysztof Kozlowski
2026-12-01 23:40 ` Guenter Roeck
2026-11-24 5:01 ` Josef Schlehofer [this message]
2026-11-25 5:46 ` [PATCH v4 2/3] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Tzung-Bi Shih
2026-12-01 23:40 ` Guenter Roeck
2026-11-24 5:01 ` [PATCH v4 3/3] powerpc: dts: turris1x.dts: Use wdi-gpios for the watchdog Josef Schlehofer
2026-11-24 9:12 ` Madhavan Srinivasan
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=20261124050118.87944-3-pepe.schlehofer@gmail.com \
--to=pepe.schlehofer@gmail.com \
--cc=chleroy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kabel@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=maz@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=pali@kernel.org \
--cc=ritesh.list@gmail.com \
--cc=robh@kernel.org \
--cc=sshegde@linux.ibm.com \
--cc=tzungbi@kernel.org \
--cc=wim@linux-watchdog.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.