summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/rn5t618_wdt.c
diff options
context:
space:
mode:
authorMarcus Folkesson <marcus.folkesson@gmail.com>2022-10-28 09:50:19 +0200
committerWim Van Sebroeck <wim@linux-watchdog.org>2022-11-19 15:30:40 +0100
commit47c008050aec3e9a13af29dd74cd8b4c112bc07b (patch)
tree6f291822b54a36899105c459e54cf0c5b090843e /drivers/watchdog/rn5t618_wdt.c
parentwatchdog: kempld: Remove #ifdef guards for PM related functions (diff)
downloadlinux-47c008050aec3e9a13af29dd74cd8b4c112bc07b.tar.xz
linux-47c008050aec3e9a13af29dd74cd8b4c112bc07b.zip
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>
Diffstat (limited to 'drivers/watchdog/rn5t618_wdt.c')
-rw-r--r--drivers/watchdog/rn5t618_wdt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/watchdog/rn5t618_wdt.c b/drivers/watchdog/rn5t618_wdt.c
index 6e524c8e26a8..40d8ebd8c0ac 100644
--- a/drivers/watchdog/rn5t618_wdt.c
+++ b/drivers/watchdog/rn5t618_wdt.c
@@ -144,6 +144,8 @@ static int rn5t618_wdt_probe(struct platform_device *pdev)
struct rn5t618 *rn5t618 = dev_get_drvdata(dev->parent);
struct rn5t618_wdt *wdt;
int min_timeout, max_timeout;
+ int ret;
+ unsigned int val;
wdt = devm_kzalloc(dev, sizeof(struct rn5t618_wdt), GFP_KERNEL);
if (!wdt)
@@ -160,6 +162,16 @@ static int rn5t618_wdt_probe(struct platform_device *pdev)
wdt->wdt_dev.timeout = max_timeout;
wdt->wdt_dev.parent = dev;
+ /* Read out previous power-off factor */
+ ret = regmap_read(wdt->rn5t618->regmap, RN5T618_POFFHIS, &val);
+ if (ret)
+ return ret;
+
+ if (val & RN5T618_POFFHIS_VINDET)
+ wdt->wdt_dev.bootstatus = WDIOF_POWERUNDER;
+ else if (val & RN5T618_POFFHIS_WDG)
+ wdt->wdt_dev.bootstatus = WDIOF_CARDRESET;
+
watchdog_set_drvdata(&wdt->wdt_dev, wdt);
watchdog_init_timeout(&wdt->wdt_dev, timeout, dev);
watchdog_set_nowayout(&wdt->wdt_dev, nowayout);