From 474ef121008a2992bcc496930166ced89bda23d2 Mon Sep 17 00:00:00 2001 From: Oskar Schirmer Date: Thu, 16 Feb 2012 12:17:45 +0000 Subject: watchdog: make imx2_wdt report boot status correctly 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 Acked-by: Wolfram Sang Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/imx2_wdt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index c44c3334003..d34a426ad17 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,13 @@ 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 = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0; + return put_user(new_value, p); + case WDIOC_KEEPALIVE: imx2_wdt_ping(); return 0; -- cgit v1.2.3-18-g5258