Linux-RTC Archive on
 help / color / Atom feed
From: Chris Packham <>
	Chris Packham <>
Subject: [PATCH v3] rtc: ds1307: provide an indication that the watchdog has fired
Date: Mon, 27 Jul 2020 15:46:14 +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 v3:
- Check for watchdog flag in ds1307_wdt_register()
Changes in v2:
- Set bootstatus to WDIOF_CARDRESET and let userspace decide what to do with
  the information.

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

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 49702942bb08..54c85cdd019d 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -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)
@@ -1676,6 +1678,10 @@ static void ds1307_wdt_register(struct ds1307 *ds1307)
 	if (!wdt)
+	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;

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27  3:46 Chris Packham [this message]
2020-07-27 13:32 ` Guenter Roeck
2020-08-04 23:07 ` Alexandre Belloni

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