From: "Oskar Schirmer" <oskar@scara.com>
To: wim@iguana.be
Cc: s.hauer@pengutronix.de, w.sang@pengutronix.de,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
"Oskar Schirmer" <oskar@scara.com>
Subject: [PATCH] watchdog: make imx2_wdt report boot status correctly
Date: 16 Feb 2012 12:17:45 +0000 [thread overview]
Message-ID: <1329394665-7238-1-git-send-email-oskar@scara.com> (raw)
Ioctl WDIOC_GETBOOTSTATUS is supposed to return some information
on why the system did (re)boot recently, value WDIOF_CARDRESET
being used to indicate watchdog induced reboot.
Up to now, imx2_wdt did not provide a value here, always returning
zero to indicate normal boot.
Do evaluate the IMX Watchdog Reset Status Register and
produce WDIOF_CARDRESET with WDIOC_GETBOOTSTATUS in case
of a watchdog induced reset.
Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
drivers/watchdog/imx2_wdt.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index c44c333..940fd43 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -46,6 +46,9 @@
#define IMX2_WDT_SEQ1 0x5555 /* -> service sequence 1 */
#define IMX2_WDT_SEQ2 0xAAAA /* -> service sequence 2 */
+#define IMX2_WDT_WRSR 0x04 /* Reset Status Register */
+#define IMX2_WDT_WRSR_TOUT (1 << 1) /* -> Reset due to Timeout */
+
#define IMX2_WDT_MAX_TIME 128
#define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */
@@ -175,6 +178,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)arg;
int __user *p = argp;
int new_value;
+ u16 val;
switch (cmd) {
case WDIOC_GETSUPPORT:
@@ -182,9 +186,15 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
sizeof(struct watchdog_info)) ? -EFAULT : 0;
case WDIOC_GETSTATUS:
- case WDIOC_GETBOOTSTATUS:
return put_user(0, p);
+ case WDIOC_GETBOOTSTATUS:
+ val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
+ new_value = 0;
+ if (val & IMX2_WDT_WRSR_TOUT)
+ new_value = WDIOF_CARDRESET;
+ return put_user(new_value, p);
+
case WDIOC_KEEPALIVE:
imx2_wdt_ping();
return 0;
--
1.7.5.4
next reply other threads:[~2012-02-16 12:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 12:17 Oskar Schirmer [this message]
2012-02-16 13:35 ` [PATCH] watchdog: make imx2_wdt report boot status correctly Wolfram Sang
2012-02-16 14:17 ` Oskar Schirmer
2012-02-16 14:23 ` Wolfram Sang
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329394665-7238-1-git-send-email-oskar@scara.com \
--to=oskar@scara.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=w.sang@pengutronix.de \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox