DA9052 boot status
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
Signed-off-by Marcus Folkesson <[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 | 26 +++++++++++++------------- drivers/watchdog/da9052_wdt.c | 13 ++++++++++++- include/linux/mfd/da9052/da9052.h | 2 ++ 3 files changed, 27 insertions(+), 14 deletions(-)
---
base-commit: cdd30ebb1b9f36159d66f088b61aee264e649d7a
change-id: 20241210-da9052-wdt-a7943a745987
Best regards,
Signature · 1 line
Marcus Folkesson <[email protected]>
PATCH 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.
Signed-off-by Marcus Folkesson <[email protected]>
--- drivers/mfd/da9052-core.c | 26 +++++++++++++------------- include/linux/mfd/da9052/da9052.h | 2 ++ 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/mfd/da9052-core.c +13 -13
@@ -545,35 +545,35 @@ EXPORT_SYMBOL_GPL(da9052_regmap_config);static int da9052_clear_fault_log (struct da9052 *da9052) {int ret =0 ; -int fault_log =0 ; +int *fault_log = &da9052->fault_log; - fault_log =da9052_reg_read (da9052,DA9052_FAULTLOG_REG ); -if (fault_log <0 ) { + *fault_log =da9052_reg_read (da9052,DA9052_FAULTLOG_REG ); +if (*fault_log <0 ) {dev_err (da9052->dev, -"Cannot read FAULT_LOG %d\n" , fault_log); -return fault_log; +"Cannot read FAULT_LOG %d\n" , *fault_log); +return *fault_log; } -if (fault_log) { -if (fault_log &DA9052_FAULTLOG_TWDERROR ) +if (*fault_log) { +if (*fault_log &DA9052_FAULTLOG_TWDERROR )dev_dbg (da9052->dev,"Fault log entry detected: TWD_ERROR\n" ); -if (fault_log &DA9052_FAULTLOG_VDDFAULT ) +if (*fault_log &DA9052_FAULTLOG_VDDFAULT )dev_dbg (da9052->dev,"Fault log entry detected: VDD_FAULT\n" ); -if (fault_log &DA9052_FAULTLOG_VDDSTART ) +if (*fault_log &DA9052_FAULTLOG_VDDSTART )dev_dbg (da9052->dev,"Fault log entry detected: VDD_START\n" ); -if (fault_log &DA9052_FAULTLOG_TEMPOVER ) +if (*fault_log &DA9052_FAULTLOG_TEMPOVER )dev_dbg (da9052->dev,"Fault log entry detected: TEMP_OVER\n" ); -if (fault_log &DA9052_FAULTLOG_KEYSHUT ) +if (*fault_log &DA9052_FAULTLOG_KEYSHUT )dev_dbg (da9052->dev,"Fault log entry detected: KEY_SHUT\n" ); -if (fault_log &DA9052_FAULTLOG_NSDSET ) +if (*fault_log &DA9052_FAULTLOG_NSDSET )dev_dbg (da9052->dev,"Fault log entry detected: nSD_SHUT\n" ); -if (fault_log &DA9052_FAULTLOG_WAITSET ) +if (*fault_log &DA9052_FAULTLOG_WAITSET )dev_dbg (da9052->dev,"Fault log entry detected: WAIT_SHUT\n" );
include/linux/mfd/da9052/da9052.h +2 -0
@@ -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
PATCH 2/2 watchdog: da9052_wdt: add support for bootstatus bits
In reply to Marcus FolkessonEnable support for these bootstatus bits:
WDIOF_CARDRESET
WDIOF_OVERHEAT
WDIOF_POWERUNDER
Signed-off-by Marcus Folkesson <[email protected]>
--- drivers/watchdog/da9052_wdt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/watchdog/da9052_wdt.c +12 -1
@@ -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