[PATCH v2 3/4] watchdog: da9062: Add support for dlg,wdt-sd property

From: Primoz Fiser

Date: Thu Sep 24 2026 - 02:52:23 EST


From: Andrej Picej <andrej.picej@xxxxxxxxx>

Implement a method to change watchdog timeout configuration based on the
"dlg,wdt-sd" devicetree property. Setting the WATCHDOG_SD bit enables
SHUTDOWN mode, and clearing it enables POWERDOWN mode on watchdog
timeout.

If no devicetree property is specified, the WATCHDOG_SD bit stays in the
default configuration, not breaking behaviour of devices which might
depend on default fuse configuration.

Signed-off-by: Andrej Picej <andrej.picej@xxxxxxxxx>
Tested-by: Christoph Niedermaier <cniedermaier@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@xxxxxxxxxxx>
Acked-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Signed-off-by: Primoz Fiser <primoz.fiser@xxxxxxxxx>
---
Changes in v2:
- implement Guenter's remarks (code refactor and update commit message)

drivers/watchdog/da9062_wdt.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c
index 3d7bf2f351db..0c007847b7c4 100644
--- a/drivers/watchdog/da9062_wdt.c
+++ b/drivers/watchdog/da9062_wdt.c
@@ -206,6 +206,8 @@ static int da9062_wdt_probe(struct platform_device *pdev)
unsigned int timeout;
struct da9062 *chip;
struct da9062_watchdog *wdt;
+ int ret;
+ u32 val;

chip = dev_get_drvdata(dev->parent);
if (!chip)
@@ -245,6 +247,22 @@ static int da9062_wdt_probe(struct platform_device *pdev)
set_bit(WDOG_HW_RUNNING, &wdt->wdtdev.status);
}

+ /*
+ * Configure what happens on watchdog timeout. Can be specified with
+ * the "dlg,wdt-sd" devicetree property (0 -> POWERDOWN, non-zero ->
+ * SHUTDOWN). If the property is not set, leave the default in place.
+ */
+ ret = device_property_read_u32(dev, "dlg,wdt-sd", &val);
+ if (!ret) {
+ ret = regmap_update_bits(wdt->hw->regmap,
+ DA9062AA_CONFIG_I,
+ DA9062AA_WATCHDOG_SD_MASK,
+ val ? DA9062AA_WATCHDOG_SD_MASK : 0);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to set wdt reset mode\n");
+ }
+
return devm_watchdog_register_device(dev, &wdt->wdtdev);
}

--
2.34.1