aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/w83697hf_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/w83697hf_wdt.c')
-rw-r--r--drivers/watchdog/w83697hf_wdt.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/watchdog/w83697hf_wdt.c b/drivers/watchdog/w83697hf_wdt.c
index c622a0e6c9ae..528b882420b6 100644
--- a/drivers/watchdog/w83697hf_wdt.c
+++ b/drivers/watchdog/w83697hf_wdt.c
@@ -44,6 +44,7 @@
44#define WATCHDOG_NAME "w83697hf/hg WDT" 44#define WATCHDOG_NAME "w83697hf/hg WDT"
45#define PFX WATCHDOG_NAME ": " 45#define PFX WATCHDOG_NAME ": "
46#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ 46#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
47#define WATCHDOG_EARLY_DISABLE 1 /* Disable until userland kicks in */
47 48
48static unsigned long wdt_is_open; 49static unsigned long wdt_is_open;
49static char expect_close; 50static char expect_close;
@@ -56,12 +57,16 @@ MODULE_PARM_DESC(wdt_io, "w83697hf/hg WDT io port (default 0x2e, 0 = autodetect)
56 57
57static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ 58static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
58module_param(timeout, int, 0); 59module_param(timeout, int, 0);
59MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) "."); 60MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255 (default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
60 61
61static int nowayout = WATCHDOG_NOWAYOUT; 62static int nowayout = WATCHDOG_NOWAYOUT;
62module_param(nowayout, int, 0); 63module_param(nowayout, int, 0);
63MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 64MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
64 65
66static int early_disable = WATCHDOG_EARLY_DISABLE;
67module_param(early_disable, int, 0);
68MODULE_PARM_DESC(early_disable, "Watchdog gets disabled at boot time (default=" __MODULE_STRING(WATCHDOG_EARLY_DISABLE) ")");
69
65/* 70/*
66 * Kernel methods. 71 * Kernel methods.
67 */ 72 */
@@ -140,7 +145,7 @@ w83697hf_init(void)
140 w83697hf_deselect_wdt(); 145 w83697hf_deselect_wdt();
141} 146}
142 147
143static int 148static void
144wdt_ping(void) 149wdt_ping(void)
145{ 150{
146 spin_lock(&io_lock); 151 spin_lock(&io_lock);
@@ -150,10 +155,9 @@ wdt_ping(void)
150 155
151 w83697hf_deselect_wdt(); 156 w83697hf_deselect_wdt();
152 spin_unlock(&io_lock); 157 spin_unlock(&io_lock);
153 return 0;
154} 158}
155 159
156static int 160static void
157wdt_enable(void) 161wdt_enable(void)
158{ 162{
159 spin_lock(&io_lock); 163 spin_lock(&io_lock);
@@ -164,10 +168,9 @@ wdt_enable(void)
164 168
165 w83697hf_deselect_wdt(); 169 w83697hf_deselect_wdt();
166 spin_unlock(&io_lock); 170 spin_unlock(&io_lock);
167 return 0;
168} 171}
169 172
170static int 173static void
171wdt_disable(void) 174wdt_disable(void)
172{ 175{
173 spin_lock(&io_lock); 176 spin_lock(&io_lock);
@@ -178,7 +181,22 @@ wdt_disable(void)
178 181
179 w83697hf_deselect_wdt(); 182 w83697hf_deselect_wdt();
180 spin_unlock(&io_lock); 183 spin_unlock(&io_lock);
181 return 0; 184}
185
186static unsigned char
187wdt_running(void)
188{
189 unsigned char t;
190
191 spin_lock(&io_lock);
192 w83697hf_select_wdt();
193
194 t = w83697hf_get_reg(0xF4); /* Read timer */
195
196 w83697hf_deselect_wdt();
197 spin_unlock(&io_lock);
198
199 return t;
182} 200}
183 201
184static int 202static int
@@ -397,7 +415,11 @@ wdt_init(void)
397 } 415 }
398 416
399 w83697hf_init(); 417 w83697hf_init();
400 wdt_disable(); /* Disable watchdog until first use */ 418 if (early_disable) {
419 if (wdt_running())
420 printk (KERN_WARNING PFX "Stopping previously enabled watchdog until userland kicks in\n");
421 wdt_disable();
422 }
401 423
402 if (wdt_set_heartbeat(timeout)) { 424 if (wdt_set_heartbeat(timeout)) {
403 wdt_set_heartbeat(WATCHDOG_TIMEOUT); 425 wdt_set_heartbeat(WATCHDOG_TIMEOUT);