diff options
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/Kconfig | 2 | ||||
-rw-r--r-- | drivers/watchdog/Makefile | 2 | ||||
-rw-r--r-- | drivers/watchdog/at91rm9200_wdt.c | 6 | ||||
-rw-r--r-- | drivers/watchdog/i6300esb.c | 155 | ||||
-rw-r--r-- | drivers/watchdog/ks8695_wdt.c | 6 | ||||
-rw-r--r-- | drivers/watchdog/omap_wdt.c | 6 | ||||
-rw-r--r-- | drivers/watchdog/orion5x_wdt.c | 57 | ||||
-rw-r--r-- | drivers/watchdog/wdrtas.c | 13 |
8 files changed, 139 insertions, 108 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 63024145215d..5eb8f21da82e 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -240,8 +240,6 @@ config ORION5X_WATCHDOG | |||
240 | To compile this driver as a module, choose M here: the | 240 | To compile this driver as a module, choose M here: the |
241 | module will be called orion5x_wdt. | 241 | module will be called orion5x_wdt. |
242 | 242 | ||
243 | # ARM26 Architecture | ||
244 | |||
245 | # AVR32 Architecture | 243 | # AVR32 Architecture |
246 | 244 | ||
247 | config AT32AP700X_WDT | 245 | config AT32AP700X_WDT |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 806b3eb08536..7f8c56b14f58 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -42,8 +42,6 @@ obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o | |||
42 | obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o | 42 | obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o |
43 | obj-$(CONFIG_ORION5X_WATCHDOG) += orion5x_wdt.o | 43 | obj-$(CONFIG_ORION5X_WATCHDOG) += orion5x_wdt.o |
44 | 44 | ||
45 | # ARM26 Architecture | ||
46 | |||
47 | # AVR32 Architecture | 45 | # AVR32 Architecture |
48 | obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o | 46 | obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o |
49 | 47 | ||
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index e35d54589232..29e52c237a3b 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
@@ -197,7 +197,7 @@ static struct miscdevice at91wdt_miscdev = { | |||
197 | .fops = &at91wdt_fops, | 197 | .fops = &at91wdt_fops, |
198 | }; | 198 | }; |
199 | 199 | ||
200 | static int __init at91wdt_probe(struct platform_device *pdev) | 200 | static int __devinit at91wdt_probe(struct platform_device *pdev) |
201 | { | 201 | { |
202 | int res; | 202 | int res; |
203 | 203 | ||
@@ -214,7 +214,7 @@ static int __init at91wdt_probe(struct platform_device *pdev) | |||
214 | return 0; | 214 | return 0; |
215 | } | 215 | } |
216 | 216 | ||
217 | static int __exit at91wdt_remove(struct platform_device *pdev) | 217 | static int __devexit at91wdt_remove(struct platform_device *pdev) |
218 | { | 218 | { |
219 | int res; | 219 | int res; |
220 | 220 | ||
@@ -252,7 +252,7 @@ static int at91wdt_resume(struct platform_device *pdev) | |||
252 | 252 | ||
253 | static struct platform_driver at91wdt_driver = { | 253 | static struct platform_driver at91wdt_driver = { |
254 | .probe = at91wdt_probe, | 254 | .probe = at91wdt_probe, |
255 | .remove = __exit_p(at91wdt_remove), | 255 | .remove = __devexit_p(at91wdt_remove), |
256 | .shutdown = at91wdt_shutdown, | 256 | .shutdown = at91wdt_shutdown, |
257 | .suspend = at91wdt_suspend, | 257 | .suspend = at91wdt_suspend, |
258 | .resume = at91wdt_resume, | 258 | .resume = at91wdt_resume, |
diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c index 2dbe83570d65..7ba0b11ec525 100644 --- a/drivers/watchdog/i6300esb.c +++ b/drivers/watchdog/i6300esb.c | |||
@@ -52,10 +52,10 @@ | |||
52 | #define ESB_LOCK_REG 0x68 /* WDT lock register */ | 52 | #define ESB_LOCK_REG 0x68 /* WDT lock register */ |
53 | 53 | ||
54 | /* Memory mapped registers */ | 54 | /* Memory mapped registers */ |
55 | #define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */ | 55 | #define ESB_TIMER1_REG (BASEADDR + 0x00)/* Timer1 value after each reset */ |
56 | #define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */ | 56 | #define ESB_TIMER2_REG (BASEADDR + 0x04)/* Timer2 value after each reset */ |
57 | #define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */ | 57 | #define ESB_GINTSR_REG (BASEADDR + 0x08)/* General Interrupt Status Register */ |
58 | #define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */ | 58 | #define ESB_RELOAD_REG (BASEADDR + 0x0c)/* Reload register */ |
59 | 59 | ||
60 | /* Lock register bits */ | 60 | /* Lock register bits */ |
61 | #define ESB_WDT_FUNC (0x01 << 2) /* Watchdog functionality */ | 61 | #define ESB_WDT_FUNC (0x01 << 2) /* Watchdog functionality */ |
@@ -68,6 +68,7 @@ | |||
68 | #define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */ | 68 | #define ESB_WDT_INTTYPE (0x11 << 0) /* Interrupt type on timer1 timeout */ |
69 | 69 | ||
70 | /* Reload register bits */ | 70 | /* Reload register bits */ |
71 | #define ESB_WDT_TIMEOUT (0x01 << 9) /* Watchdog timed out */ | ||
71 | #define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */ | 72 | #define ESB_WDT_RELOAD (0x01 << 8) /* prevent timeout */ |
72 | 73 | ||
73 | /* Magic constants */ | 74 | /* Magic constants */ |
@@ -87,7 +88,6 @@ static struct platform_device *esb_platform_device; | |||
87 | /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ | 88 | /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */ |
88 | #define WATCHDOG_HEARTBEAT 30 | 89 | #define WATCHDOG_HEARTBEAT 30 |
89 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ | 90 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ |
90 | |||
91 | module_param(heartbeat, int, 0); | 91 | module_param(heartbeat, int, 0); |
92 | MODULE_PARM_DESC(heartbeat, | 92 | MODULE_PARM_DESC(heartbeat, |
93 | "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" | 93 | "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" |
@@ -123,7 +123,7 @@ static int esb_timer_start(void) | |||
123 | esb_unlock_registers(); | 123 | esb_unlock_registers(); |
124 | writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); | 124 | writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); |
125 | /* Enable or Enable + Lock? */ | 125 | /* Enable or Enable + Lock? */ |
126 | val = 0x02 | (nowayout ? 0x01 : 0x00); | 126 | val = ESB_WDT_ENABLE | (nowayout ? ESB_WDT_LOCK : 0x00); |
127 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); | 127 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); |
128 | spin_unlock(&esb_lock); | 128 | spin_unlock(&esb_lock); |
129 | return 0; | 129 | return 0; |
@@ -143,7 +143,7 @@ static int esb_timer_stop(void) | |||
143 | spin_unlock(&esb_lock); | 143 | spin_unlock(&esb_lock); |
144 | 144 | ||
145 | /* Returns 0 if the timer was disabled, non-zero otherwise */ | 145 | /* Returns 0 if the timer was disabled, non-zero otherwise */ |
146 | return (val & 0x01); | 146 | return val & ESB_WDT_ENABLE; |
147 | } | 147 | } |
148 | 148 | ||
149 | static void esb_timer_keepalive(void) | 149 | static void esb_timer_keepalive(void) |
@@ -190,18 +190,6 @@ static int esb_timer_set_heartbeat(int time) | |||
190 | return 0; | 190 | return 0; |
191 | } | 191 | } |
192 | 192 | ||
193 | static int esb_timer_read(void) | ||
194 | { | ||
195 | u32 count; | ||
196 | |||
197 | /* This isn't documented, and doesn't take into | ||
198 | * acount which stage is running, but it looks | ||
199 | * like a 20 bit count down, so we might as well report it. | ||
200 | */ | ||
201 | pci_read_config_dword(esb_pci, 0x64, &count); | ||
202 | return (int)count; | ||
203 | } | ||
204 | |||
205 | /* | 193 | /* |
206 | * /dev/watchdog handling | 194 | * /dev/watchdog handling |
207 | */ | 195 | */ |
@@ -282,7 +270,7 @@ static long esb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
282 | sizeof(ident)) ? -EFAULT : 0; | 270 | sizeof(ident)) ? -EFAULT : 0; |
283 | 271 | ||
284 | case WDIOC_GETSTATUS: | 272 | case WDIOC_GETSTATUS: |
285 | return put_user(esb_timer_read(), p); | 273 | return put_user(0, p); |
286 | 274 | ||
287 | case WDIOC_GETBOOTSTATUS: | 275 | case WDIOC_GETBOOTSTATUS: |
288 | return put_user(triggered, p); | 276 | return put_user(triggered, p); |
@@ -362,8 +350,6 @@ MODULE_DEVICE_TABLE(pci, esb_pci_tbl); | |||
362 | 350 | ||
363 | static unsigned char __devinit esb_getdevice(void) | 351 | static unsigned char __devinit esb_getdevice(void) |
364 | { | 352 | { |
365 | u8 val1; | ||
366 | unsigned short val2; | ||
367 | /* | 353 | /* |
368 | * Find the PCI device | 354 | * Find the PCI device |
369 | */ | 355 | */ |
@@ -371,66 +357,79 @@ static unsigned char __devinit esb_getdevice(void) | |||
371 | esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL, | 357 | esb_pci = pci_get_device(PCI_VENDOR_ID_INTEL, |
372 | PCI_DEVICE_ID_INTEL_ESB_9, NULL); | 358 | PCI_DEVICE_ID_INTEL_ESB_9, NULL); |
373 | 359 | ||
374 | if (esb_pci) { | 360 | if (!esb_pci) |
375 | if (pci_enable_device(esb_pci)) { | 361 | return 0; |
376 | printk(KERN_ERR PFX "failed to enable device\n"); | ||
377 | goto err_devput; | ||
378 | } | ||
379 | 362 | ||
380 | if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) { | 363 | if (pci_enable_device(esb_pci)) { |
381 | printk(KERN_ERR PFX "failed to request region\n"); | 364 | printk(KERN_ERR PFX "failed to enable device\n"); |
382 | goto err_disable; | 365 | goto err_devput; |
383 | } | 366 | } |
384 | 367 | ||
385 | BASEADDR = pci_ioremap_bar(esb_pci, 0); | 368 | if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) { |
386 | if (BASEADDR == NULL) { | 369 | printk(KERN_ERR PFX "failed to request region\n"); |
387 | /* Something's wrong here, BASEADDR has to be set */ | 370 | goto err_disable; |
388 | printk(KERN_ERR PFX "failed to get BASEADDR\n"); | 371 | } |
389 | goto err_release; | ||
390 | } | ||
391 | 372 | ||
392 | /* | 373 | BASEADDR = pci_ioremap_bar(esb_pci, 0); |
393 | * The watchdog has two timers, it can be setup so that the | 374 | if (BASEADDR == NULL) { |
394 | * expiry of timer1 results in an interrupt and the expiry of | 375 | /* Something's wrong here, BASEADDR has to be set */ |
395 | * timer2 results in a reboot. We set it to not generate | 376 | printk(KERN_ERR PFX "failed to get BASEADDR\n"); |
396 | * any interrupts as there is not much we can do with it | 377 | goto err_release; |
397 | * right now. | 378 | } |
398 | * | 379 | |
399 | * We also enable reboots and set the timer frequency to | 380 | /* Done */ |
400 | * the PCI clock divided by 2^15 (approx 1KHz). | 381 | return 1; |
401 | */ | ||
402 | pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003); | ||
403 | |||
404 | /* Check that the WDT isn't already locked */ | ||
405 | pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1); | ||
406 | if (val1 & ESB_WDT_LOCK) | ||
407 | printk(KERN_WARNING PFX "nowayout already set\n"); | ||
408 | |||
409 | /* Set the timer to watchdog mode and disable it for now */ | ||
410 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00); | ||
411 | |||
412 | /* Check if the watchdog was previously triggered */ | ||
413 | esb_unlock_registers(); | ||
414 | val2 = readw(ESB_RELOAD_REG); | ||
415 | triggered = (val2 & (0x01 << 9) >> 9); | ||
416 | |||
417 | /* Reset trigger flag and timers */ | ||
418 | esb_unlock_registers(); | ||
419 | writew((0x11 << 8), ESB_RELOAD_REG); | ||
420 | |||
421 | /* Done */ | ||
422 | return 1; | ||
423 | 382 | ||
424 | err_release: | 383 | err_release: |
425 | pci_release_region(esb_pci, 0); | 384 | pci_release_region(esb_pci, 0); |
426 | err_disable: | 385 | err_disable: |
427 | pci_disable_device(esb_pci); | 386 | pci_disable_device(esb_pci); |
428 | err_devput: | 387 | err_devput: |
429 | pci_dev_put(esb_pci); | 388 | pci_dev_put(esb_pci); |
430 | } | ||
431 | return 0; | 389 | return 0; |
432 | } | 390 | } |
433 | 391 | ||
392 | static void __devinit esb_initdevice(void) | ||
393 | { | ||
394 | u8 val1; | ||
395 | u16 val2; | ||
396 | |||
397 | /* | ||
398 | * Config register: | ||
399 | * Bit 5 : 0 = Enable WDT_OUTPUT | ||
400 | * Bit 2 : 0 = set the timer frequency to the PCI clock | ||
401 | * divided by 2^15 (approx 1KHz). | ||
402 | * Bits 1:0 : 11 = WDT_INT_TYPE Disabled. | ||
403 | * The watchdog has two timers, it can be setup so that the | ||
404 | * expiry of timer1 results in an interrupt and the expiry of | ||
405 | * timer2 results in a reboot. We set it to not generate | ||
406 | * any interrupts as there is not much we can do with it | ||
407 | * right now. | ||
408 | */ | ||
409 | pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003); | ||
410 | |||
411 | /* Check that the WDT isn't already locked */ | ||
412 | pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1); | ||
413 | if (val1 & ESB_WDT_LOCK) | ||
414 | printk(KERN_WARNING PFX "nowayout already set\n"); | ||
415 | |||
416 | /* Set the timer to watchdog mode and disable it for now */ | ||
417 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00); | ||
418 | |||
419 | /* Check if the watchdog was previously triggered */ | ||
420 | esb_unlock_registers(); | ||
421 | val2 = readw(ESB_RELOAD_REG); | ||
422 | if (val2 & ESB_WDT_TIMEOUT) | ||
423 | triggered = WDIOF_CARDRESET; | ||
424 | |||
425 | /* Reset WDT_TIMEOUT flag and timers */ | ||
426 | esb_unlock_registers(); | ||
427 | writew((ESB_WDT_TIMEOUT | ESB_WDT_RELOAD), ESB_RELOAD_REG); | ||
428 | |||
429 | /* And set the correct timeout value */ | ||
430 | esb_timer_set_heartbeat(heartbeat); | ||
431 | } | ||
432 | |||
434 | static int __devinit esb_probe(struct platform_device *dev) | 433 | static int __devinit esb_probe(struct platform_device *dev) |
435 | { | 434 | { |
436 | int ret; | 435 | int ret; |
@@ -441,13 +440,17 @@ static int __devinit esb_probe(struct platform_device *dev) | |||
441 | 440 | ||
442 | /* Check that the heartbeat value is within it's range; | 441 | /* Check that the heartbeat value is within it's range; |
443 | if not reset to the default */ | 442 | if not reset to the default */ |
444 | if (esb_timer_set_heartbeat(heartbeat)) { | 443 | if (heartbeat < 0x1 || heartbeat > 2 * 0x03ff) { |
445 | esb_timer_set_heartbeat(WATCHDOG_HEARTBEAT); | 444 | heartbeat = WATCHDOG_HEARTBEAT; |
446 | printk(KERN_INFO PFX | 445 | printk(KERN_INFO PFX |
447 | "heartbeat value must be 1<heartbeat<2046, using %d\n", | 446 | "heartbeat value must be 1<heartbeat<2046, using %d\n", |
448 | heartbeat); | 447 | heartbeat); |
449 | } | 448 | } |
450 | 449 | ||
450 | /* Initialize the watchdog and make sure it does not run */ | ||
451 | esb_initdevice(); | ||
452 | |||
453 | /* Register the watchdog so that userspace has access to it */ | ||
451 | ret = misc_register(&esb_miscdev); | 454 | ret = misc_register(&esb_miscdev); |
452 | if (ret != 0) { | 455 | if (ret != 0) { |
453 | printk(KERN_ERR PFX | 456 | printk(KERN_ERR PFX |
@@ -455,7 +458,6 @@ static int __devinit esb_probe(struct platform_device *dev) | |||
455 | WATCHDOG_MINOR, ret); | 458 | WATCHDOG_MINOR, ret); |
456 | goto err_unmap; | 459 | goto err_unmap; |
457 | } | 460 | } |
458 | esb_timer_stop(); | ||
459 | printk(KERN_INFO PFX | 461 | printk(KERN_INFO PFX |
460 | "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", | 462 | "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", |
461 | BASEADDR, heartbeat, nowayout); | 463 | BASEADDR, heartbeat, nowayout); |
@@ -463,11 +465,8 @@ static int __devinit esb_probe(struct platform_device *dev) | |||
463 | 465 | ||
464 | err_unmap: | 466 | err_unmap: |
465 | iounmap(BASEADDR); | 467 | iounmap(BASEADDR); |
466 | /* err_release: */ | ||
467 | pci_release_region(esb_pci, 0); | 468 | pci_release_region(esb_pci, 0); |
468 | /* err_disable: */ | ||
469 | pci_disable_device(esb_pci); | 469 | pci_disable_device(esb_pci); |
470 | /* err_devput: */ | ||
471 | pci_dev_put(esb_pci); | 470 | pci_dev_put(esb_pci); |
472 | return ret; | 471 | return ret; |
473 | } | 472 | } |
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c index 74c92d384112..ae3832110acb 100644 --- a/drivers/watchdog/ks8695_wdt.c +++ b/drivers/watchdog/ks8695_wdt.c | |||
@@ -221,7 +221,7 @@ static struct miscdevice ks8695wdt_miscdev = { | |||
221 | .fops = &ks8695wdt_fops, | 221 | .fops = &ks8695wdt_fops, |
222 | }; | 222 | }; |
223 | 223 | ||
224 | static int __init ks8695wdt_probe(struct platform_device *pdev) | 224 | static int __devinit ks8695wdt_probe(struct platform_device *pdev) |
225 | { | 225 | { |
226 | int res; | 226 | int res; |
227 | 227 | ||
@@ -238,7 +238,7 @@ static int __init ks8695wdt_probe(struct platform_device *pdev) | |||
238 | return 0; | 238 | return 0; |
239 | } | 239 | } |
240 | 240 | ||
241 | static int __exit ks8695wdt_remove(struct platform_device *pdev) | 241 | static int __devexit ks8695wdt_remove(struct platform_device *pdev) |
242 | { | 242 | { |
243 | int res; | 243 | int res; |
244 | 244 | ||
@@ -276,7 +276,7 @@ static int ks8695wdt_resume(struct platform_device *pdev) | |||
276 | 276 | ||
277 | static struct platform_driver ks8695wdt_driver = { | 277 | static struct platform_driver ks8695wdt_driver = { |
278 | .probe = ks8695wdt_probe, | 278 | .probe = ks8695wdt_probe, |
279 | .remove = __exit_p(ks8695wdt_remove), | 279 | .remove = __devexit_p(ks8695wdt_remove), |
280 | .shutdown = ks8695wdt_shutdown, | 280 | .shutdown = ks8695wdt_shutdown, |
281 | .suspend = ks8695wdt_suspend, | 281 | .suspend = ks8695wdt_suspend, |
282 | .resume = ks8695wdt_resume, | 282 | .resume = ks8695wdt_resume, |
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index aa5ad6e33f02..f2713851aaab 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c | |||
@@ -258,7 +258,7 @@ static const struct file_operations omap_wdt_fops = { | |||
258 | .release = omap_wdt_release, | 258 | .release = omap_wdt_release, |
259 | }; | 259 | }; |
260 | 260 | ||
261 | static int __init omap_wdt_probe(struct platform_device *pdev) | 261 | static int __devinit omap_wdt_probe(struct platform_device *pdev) |
262 | { | 262 | { |
263 | struct resource *res, *mem; | 263 | struct resource *res, *mem; |
264 | struct omap_wdt_dev *wdev; | 264 | struct omap_wdt_dev *wdev; |
@@ -367,7 +367,7 @@ static void omap_wdt_shutdown(struct platform_device *pdev) | |||
367 | omap_wdt_disable(wdev); | 367 | omap_wdt_disable(wdev); |
368 | } | 368 | } |
369 | 369 | ||
370 | static int omap_wdt_remove(struct platform_device *pdev) | 370 | static int __devexit omap_wdt_remove(struct platform_device *pdev) |
371 | { | 371 | { |
372 | struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); | 372 | struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); |
373 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 373 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -426,7 +426,7 @@ static int omap_wdt_resume(struct platform_device *pdev) | |||
426 | 426 | ||
427 | static struct platform_driver omap_wdt_driver = { | 427 | static struct platform_driver omap_wdt_driver = { |
428 | .probe = omap_wdt_probe, | 428 | .probe = omap_wdt_probe, |
429 | .remove = omap_wdt_remove, | 429 | .remove = __devexit_p(omap_wdt_remove), |
430 | .shutdown = omap_wdt_shutdown, | 430 | .shutdown = omap_wdt_shutdown, |
431 | .suspend = omap_wdt_suspend, | 431 | .suspend = omap_wdt_suspend, |
432 | .resume = omap_wdt_resume, | 432 | .resume = omap_wdt_resume, |
diff --git a/drivers/watchdog/orion5x_wdt.c b/drivers/watchdog/orion5x_wdt.c index e81441f103dd..7529616739d2 100644 --- a/drivers/watchdog/orion5x_wdt.c +++ b/drivers/watchdog/orion5x_wdt.c | |||
@@ -42,7 +42,17 @@ static unsigned int wdt_tclk; | |||
42 | static unsigned long wdt_status; | 42 | static unsigned long wdt_status; |
43 | static spinlock_t wdt_lock; | 43 | static spinlock_t wdt_lock; |
44 | 44 | ||
45 | static void wdt_enable(void) | 45 | static void orion5x_wdt_ping(void) |
46 | { | ||
47 | spin_lock(&wdt_lock); | ||
48 | |||
49 | /* Reload watchdog duration */ | ||
50 | writel(wdt_tclk * heartbeat, WDT_VAL); | ||
51 | |||
52 | spin_unlock(&wdt_lock); | ||
53 | } | ||
54 | |||
55 | static void orion5x_wdt_enable(void) | ||
46 | { | 56 | { |
47 | u32 reg; | 57 | u32 reg; |
48 | 58 | ||
@@ -69,7 +79,7 @@ static void wdt_enable(void) | |||
69 | spin_unlock(&wdt_lock); | 79 | spin_unlock(&wdt_lock); |
70 | } | 80 | } |
71 | 81 | ||
72 | static void wdt_disable(void) | 82 | static void orion5x_wdt_disable(void) |
73 | { | 83 | { |
74 | u32 reg; | 84 | u32 reg; |
75 | 85 | ||
@@ -101,7 +111,7 @@ static int orion5x_wdt_open(struct inode *inode, struct file *file) | |||
101 | if (test_and_set_bit(WDT_IN_USE, &wdt_status)) | 111 | if (test_and_set_bit(WDT_IN_USE, &wdt_status)) |
102 | return -EBUSY; | 112 | return -EBUSY; |
103 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | 113 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); |
104 | wdt_enable(); | 114 | orion5x_wdt_enable(); |
105 | return nonseekable_open(inode, file); | 115 | return nonseekable_open(inode, file); |
106 | } | 116 | } |
107 | 117 | ||
@@ -122,18 +132,28 @@ static ssize_t orion5x_wdt_write(struct file *file, const char *data, | |||
122 | set_bit(WDT_OK_TO_CLOSE, &wdt_status); | 132 | set_bit(WDT_OK_TO_CLOSE, &wdt_status); |
123 | } | 133 | } |
124 | } | 134 | } |
125 | wdt_enable(); | 135 | orion5x_wdt_ping(); |
126 | } | 136 | } |
127 | return len; | 137 | return len; |
128 | } | 138 | } |
129 | 139 | ||
130 | static struct watchdog_info ident = { | 140 | static int orion5x_wdt_settimeout(int new_time) |
141 | { | ||
142 | if ((new_time <= 0) || (new_time > wdt_max_duration)) | ||
143 | return -EINVAL; | ||
144 | |||
145 | /* Set new watchdog time to be used when | ||
146 | * orion5x_wdt_enable() or orion5x_wdt_ping() is called. */ | ||
147 | heartbeat = new_time; | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static const struct watchdog_info ident = { | ||
131 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | | 152 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | |
132 | WDIOF_KEEPALIVEPING, | 153 | WDIOF_KEEPALIVEPING, |
133 | .identity = "Orion5x Watchdog", | 154 | .identity = "Orion5x Watchdog", |
134 | }; | 155 | }; |
135 | 156 | ||
136 | |||
137 | static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, | 157 | static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, |
138 | unsigned long arg) | 158 | unsigned long arg) |
139 | { | 159 | { |
@@ -152,7 +172,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, | |||
152 | break; | 172 | break; |
153 | 173 | ||
154 | case WDIOC_KEEPALIVE: | 174 | case WDIOC_KEEPALIVE: |
155 | wdt_enable(); | 175 | orion5x_wdt_ping(); |
156 | ret = 0; | 176 | ret = 0; |
157 | break; | 177 | break; |
158 | 178 | ||
@@ -161,12 +181,11 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, | |||
161 | if (ret) | 181 | if (ret) |
162 | break; | 182 | break; |
163 | 183 | ||
164 | if (time <= 0 || time > wdt_max_duration) { | 184 | if (orion5x_wdt_settimeout(time)) { |
165 | ret = -EINVAL; | 185 | ret = -EINVAL; |
166 | break; | 186 | break; |
167 | } | 187 | } |
168 | heartbeat = time; | 188 | orion5x_wdt_ping(); |
169 | wdt_enable(); | ||
170 | /* Fall through */ | 189 | /* Fall through */ |
171 | 190 | ||
172 | case WDIOC_GETTIMEOUT: | 191 | case WDIOC_GETTIMEOUT: |
@@ -187,7 +206,7 @@ static long orion5x_wdt_ioctl(struct file *file, unsigned int cmd, | |||
187 | static int orion5x_wdt_release(struct inode *inode, struct file *file) | 206 | static int orion5x_wdt_release(struct inode *inode, struct file *file) |
188 | { | 207 | { |
189 | if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) | 208 | if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) |
190 | wdt_disable(); | 209 | orion5x_wdt_disable(); |
191 | else | 210 | else |
192 | printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " | 211 | printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " |
193 | "timer will not stop\n"); | 212 | "timer will not stop\n"); |
@@ -230,7 +249,7 @@ static int __devinit orion5x_wdt_probe(struct platform_device *pdev) | |||
230 | orion5x_wdt_miscdev.parent = &pdev->dev; | 249 | orion5x_wdt_miscdev.parent = &pdev->dev; |
231 | 250 | ||
232 | wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk; | 251 | wdt_max_duration = WDT_MAX_CYCLE_COUNT / wdt_tclk; |
233 | if (heartbeat <= 0 || heartbeat > wdt_max_duration) | 252 | if (orion5x_wdt_settimeout(heartbeat)) |
234 | heartbeat = wdt_max_duration; | 253 | heartbeat = wdt_max_duration; |
235 | 254 | ||
236 | ret = misc_register(&orion5x_wdt_miscdev); | 255 | ret = misc_register(&orion5x_wdt_miscdev); |
@@ -247,7 +266,7 @@ static int __devexit orion5x_wdt_remove(struct platform_device *pdev) | |||
247 | int ret; | 266 | int ret; |
248 | 267 | ||
249 | if (test_bit(WDT_IN_USE, &wdt_status)) { | 268 | if (test_bit(WDT_IN_USE, &wdt_status)) { |
250 | wdt_disable(); | 269 | orion5x_wdt_disable(); |
251 | clear_bit(WDT_IN_USE, &wdt_status); | 270 | clear_bit(WDT_IN_USE, &wdt_status); |
252 | } | 271 | } |
253 | 272 | ||
@@ -258,9 +277,16 @@ static int __devexit orion5x_wdt_remove(struct platform_device *pdev) | |||
258 | return ret; | 277 | return ret; |
259 | } | 278 | } |
260 | 279 | ||
280 | static void orion5x_wdt_shutdown(struct platform_device *pdev) | ||
281 | { | ||
282 | if (test_bit(WDT_IN_USE, &wdt_status)) | ||
283 | orion5x_wdt_disable(); | ||
284 | } | ||
285 | |||
261 | static struct platform_driver orion5x_wdt_driver = { | 286 | static struct platform_driver orion5x_wdt_driver = { |
262 | .probe = orion5x_wdt_probe, | 287 | .probe = orion5x_wdt_probe, |
263 | .remove = __devexit_p(orion5x_wdt_remove), | 288 | .remove = __devexit_p(orion5x_wdt_remove), |
289 | .shutdown = orion5x_wdt_shutdown, | ||
264 | .driver = { | 290 | .driver = { |
265 | .owner = THIS_MODULE, | 291 | .owner = THIS_MODULE, |
266 | .name = "orion5x_wdt", | 292 | .name = "orion5x_wdt", |
@@ -285,10 +311,11 @@ MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>"); | |||
285 | MODULE_DESCRIPTION("Orion5x Processor Watchdog"); | 311 | MODULE_DESCRIPTION("Orion5x Processor Watchdog"); |
286 | 312 | ||
287 | module_param(heartbeat, int, 0); | 313 | module_param(heartbeat, int, 0); |
288 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds"); | 314 | MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); |
289 | 315 | ||
290 | module_param(nowayout, int, 0); | 316 | module_param(nowayout, int, 0); |
291 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"); | 317 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
318 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
292 | 319 | ||
293 | MODULE_LICENSE("GPL"); | 320 | MODULE_LICENSE("GPL"); |
294 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 321 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c index 5d3b1a8e28b0..a38fa4907c92 100644 --- a/drivers/watchdog/wdrtas.c +++ b/drivers/watchdog/wdrtas.c | |||
@@ -106,6 +106,8 @@ static int wdrtas_set_interval(int interval) | |||
106 | return result; | 106 | return result; |
107 | } | 107 | } |
108 | 108 | ||
109 | #define WDRTAS_SP_SPI_LEN 4 | ||
110 | |||
109 | /** | 111 | /** |
110 | * wdrtas_get_interval - returns the current watchdog interval | 112 | * wdrtas_get_interval - returns the current watchdog interval |
111 | * @fallback_value: value (in seconds) to use, if the RTAS call fails | 113 | * @fallback_value: value (in seconds) to use, if the RTAS call fails |
@@ -119,10 +121,17 @@ static int wdrtas_set_interval(int interval) | |||
119 | static int wdrtas_get_interval(int fallback_value) | 121 | static int wdrtas_get_interval(int fallback_value) |
120 | { | 122 | { |
121 | long result; | 123 | long result; |
122 | char value[4]; | 124 | char value[WDRTAS_SP_SPI_LEN]; |
123 | 125 | ||
126 | spin_lock(&rtas_data_buf_lock); | ||
127 | memset(rtas_data_buf, 0, WDRTAS_SP_SPI_LEN); | ||
124 | result = rtas_call(wdrtas_token_get_sp, 3, 1, NULL, | 128 | result = rtas_call(wdrtas_token_get_sp, 3, 1, NULL, |
125 | WDRTAS_SP_SPI, (void *)__pa(&value), 4); | 129 | WDRTAS_SP_SPI, __pa(rtas_data_buf), |
130 | WDRTAS_SP_SPI_LEN); | ||
131 | |||
132 | memcpy(value, rtas_data_buf, WDRTAS_SP_SPI_LEN); | ||
133 | spin_unlock(&rtas_data_buf_lock); | ||
134 | |||
126 | if (value[0] != 0 || value[1] != 2 || value[3] != 0 || result < 0) { | 135 | if (value[0] != 0 || value[1] != 2 || value[3] != 0 || result < 0) { |
127 | printk(KERN_WARNING "wdrtas: could not get sp_spi watchdog " | 136 | printk(KERN_WARNING "wdrtas: could not get sp_spi watchdog " |
128 | "timeout (%li). Continuing\n", result); | 137 | "timeout (%li). Continuing\n", result); |