Commit 9bf13062 authored by Chris Packham's avatar Chris Packham Committed by Alexandre Belloni

rtc: ds1307: provide an indication that the watchdog has fired

There's not much feedback when the ds1388 watchdog fires. Generally it
yanks on the reset line and the board reboots. Capture the fact that the
watchdog has fired in the past so that userspace can retrieve it via
WDIOC_GETBOOTSTATUS. This should help distinguish a watchdog triggered
reset from a power interruption.
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200727034615.19755-1-chris.packham@alliedtelesis.co.nz
parent 3d6cfb36
...@@ -1668,6 +1668,8 @@ static const struct watchdog_ops ds1388_wdt_ops = { ...@@ -1668,6 +1668,8 @@ static const struct watchdog_ops ds1388_wdt_ops = {
static void ds1307_wdt_register(struct ds1307 *ds1307) static void ds1307_wdt_register(struct ds1307 *ds1307)
{ {
struct watchdog_device *wdt; struct watchdog_device *wdt;
int err;
int val;
if (ds1307->type != ds_1388) if (ds1307->type != ds_1388)
return; return;
...@@ -1676,6 +1678,10 @@ static void ds1307_wdt_register(struct ds1307 *ds1307) ...@@ -1676,6 +1678,10 @@ static void ds1307_wdt_register(struct ds1307 *ds1307)
if (!wdt) if (!wdt)
return; return;
err = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &val);
if (!err && val & DS1388_BIT_WF)
wdt->bootstatus = WDIOF_CARDRESET;
wdt->info = &ds1388_wdt_info; wdt->info = &ds1388_wdt_info;
wdt->ops = &ds1388_wdt_ops; wdt->ops = &ds1388_wdt_ops;
wdt->timeout = 99; wdt->timeout = 99;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment