Skip to contentSkip to conversation

DA9052 boot status

PATCH Applied Marcus Folkesson 3 participants 5 messages Dec 10, 2024 – Dec 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover DA9052 boot status

Make it possible to read out the boot status from the da9052-wdt driver.

Function verified with wdctl.

root@mfoc:~# wdctl  /dev/watchdog1
Device:        /dev/watchdog1
Identity:      DA9052 Watchdog [version 0]
Timeout:        4 seconds
Pre-timeout:    0 seconds
FLAG           DESCRIPTION                   STATUS BOOT-STATUS
CARDRESET      Card previously reset the CPU      1           1
KEEPALIVEPING  Keep alive ping reply              1           0
OVERHEAT       Reset due to CPU overheat          0           0
POWERUNDER     Power bad/power fault              0           0
SETTIMEOUT     Set timeout (in seconds)           0           0

---
Changes in v2:
- Simplify assignment of fault_log. Why complicate things...
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Marcus Folkesson (2):
mfd: da9052: store result from fault_log
watchdog: da9052_wdt: add support for bootstatus bits

 drivers/mfd/da9052-core.c         |  1 +
 drivers/watchdog/da9052_wdt.c     | 13 ++++++++++++-
 include/linux/mfd/da9052/da9052.h |  2 ++
 3 files changed, 15 insertions(+), 1 deletion(-)

---
base-commit: cdd30ebb1b9f36159d66f088b61aee264e649d7a
change-id: 20241210-da9052-wdt-a7943a745987

Best regards,

Signature · 1 line
Marcus Folkesson <[email protected]>
#1 lore raw

PATCH v2 1/2 mfd: da9052: store result from fault_log

Other sub-components (da9052-wdt) could use the result to determine reboot cause.
Expose the result by make it part of the da9052 structure.

---
 drivers/mfd/da9052-core.c         | 1 +
 include/linux/mfd/da9052/da9052.h | 2 ++
 2 files changed, 3 insertions(+)
drivers/mfd/da9052-core.c +1 -0
index dc85801b9fa0850fe4dbc351014b7f2981460f02..b06cd518413bffd2e330fb81f8fbbb85c3cf40b9 100644
@@ -585,6 +585,7 @@ static int da9052_clear_fault_log(struct da9052 *da9052)
 				"Cannot reset FAULT_LOG values %d\n", ret);
 	}
 
+	da9052->fault_log = fault_log;
 	return ret;
 }
 
include/linux/mfd/da9052/da9052.h +2 -0
index 76feb3a7066dd4ea2f7768794b8920f67726b211..9cb2fc2938cecf6ddb76da401ae3a098525c380e 100644
@@ -93,6 +93,8 @@ struct da9052 {
 
 	int chip_irq;
 
+	int fault_log;
+
 	/* SOC I/O transfer related fixes for DA9052/53 */
 	int (*fix_io) (struct da9052 *da9052, unsigned char reg);
 };
Signature · 1 line
2.47.0
maintainer Applied
#2 lore raw

Re: (subset) [PATCH v2 1/2] mfd: da9052: store result from fault_log

Quoted 5 lines · Marcus Folkesson

Other sub-components (da9052-wdt) could use the result to determine reboot cause.
Expose the result by make it part of the da9052 structure.

Applied, thanks!

[1/2] mfd: da9052: store result from fault_log

      commit: 2873c48377e5d68aebdbb3b6a6c191fda321ddbf

--
Lee Jones [李琼斯]

#3 lore raw

PATCH v2 2/2 watchdog: da9052_wdt: add support for bootstatus bits

In reply to Marcus Folkesson

Enable support for these bootstatus bits:
WDIOF_CARDRESET
WDIOF_OVERHEAT
WDIOF_POWERUNDER

---
 drivers/watchdog/da9052_wdt.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/watchdog/da9052_wdt.c +12 -1
index d708c091bf1b1e3327a134d4d2244d4b883d14e4..77039f2f0be54273df1666fe40c413b6c89285a1 100644
@@ -135,7 +135,11 @@ static int da9052_wdt_ping(struct watchdog_device *wdt_dev)
 }
 
 static const struct watchdog_info da9052_wdt_info = {
-	.options	= WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
+	.options =	WDIOF_SETTIMEOUT |
+			WDIOF_KEEPALIVEPING |
+			WDIOF_CARDRESET |
+			WDIOF_OVERHEAT |
+			WDIOF_POWERUNDER,
 	.identity	= "DA9052 Watchdog",
 };
 
@@ -169,6 +173,13 @@ static int da9052_wdt_probe(struct platform_device *pdev)
 	da9052_wdt->parent = dev;
 	watchdog_set_drvdata(da9052_wdt, driver_data);
 
+	if (da9052->fault_log & DA9052_FAULTLOG_TWDERROR)
+		da9052_wdt->bootstatus |= WDIOF_CARDRESET;
+	if (da9052->fault_log & DA9052_FAULTLOG_TEMPOVER)
+		da9052_wdt->bootstatus |= WDIOF_OVERHEAT;
+	if (da9052->fault_log & DA9052_FAULTLOG_VDDFAULT)
+		da9052_wdt->bootstatus |= WDIOF_POWERUNDER;
+
 	ret = da9052_reg_update(da9052, DA9052_CONTROL_D_REG,
 				DA9052_CONTROLD_TWDSCALE, 0);
 	if (ret < 0) {
Signature · 1 line
2.47.0