aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/imx2_wdt.c
diff options
context:
space:
mode:
authorOskar Schirmer <oskar@scara.com>2012-02-16 07:17:45 -0500
committerWim Van Sebroeck <wim@iguana.be>2012-03-27 13:58:30 -0400
commit474ef121008a2992bcc496930166ced89bda23d2 (patch)
tree5411110e4ff37ca1e2e4196d5433d4065c583e62 /drivers/watchdog/imx2_wdt.c
parent5ba927e8ca3f73acb98f417d126652e26ab40a57 (diff)
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 <oskar@scara.com> Acked-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/imx2_wdt.c')
-rw-r--r--drivers/watchdog/imx2_wdt.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index c44c3334003a..d34a426ad178 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -46,6 +46,9 @@
46#define IMX2_WDT_SEQ1 0x5555 /* -> service sequence 1 */ 46#define IMX2_WDT_SEQ1 0x5555 /* -> service sequence 1 */
47#define IMX2_WDT_SEQ2 0xAAAA /* -> service sequence 2 */ 47#define IMX2_WDT_SEQ2 0xAAAA /* -> service sequence 2 */
48 48
49#define IMX2_WDT_WRSR 0x04 /* Reset Status Register */
50#define IMX2_WDT_WRSR_TOUT (1 << 1) /* -> Reset due to Timeout */
51
49#define IMX2_WDT_MAX_TIME 128 52#define IMX2_WDT_MAX_TIME 128
50#define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */ 53#define IMX2_WDT_DEFAULT_TIME 60 /* in seconds */
51 54
@@ -175,6 +178,7 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
175 void __user *argp = (void __user *)arg; 178 void __user *argp = (void __user *)arg;
176 int __user *p = argp; 179 int __user *p = argp;
177 int new_value; 180 int new_value;
181 u16 val;
178 182
179 switch (cmd) { 183 switch (cmd) {
180 case WDIOC_GETSUPPORT: 184 case WDIOC_GETSUPPORT:
@@ -182,9 +186,13 @@ static long imx2_wdt_ioctl(struct file *file, unsigned int cmd,
182 sizeof(struct watchdog_info)) ? -EFAULT : 0; 186 sizeof(struct watchdog_info)) ? -EFAULT : 0;
183 187
184 case WDIOC_GETSTATUS: 188 case WDIOC_GETSTATUS:
185 case WDIOC_GETBOOTSTATUS:
186 return put_user(0, p); 189 return put_user(0, p);
187 190
191 case WDIOC_GETBOOTSTATUS:
192 val = __raw_readw(imx2_wdt.base + IMX2_WDT_WRSR);
193 new_value = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
194 return put_user(new_value, p);
195
188 case WDIOC_KEEPALIVE: 196 case WDIOC_KEEPALIVE:
189 imx2_wdt_ping(); 197 imx2_wdt_ping();
190 return 0; 198 return 0;