Skip to content

Commit

Permalink
rtc: ds1307: provide an indication that the watchdog has fired
Browse files Browse the repository at this point in the history
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: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200727034615.19755-1-chris.packham@alliedtelesis.co.nz
  • Loading branch information
Chris Packham authored and Alexandre Belloni committed Aug 4, 2020
1 parent 3d6cfb3 commit 9bf1306
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/rtc/rtc-ds1307.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,8 @@ static const struct watchdog_ops ds1388_wdt_ops = {
static void ds1307_wdt_register(struct ds1307 *ds1307)
{
struct watchdog_device *wdt;
int err;
int val;

if (ds1307->type != ds_1388)
return;
Expand All @@ -1676,6 +1678,10 @@ static void ds1307_wdt_register(struct ds1307 *ds1307)
if (!wdt)
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->ops = &ds1388_wdt_ops;
wdt->timeout = 99;
Expand Down

0 comments on commit 9bf1306

Please sign in to comment.