Linux-RTC Archive on
 help / color / Atom feed
From: Chris Packham <>
	Chris Packham <>
Subject: [PATCH v2] rtc: ds1307: provide an indication that the watchdog has fired
Date: Mon, 27 Jul 2020 11:13:06 +1200
Message-ID: <> (raw)

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 <>
Changes in v2:
- Set bootstatus to WDIOF_CARDRESET and let userspace decide what to do with
  the information.

 drivers/rtc/rtc-ds1307.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 49702942bb08..209736db510d 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -868,6 +868,14 @@ static int ds1388_wdt_start(struct watchdog_device *wdt_dev)
 	struct ds1307 *ds1307 = watchdog_get_drvdata(wdt_dev);
 	u8 regs[2];
 	int ret;
+	int val;
+	ret = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &val);
+	if (ret)
+		return ret;
+	if (val & DS1388_BIT_WF)
+		wdt_dev->bootstatus = WDIOF_CARDRESET;
 	ret = regmap_update_bits(ds1307->regmap, DS1388_REG_FLAG,
 				 DS1388_BIT_WF, 0);

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26 23:13 Chris Packham [this message]
2020-07-27  3:15 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-RTC Archive on

Archives are clonable:
	git clone --mirror linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ \
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone