Skip to contentSkip to conversation

da9062/da9061 watchdog timeout mode

PATCH Superseded Primoz Fiser 3 participants 11 messages Sep 23

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover da9062/da9061 watchdog timeout mode

This is a revival of a series originally posted by Andrej Picej in December 2021 [1]. It lets the DA9061/2 PMIC watchdog be configured via the "dlg,wdt-sd" DT property, to trigger a full SHUTDOWN instead of the default POWERDOWN on watchdog timeout, and enables that on the PHYTEC phyCORE-i.MX6 SOM.

From v5 of original series this resend drops patch 4/5 ("dt-bindings:
watchdog: da9062: add watchdog timeout mode") because it already landed upstream as commit 382256b219fb, later converted from .txt to YAML by bd888a4377ae. Thus dlg,da9062-watchdog.yaml already documents dlg,wdt-sd property.

Patches 1 and 2 (the mfd prerequisites making register CONFIG_I writable) needed a rebase: an unrelated commit has since added CONFIG_J, the register immediately adjacent to CONFIG_I, to the same writeable-range tables. Rather than reapplying the original single- register insert next to it, these merge CONFIG_I and CONFIG_J into one range, matching the existing CONFIG_G-CONFIG_K style already used in this file.

Patch 3 (the watchdog driver support) still applies unmodified.

Patch 4 only needed its target path updated for the arch/arm/boot/dts vendor sub-directory move (imx6qdl-phytec-phycore-som.dtsi is now under nxp/imx/).

[1] https://lore.kernel.org/all/[email protected]/

Andrej Picej (3):
mfd: da9061: make register CONFIG_I writable
watchdog: da9062: reset board on watchdog timeout
ARM: dts: imx6: phycore-som: set watchdog timeout mode to shutdown

Stefan Christ (1):
mfd: da9062: make register CONFIG_I writable

 .../nxp/imx/imx6qdl-phytec-phycore-som.dtsi   |  1 +
 drivers/mfd/da9062-core.c                     |  4 +--
 drivers/watchdog/da9062_wdt.c                 | 27 +++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 mfd: da9062: make register CONFIG_I writable

From: Stefan Christ <[email protected]>

Make the config register CONFIG_I writable to change the watchdog mode.

---
 drivers/mfd/da9062-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/da9062-core.c +1 -1
index ad198183aff7..32dd24483ee0 100644
@@ -531,7 +531,7 @@ static const struct regmap_range da9062_aa_writeable_ranges[] = {
 	regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B),
 	regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
 	regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT),
-	regmap_reg_range(DA9062AA_CONFIG_J, DA9062AA_CONFIG_J),
+	regmap_reg_range(DA9062AA_CONFIG_I, DA9062AA_CONFIG_J),
 	regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19),
 };
 
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/4] mfd: da9062: make register CONFIG_I writable

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] mfd: commit message capitalization violation --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mfd: commit message capitalization violation
--

commit e25cc5ced7f3db4cd954295f961924b993742524
Author: Stefan Christ <[email protected]>

mfd: da9062: make register CONFIG_I writable

This commit makes the configuration register CONFIG_I writable to allow changing the watchdog mode.

Quoted 1 line

mfd: da9062: make register CONFIG_I writable

[Severity: Low]
This isn't a bug, but the MFD subsystem guidelines require the description to always be capitalized after the subsystem prefix. Should "make" be capitalized to "Make" to align with this convention?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH 2/4 mfd: da9061: make register CONFIG_I writable

In reply to Primoz Fiser

From: Andrej Picej <[email protected]>

Make the config register CONFIG_I writable to change the watchdog mode.

---
 drivers/mfd/da9062-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/da9062-core.c +1 -1
index 32dd24483ee0..c987e533824d 100644
@@ -427,7 +427,7 @@ static const struct regmap_range da9061_aa_writeable_ranges[] = {
 	regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B),
 	regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B),
 	regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
-	regmap_reg_range(DA9062AA_CONFIG_J, DA9062AA_CONFIG_J),
+	regmap_reg_range(DA9062AA_CONFIG_I, DA9062AA_CONFIG_J),
 	regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19),
 };
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 2/4] mfd: da9061: make register CONFIG_I writable

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] mfd: commit message description is not capitalized --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mfd: commit message description is not capitalized
--

commit 5997b5e9bac966d2caba888fc1dfee5d188e81e0
Author: Andrej Picej <[email protected]>

mfd: da9061: make register CONFIG_I writable

This commit makes the configuration register CONFIG_I writable to allow changing the watchdog mode.

Quoted 1 line

mfd: da9061: make register CONFIG_I writable

[Severity: Low]
This isn't a bug, but the MFD subsystem guidelines explicitly require the description after the subsystem prefix to be capitalized. Should the commit message title be updated to "mfd: da9061: Make register CONFIG_I writable" to ensure it follows the standard Git history categorization for this subsystem?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

PATCH 3/4 watchdog: da9062: reset board on watchdog timeout

In reply to Primoz Fiser

From: Andrej Picej <[email protected]>

Implement a method to change watchdog timeout configuration based on DT binding ("dlg,wdt-sd"). There is a possibility to change the behaviour of watchdog reset. Setting WATCHDOG_SD bit enables SHUTDOWN mode, and clearing it enables POWERDOWN mode on watchdog timeout.

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

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

---
 drivers/watchdog/da9062_wdt.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/watchdog/da9062_wdt.c +27 -0
index 3d7bf2f351db..7ceef8cd7425 100644
@@ -204,8 +204,11 @@ static int da9062_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	unsigned int timeout;
+	unsigned int mask;
 	struct da9062 *chip;
 	struct da9062_watchdog *wdt;
+	int ret;
+	u32 val;
 
 	chip = dev_get_drvdata(dev->parent);
 	if (!chip)
@@ -245,6 +248,30 @@ 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
+	 * "dlg,wdt-sd" dt-binding (0 -> POWERDOWN, 1 -> SHUTDOWN).
+	 * If "dlg,wdt-sd" dt-binding is NOT set use the default.
+	 */
+	ret = device_property_read_u32(dev, "dlg,wdt-sd", &val);
+	if (!ret) {
+		if (val)
+			/* Use da9062's SHUTDOWN mode */
+			mask = DA9062AA_WATCHDOG_SD_MASK;
+		else
+			/* Use da9062's POWERDOWN mode. */
+			mask = 0x0;
+
+		ret = regmap_update_bits(wdt->hw->regmap,
+						DA9062AA_CONFIG_I,
+						DA9062AA_WATCHDOG_SD_MASK,
+						mask);
+
+		if (ret)
+			dev_err(dev, "failed to set wdt reset mode: %d\n",
+				ret);
+	}
+
 	return devm_watchdog_register_device(dev, &wdt->wdtdev);
 }
 
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH 3/4] watchdog: da9062: reset board on watchdog timeout

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] watchdog: da9062: ignored regmap_update_bits error during probe --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] watchdog: da9062: ignored regmap_update_bits error during probe --

commit bb521fc9765eec74ebb6a0d926ce1286dabd2490
Author: Andrej Picej <[email protected]>
watchdog: da9062: reset board on watchdog timeout

This commit introduces a method to change the watchdog timeout configuration based on the "dlg,wdt-sd" DT binding in the da9062 watchdog driver. It allows switching between SHUTDOWN mode and POWERDOWN mode on watchdog timeout. If the DT binding is absent, it retains the default behavior.

Quoted 4 lines
drivers/watchdog/da9062_wdt.c +0 -0
index 426962547df16..2a9da83493b38 100644

[ ... ]

Quoted 1 line
drivers/watchdog/da9062_wdt.c +0 -0
@@ -245,6 +248,30 @@ static int da9062_wdt_probe(struct platform_device *pdev)

[ ... ]

drivers/watchdog/da9062_wdt.c static int da9062_wdt_probe(struct platform_device *pdev) · line 275

Quoted 11 lines
drivers/watchdog/da9062_wdt.c +10 -0
+		ret = regmap_update_bits(wdt->hw->regmap,
+						DA9062AA_CONFIG_I,
+						DA9062AA_WATCHDOG_SD_MASK,
+						mask);
+
+		if (ret)
+			dev_err(dev, "failed to set wdt reset mode: %d\n",
+				ret);
+	}
+
 	return devm_watchdog_register_device(dev, &wdt->wdtdev);

[Severity: Medium]
Is the regmap_update_bits() error code intentionally ignored here?

When the device tree contains the "dlg,wdt-sd" property, da9062_wdt_probe() attempts to update the DA9062AA_CONFIG_I register. If this transaction fails (for example, returning -EIO due to a hardware fault), the failure is logged via dev_err(), but the error code in 'ret' is then discarded because execution falls through to devm_watchdog_register_device().

This could leave the watchdog in an incorrect reset mode that conflicts with the explicit configuration requested by the device tree. Should the function return 'ret' early upon failure, instead of continuing probe?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
maintainer
#7 lore raw

Re: [PATCH 3/4] watchdog: da9062: reset board on watchdog timeout

In reply to Primoz Fiser
Quoted 7 lines · Primoz Fiser

From: Andrej Picej <[email protected]>

Implement a method to change watchdog timeout configuration based on DT binding ("dlg,wdt-sd"). There is a possibility to change the behaviour of watchdog reset. Setting WATCHDOG_SD bit enables SHUTDOWN mode, and clearing it enables POWERDOWN mode on watchdog timeout.

Quoted 7 lines

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

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

Please reword to something like:

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 default configuration, not breaking behaviour of devices which might depend on default fuse configuration.

Specifically, "There is a possibility ..." should not be part of the description at all, and "Note:" should not be part of the description and be moved below "---".

Quoted 27 lines
---
 drivers/watchdog/da9062_wdt.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/watchdog/da9062_wdt.c +3 -0
index 3d7bf2f351db..7ceef8cd7425 100644
@@ -204,8 +204,11 @@ static int da9062_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	unsigned int timeout;
+	unsigned int mask;
 	struct da9062 *chip;
 	struct da9062_watchdog *wdt;
+	int ret;
+	u32 val;
 
 	chip = dev_get_drvdata(dev->parent);
 	if (!chip)

drivers/watchdog/da9062_wdt.c static int da9062_wdt_probe(struct platform_device *pdev) · line 254

Quoted 7 lines
drivers/watchdog/da9062_wdt.c +4 -0
@@ -245,6 +248,30 @@ 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
+	 * "dlg,wdt-sd" dt-binding (0 -> POWERDOWN, 1 -> SHUTDOWN).
+	 * If "dlg,wdt-sd" dt-binding is NOT set use the default.

This is not really what he code below does.
It sets the mode to shutdown if val is != 0, not if it is 1.

Quoted 4 lines
drivers/watchdog/da9062_wdt.c +4 -0
+	 */
+	ret = device_property_read_u32(dev, "dlg,wdt-sd", &val);
+	if (!ret) {
+		if (val)

drivers/watchdog/da9062_wdt.c static int da9062_wdt_probe(struct platform_device *pdev) · line 268

Quoted 10 lines
drivers/watchdog/da9062_wdt.c +10 -0
+			/* Use da9062's SHUTDOWN mode */
+			mask = DA9062AA_WATCHDOG_SD_MASK;
+		else
+			/* Use da9062's POWERDOWN mode. */
+			mask = 0x0;
+
+		ret = regmap_update_bits(wdt->hw->regmap,
+						DA9062AA_CONFIG_I,
+						DA9062AA_WATCHDOG_SD_MASK,
+						mask);

CHECK: Alignment should match open parenthesis
#157: FILE: drivers/watchdog/da9062_wdt.c:266:
+ ret = regmap_update_bits(wdt->hw->regmap,
+ DA9062AA_CONFIG_I,

Also, this does not require an additional variable.

		ret = regmap_update_bits(wdt->hw->regmap,
					 DA9062AA_CONFIG_I,
					 DA9062AA_WATCHDOG_SD_MASK,
					 val ? DA9062AA_WATCHDOG_SD_MASK : 0);

drivers/watchdog/da9062_wdt.c static int da9062_wdt_probe(struct platform_device *pdev) · line 272

Quoted 4 lines
drivers/watchdog/da9062_wdt.c +4 -0
+
+		if (ret)
+			dev_err(dev, "failed to set wdt reset mode: %d\n",
+				ret);
			return dev_err_probe(dev, ret,
					     "failed to set wdt reset mode\n");

Thanks,
Guenter

maintainer
#8 lore raw

Re: [PATCH 3/4] watchdog: da9062: reset board on watchdog timeout

Quoted 22 lines · Guenter Roeck
Quoted 7 lines · Primoz Fiser

From: Andrej Picej <[email protected]>

Implement a method to change watchdog timeout configuration based on DT binding ("dlg,wdt-sd"). There is a possibility to change the behaviour of watchdog reset. Setting WATCHDOG_SD bit enables SHUTDOWN mode, and clearing it enables POWERDOWN mode on watchdog timeout.

Quoted 7 lines

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

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

Please reword to something like:

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.

Quoted 8 lines

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

Specifically, "There is a possibility ..." should not be part of the description at all, and "Note:" should not be part of the description and be moved below "---".

Also, the subject is wrong. The patch does not "reset board on watchdog timeout", it implements support for "dlg,wdt-sd".

Guenter

#9 lore raw

PATCH 4/4 ARM: dts: imx6: phycore-som: set watchdog timeout mode to shutdown

In reply to Primoz Fiser

From: Andrej Picej <[email protected]>

Enable system restart when the watchdog timeout occurs.

---
 arch/arm/boot/dts/nxp/imx/imx6qdl-phytec-phycore-som.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/nxp/imx/imx6qdl-phytec-phycore-som.dtsi +1 -0
index 85e278eb2016..ddbfecd591f5 100644
@@ -115,6 +115,7 @@ da9062_onkey: onkey {
 		watchdog {
 			compatible = "dlg,da9062-watchdog";
 			dlg,use-sw-pm;
+			dlg,wdt-sd = <1>;
 		};
 
 		thermal {
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH 4/4] ARM: dts: imx6: phycore-som: set watchdog timeout mode to shutdown

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

From: Andrej Picej <[email protected]>

Enable system restart when the watchdog timeout occurs.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4