Skip to content

Commit 9bf1306

Browse files
cpackham-atlnzalexandrebelloni
authored andcommitted
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: 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
1 parent 3d6cfb3 commit 9bf1306

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/rtc/rtc-ds1307.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,8 @@ static const struct watchdog_ops ds1388_wdt_ops = {
16681668
static void ds1307_wdt_register(struct ds1307 *ds1307)
16691669
{
16701670
struct watchdog_device *wdt;
1671+
int err;
1672+
int val;
16711673

16721674
if (ds1307->type != ds_1388)
16731675
return;
@@ -1676,6 +1678,10 @@ static void ds1307_wdt_register(struct ds1307 *ds1307)
16761678
if (!wdt)
16771679
return;
16781680

1681+
err = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &val);
1682+
if (!err && val & DS1388_BIT_WF)
1683+
wdt->bootstatus = WDIOF_CARDRESET;
1684+
16791685
wdt->info = &ds1388_wdt_info;
16801686
wdt->ops = &ds1388_wdt_ops;
16811687
wdt->timeout = 99;

0 commit comments

Comments
 (0)