mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/3] watchdog: max63xx_wdt: Support a WDI pin connected to a GPIO
@ 2026-11-24  5:01 Josef Schlehofer
  2026-11-24  5:01 ` [PATCH v4 1/3] dt-bindings: watchdog: maxim,max63xx: Add wdi-gpios Josef Schlehofer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-24  5:01 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Pali Rohár, Marek Behún, Tzung-Bi Shih, Marc Zyngier,
	Linus Walleij, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy (CS GROUP),
	Ritesh Harjani (IBM),
	Shrikanth Hegde, linux-watchdog, devicetree, linuxppc-dev,
	linux-kernel

This series picks up Pali's patches [1], which stopped at v3 in July
2022. Pali is on Cc.

The MAX6370 on CZ.NIC Turris 1.x routers has its SET pins connected
through a CPLD, but its WDI pin is connected to a SoC GPIO. The driver
currently cannot use this GPIO, despite turris1x.dts already describing
it.

This series adds GPIO support to the driver and binding, and updates
turris1x.dts to use the new wdi-gpios property.

Changes in v4:

- Address review feedback from Rob, Tzung-Bi and Guenter.
- Fix GPIO direction handling and remove unnecessary locking.
- Rename the property in turris1x.dts.

Tested on a Turris 1.1 running the Turris OS build of Linux 6.6.142
with patches 2 and 3 backported. The watchdog works with periodic GPIO
pings and resets the board after the pings stop. On v7.4-rc3, also
tested the binding with dt_binding_check and dtbs_check, and built the
driver for powerpc, and for arm64 with and without GPIOLIB. GPIO
behaviour was additionally tested under QEMU.

Patch 3 can go through the powerpc tree once the binding is in.

[1] https://lore.kernel.org/r/20220705001023.14660-1-pali@kernel.org/

Josef Schlehofer (1):
  powerpc: dts: turris1x.dts: Use wdi-gpios for the watchdog

Pali Rohár (2):
  dt-bindings: watchdog: maxim,max63xx: Add wdi-gpios
  watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO

 .../bindings/watchdog/maxim,max63xx.yaml      |  6 +++++
 arch/powerpc/boot/dts/turris1x.dts            |  2 +-
 drivers/watchdog/max63xx_wdt.c                | 24 +++++++++++++++++--
 3 files changed, 29 insertions(+), 3 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.54.0 (Apple Git-157)


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

* [PATCH v4 1/3] dt-bindings: watchdog: maxim,max63xx: Add wdi-gpios
  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 ` Josef Schlehofer
  2026-11-24  5:01 ` [PATCH v4 2/3] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Josef Schlehofer
  2026-11-24  5:01 ` [PATCH v4 3/3] powerpc: dts: turris1x.dts: Use wdi-gpios for the watchdog Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-24  5:01 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Pali Rohár, Marek Behún, Tzung-Bi Shih, Marc Zyngier,
	Linus Walleij, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy (CS GROUP),
	Ritesh Harjani (IBM),
	Shrikanth Hegde, linux-watchdog, devicetree, linuxppc-dev,
	linux-kernel

From: Pali Rohár <pali@kernel.org>

On some boards only the SET pins of the watchdog are mapped to the
register, and its WDI (watchdog input) pin is connected to a GPIO. The
CZ.NIC Turris 1.x routers are wired this way.

Add an optional wdi-gpios property for that GPIO.

Signed-off-by: Pali Rohár <pali@kernel.org>
[pepe.schlehofer@gmail.com: rename gpios to wdi-gpios, reword the description]
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---

Notes:
    Changes in v4:
    - rename the property to wdi-gpios (Rob)
    - wrap the description at 80 columns (Rob)
    
    Changes in v3:
    * Extend description

 .../devicetree/bindings/watchdog/maxim,max63xx.yaml         | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
index defe0401ded0..72f16d9f4596 100644
--- a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
+++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
@@ -28,6 +28,12 @@ properties:
     description: This is a 1-byte memory-mapped address
     maxItems: 1
 
+  wdi-gpios:
+    description:
+      GPIO connected to the WDI (watchdog input) pin, on boards where WDI is
+      not driven through the memory-mapped register.
+    maxItems: 1
+
 required:
   - compatible
   - reg
-- 
2.54.0 (Apple Git-157)


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

* [PATCH v4 2/3] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO
  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-11-24  5:01 ` Josef Schlehofer
  2026-11-24  5:01 ` [PATCH v4 3/3] powerpc: dts: turris1x.dts: Use wdi-gpios for the watchdog Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-24  5:01 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Pali Rohár, Marek Behún, Tzung-Bi Shih, Marc Zyngier,
	Linus Walleij, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy (CS GROUP),
	Ritesh Harjani (IBM),
	Shrikanth Hegde, linux-watchdog, devicetree, linuxppc-dev,
	linux-kernel

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)


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

* [PATCH v4 3/3] powerpc: dts: turris1x.dts: Use wdi-gpios for the watchdog
  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-11-24  5:01 ` [PATCH v4 2/3] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Josef Schlehofer
@ 2026-11-24  5:01 ` Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-11-24  5:01 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Pali Rohár, Marek Behún, Tzung-Bi Shih, Marc Zyngier,
	Linus Walleij, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy (CS GROUP),
	Ritesh Harjani (IBM),
	Shrikanth Hegde, linux-watchdog, devicetree, linuxppc-dev,
	linux-kernel

The watchdog node passes its WDI GPIO in a gpios property, which the
maxim,max63xx binding does not define and the max63xx_wdt driver does
not read. dtbs_check reports it for watchdog@2:

  Unevaluated properties are not allowed ('gpios' was unexpected)

Rename it to wdi-gpios, which the binding defines and the driver reads.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---

Notes:
    Changes in v4:
    - new patch

 arch/powerpc/boot/dts/turris1x.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/dts/turris1x.dts b/arch/powerpc/boot/dts/turris1x.dts
index dff1ea074d9d..494a96a1f78c 100644
--- a/arch/powerpc/boot/dts/turris1x.dts
+++ b/arch/powerpc/boot/dts/turris1x.dts
@@ -363,7 +363,7 @@
 				 */
 				compatible = "maxim,max6370";
 				reg = <0x02 0x01>;
-				gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
+				wdi-gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
 			};
 
 			reboot@d {
-- 
2.54.0 (Apple Git-157)


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

end of thread, other threads:[~2026-11-24  5:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-11-24  5:01 ` [PATCH v4 2/3] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Josef Schlehofer
2026-11-24  5:01 ` [PATCH v4 3/3] powerpc: dts: turris1x.dts: Use wdi-gpios for the watchdog Josef Schlehofer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®