Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: rn5t618: add support for read out bootstatus

The PMIC does store the power-off factor internally.
Read it out and report it as bootstatus.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Acked-by: Lee Jones <lee@kernel.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20221028075019.2757812-1-marcus.folkesson@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Marcus Folkesson and committed by
Wim Van Sebroeck
47c00805 758f46c2

+21
+12
drivers/watchdog/rn5t618_wdt.c
··· 144 144 struct rn5t618 *rn5t618 = dev_get_drvdata(dev->parent); 145 145 struct rn5t618_wdt *wdt; 146 146 int min_timeout, max_timeout; 147 + int ret; 148 + unsigned int val; 147 149 148 150 wdt = devm_kzalloc(dev, sizeof(struct rn5t618_wdt), GFP_KERNEL); 149 151 if (!wdt) ··· 161 159 wdt->wdt_dev.max_timeout = max_timeout; 162 160 wdt->wdt_dev.timeout = max_timeout; 163 161 wdt->wdt_dev.parent = dev; 162 + 163 + /* Read out previous power-off factor */ 164 + ret = regmap_read(wdt->rn5t618->regmap, RN5T618_POFFHIS, &val); 165 + if (ret) 166 + return ret; 167 + 168 + if (val & RN5T618_POFFHIS_VINDET) 169 + wdt->wdt_dev.bootstatus = WDIOF_POWERUNDER; 170 + else if (val & RN5T618_POFFHIS_WDG) 171 + wdt->wdt_dev.bootstatus = WDIOF_CARDRESET; 164 172 165 173 watchdog_set_drvdata(&wdt->wdt_dev, wdt); 166 174 watchdog_init_timeout(&wdt->wdt_dev, timeout, dev);
+9
include/linux/mfd/rn5t618.h
··· 227 227 #define RN5T618_WATCHDOG_WDOGTIM_S 0 228 228 #define RN5T618_PWRIRQ_IR_WDOG BIT(6) 229 229 230 + #define RN5T618_POFFHIS_PWRON BIT(0) 231 + #define RN5T618_POFFHIS_TSHUT BIT(1) 232 + #define RN5T618_POFFHIS_VINDET BIT(2) 233 + #define RN5T618_POFFHIS_IODET BIT(3) 234 + #define RN5T618_POFFHIS_CPU BIT(4) 235 + #define RN5T618_POFFHIS_WDG BIT(5) 236 + #define RN5T618_POFFHIS_DCLIM BIT(6) 237 + #define RN5T618_POFFHIS_N_OE BIT(7) 238 + 230 239 enum { 231 240 RN5T618_DCDC1, 232 241 RN5T618_DCDC2,