diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-27 17:37:28 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-27 17:37:28 -0400 |
| commit | ee7cbabbd359b5d9a60de3d5f1693163e07987ca (patch) | |
| tree | 29c3b01f8cdb26ccf69acaf5d0a64eefab87f7b3 | |
| parent | a152db71d962f405f7e9be5c818bddf6d1be50a7 (diff) | |
| parent | 3ccd3ec6d4a7750c49c4d2bbcc1d0e82cd4c8a7f (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
* git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog:
[WATCHDOG] removed unused #include <version.h>
[WATCHDOG] at91rm9200_wdt.c: fix misleading indentation
[WATCHDOG] mpc8xxx_wdt: fix modular build
[WATCHDOG] hpwdt.c kdebug support
[WATCHDOG] Add support for the IDT RC32434 watchdog
[WATCHDOG] Add support for the built-int RDC R-321x SoC watchdog
[WATHDOG] delete unused driver mpc8xx_wdt.c
[WATCHDOG] Fix s3c2410_wdt driver coding style issues
[WATCHDOG] Clean out header of s3c2410_wdt driver.
[WATCHDOG] Fix NULL usage in s3c2410_wdt driver.
| -rw-r--r-- | drivers/watchdog/Kconfig | 24 | ||||
| -rw-r--r-- | drivers/watchdog/Makefile | 3 | ||||
| -rw-r--r-- | drivers/watchdog/at91rm9200_wdt.c | 2 | ||||
| -rw-r--r-- | drivers/watchdog/hpwdt.c | 93 | ||||
| -rw-r--r-- | drivers/watchdog/mpc8xx_wdt.c | 170 | ||||
| -rw-r--r-- | drivers/watchdog/mpc8xxx_wdt.c | 11 | ||||
| -rw-r--r-- | drivers/watchdog/pc87413_wdt.c | 1 | ||||
| -rw-r--r-- | drivers/watchdog/rc32434_wdt.c | 344 | ||||
| -rw-r--r-- | drivers/watchdog/rdc321x_wdt.c | 285 | ||||
| -rw-r--r-- | drivers/watchdog/s3c2410_wdt.c | 16 |
10 files changed, 714 insertions, 235 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index db20542796bf..c51036716700 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
| @@ -465,6 +465,16 @@ config PC87413_WDT | |||
| 465 | 465 | ||
| 466 | Most people will say N. | 466 | Most people will say N. |
| 467 | 467 | ||
| 468 | config RDC321X_WDT | ||
| 469 | tristate "RDC R-321x SoC watchdog" | ||
| 470 | depends on X86_RDC321X | ||
| 471 | help | ||
| 472 | This is the driver for the built in hardware watchdog | ||
| 473 | in the RDC R-321x SoC. | ||
| 474 | |||
| 475 | To compile this driver as a module, choose M here: the | ||
| 476 | module will be called rdc321x_wdt. | ||
| 477 | |||
| 468 | config 60XX_WDT | 478 | config 60XX_WDT |
| 469 | tristate "SBC-60XX Watchdog Timer" | 479 | tristate "SBC-60XX Watchdog Timer" |
| 470 | depends on X86 | 480 | depends on X86 |
| @@ -633,6 +643,16 @@ config SBC_EPX_C3_WATCHDOG | |||
| 633 | 643 | ||
| 634 | # MIPS Architecture | 644 | # MIPS Architecture |
| 635 | 645 | ||
| 646 | config RC32434_WDT | ||
| 647 | tristate "IDT RC32434 SoC Watchdog Timer" | ||
| 648 | depends on MIKROTIK_RB532 | ||
| 649 | help | ||
| 650 | Hardware driver for the IDT RC32434 SoC built-in | ||
| 651 | watchdog timer. | ||
| 652 | |||
| 653 | To compile this driver as a module, choose M here: the | ||
| 654 | module will be called rc32434_wdt. | ||
| 655 | |||
| 636 | config INDYDOG | 656 | config INDYDOG |
| 637 | tristate "Indy/I2 Hardware Watchdog" | 657 | tristate "Indy/I2 Hardware Watchdog" |
| 638 | depends on SGI_HAS_INDYDOG | 658 | depends on SGI_HAS_INDYDOG |
| @@ -692,10 +712,6 @@ config MPC5200_WDT | |||
| 692 | tristate "MPC5200 Watchdog Timer" | 712 | tristate "MPC5200 Watchdog Timer" |
| 693 | depends on PPC_MPC52xx | 713 | depends on PPC_MPC52xx |
| 694 | 714 | ||
| 695 | config 8xx_WDT | ||
| 696 | tristate "MPC8xx Watchdog Timer" | ||
| 697 | depends on 8xx | ||
| 698 | |||
| 699 | config 8xxx_WDT | 715 | config 8xxx_WDT |
| 700 | tristate "MPC8xxx Platform Watchdog Timer" | 716 | tristate "MPC8xxx Platform Watchdog Timer" |
| 701 | depends on PPC_8xx || PPC_83xx || PPC_86xx | 717 | depends on PPC_8xx || PPC_83xx || PPC_86xx |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index ca3dc043d786..e0ef123fbdea 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
| @@ -75,6 +75,7 @@ obj-$(CONFIG_HP_WATCHDOG) += hpwdt.o | |||
| 75 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | 75 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o |
| 76 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | 76 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o |
| 77 | obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o | 77 | obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o |
| 78 | obj-$(CONFIG_RDC321X_WDT) += rdc321x_wdt.o | ||
| 78 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o | 79 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o |
| 79 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o | 80 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o |
| 80 | obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o | 81 | obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o |
| @@ -94,6 +95,7 @@ obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o | |||
| 94 | # M68KNOMMU Architecture | 95 | # M68KNOMMU Architecture |
| 95 | 96 | ||
| 96 | # MIPS Architecture | 97 | # MIPS Architecture |
| 98 | obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o | ||
| 97 | obj-$(CONFIG_INDYDOG) += indydog.o | 99 | obj-$(CONFIG_INDYDOG) += indydog.o |
| 98 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o | 100 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o |
| 99 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o | 101 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o |
| @@ -104,7 +106,6 @@ obj-$(CONFIG_TXX9_WDT) += txx9wdt.o | |||
| 104 | # PARISC Architecture | 106 | # PARISC Architecture |
| 105 | 107 | ||
| 106 | # POWERPC Architecture | 108 | # POWERPC Architecture |
| 107 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o | ||
| 108 | obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o | 109 | obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o |
| 109 | obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o | 110 | obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o |
| 110 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o | 111 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o |
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index d061f0ad2d20..993e5f52afef 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
| @@ -241,7 +241,7 @@ static int at91wdt_resume(struct platform_device *pdev) | |||
| 241 | { | 241 | { |
| 242 | if (at91wdt_busy) | 242 | if (at91wdt_busy) |
| 243 | at91_wdt_start(); | 243 | at91_wdt_start(); |
| 244 | return 0; | 244 | return 0; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | #else | 247 | #else |
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index d039d5f2fd1c..a3765e0be4a8 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c | |||
| @@ -116,6 +116,7 @@ static unsigned int reload; /* the computed soft_margin */ | |||
| 116 | static int nowayout = WATCHDOG_NOWAYOUT; | 116 | static int nowayout = WATCHDOG_NOWAYOUT; |
| 117 | static char expect_release; | 117 | static char expect_release; |
| 118 | static unsigned long hpwdt_is_open; | 118 | static unsigned long hpwdt_is_open; |
| 119 | static unsigned int allow_kdump; | ||
| 119 | 120 | ||
| 120 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ | 121 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ |
| 121 | static unsigned long __iomem *hpwdt_timer_reg; | 122 | static unsigned long __iomem *hpwdt_timer_reg; |
| @@ -221,19 +222,19 @@ static int __devinit cru_detect(unsigned long map_entry, | |||
| 221 | 222 | ||
| 222 | if (cmn_regs.u1.ral != 0) { | 223 | if (cmn_regs.u1.ral != 0) { |
| 223 | printk(KERN_WARNING | 224 | printk(KERN_WARNING |
| 224 | "hpwdt: Call succeeded but with an error: 0x%x\n", | 225 | "hpwdt: Call succeeded but with an error: 0x%x\n", |
| 225 | cmn_regs.u1.ral); | 226 | cmn_regs.u1.ral); |
| 226 | } else { | 227 | } else { |
| 227 | physical_bios_base = cmn_regs.u2.rebx; | 228 | physical_bios_base = cmn_regs.u2.rebx; |
| 228 | physical_bios_offset = cmn_regs.u4.redx; | 229 | physical_bios_offset = cmn_regs.u4.redx; |
| 229 | cru_length = cmn_regs.u3.recx; | 230 | cru_length = cmn_regs.u3.recx; |
| 230 | cru_physical_address = | 231 | cru_physical_address = |
| 231 | physical_bios_base + physical_bios_offset; | 232 | physical_bios_base + physical_bios_offset; |
| 232 | 233 | ||
| 233 | /* If the values look OK, then map it in. */ | 234 | /* If the values look OK, then map it in. */ |
| 234 | if ((physical_bios_base + physical_bios_offset)) { | 235 | if ((physical_bios_base + physical_bios_offset)) { |
| 235 | cru_rom_addr = | 236 | cru_rom_addr = |
| 236 | ioremap(cru_physical_address, cru_length); | 237 | ioremap(cru_physical_address, cru_length); |
| 237 | if (cru_rom_addr) | 238 | if (cru_rom_addr) |
| 238 | retval = 0; | 239 | retval = 0; |
| 239 | } | 240 | } |
| @@ -356,7 +357,6 @@ asm(".text \n\t" | |||
| 356 | "call *%r12 \n\t" | 357 | "call *%r12 \n\t" |
| 357 | "pushfq \n\t" | 358 | "pushfq \n\t" |
| 358 | "popq %r12 \n\t" | 359 | "popq %r12 \n\t" |
| 359 | "popfq \n\t" | ||
| 360 | "movl %eax, (%r9) \n\t" | 360 | "movl %eax, (%r9) \n\t" |
| 361 | "movl %ebx, 4(%r9) \n\t" | 361 | "movl %ebx, 4(%r9) \n\t" |
| 362 | "movl %ecx, 8(%r9) \n\t" | 362 | "movl %ecx, 8(%r9) \n\t" |
| @@ -390,10 +390,10 @@ static void __devinit dmi_find_cru(const struct dmi_header *dm) | |||
| 390 | smbios_cru64_ptr = (struct smbios_cru64_info *) dm; | 390 | smbios_cru64_ptr = (struct smbios_cru64_info *) dm; |
| 391 | if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) { | 391 | if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) { |
| 392 | cru_physical_address = | 392 | cru_physical_address = |
| 393 | smbios_cru64_ptr->physical_address + | 393 | smbios_cru64_ptr->physical_address + |
| 394 | smbios_cru64_ptr->double_offset; | 394 | smbios_cru64_ptr->double_offset; |
| 395 | cru_rom_addr = ioremap(cru_physical_address, | 395 | cru_rom_addr = ioremap(cru_physical_address, |
| 396 | smbios_cru64_ptr->double_length); | 396 | smbios_cru64_ptr->double_length); |
| 397 | } | 397 | } |
| 398 | } | 398 | } |
| 399 | } | 399 | } |
| @@ -405,7 +405,7 @@ static int __devinit detect_cru_service(void) | |||
| 405 | dmi_walk(dmi_find_cru); | 405 | dmi_walk(dmi_find_cru); |
| 406 | 406 | ||
| 407 | /* if cru_rom_addr has been set then we found a CRU service */ | 407 | /* if cru_rom_addr has been set then we found a CRU service */ |
| 408 | return ((cru_rom_addr != NULL) ? 0: -ENODEV); | 408 | return ((cru_rom_addr != NULL) ? 0 : -ENODEV); |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | /* ------------------------------------------------------------------------- */ | 411 | /* ------------------------------------------------------------------------- */ |
| @@ -413,34 +413,6 @@ static int __devinit detect_cru_service(void) | |||
| 413 | #endif | 413 | #endif |
| 414 | 414 | ||
| 415 | /* | 415 | /* |
| 416 | * NMI Handler | ||
| 417 | */ | ||
| 418 | static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason, | ||
| 419 | void *data) | ||
| 420 | { | ||
| 421 | unsigned long rom_pl; | ||
| 422 | static int die_nmi_called; | ||
| 423 | |||
| 424 | if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI) | ||
| 425 | return NOTIFY_OK; | ||
| 426 | |||
| 427 | spin_lock_irqsave(&rom_lock, rom_pl); | ||
| 428 | if (!die_nmi_called) | ||
| 429 | asminline_call(&cmn_regs, cru_rom_addr); | ||
| 430 | die_nmi_called = 1; | ||
| 431 | spin_unlock_irqrestore(&rom_lock, rom_pl); | ||
| 432 | if (cmn_regs.u1.ral == 0) { | ||
| 433 | printk(KERN_WARNING "hpwdt: An NMI occurred, " | ||
| 434 | "but unable to determine source.\n"); | ||
| 435 | } else { | ||
| 436 | panic("An NMI occurred, please see the Integrated " | ||
| 437 | "Management Log for details.\n"); | ||
| 438 | } | ||
| 439 | |||
| 440 | return NOTIFY_STOP; | ||
| 441 | } | ||
| 442 | |||
| 443 | /* | ||
| 444 | * Watchdog operations | 416 | * Watchdog operations |
| 445 | */ | 417 | */ |
| 446 | static void hpwdt_start(void) | 418 | static void hpwdt_start(void) |
| @@ -484,6 +456,36 @@ static int hpwdt_change_timer(int new_margin) | |||
| 484 | } | 456 | } |
| 485 | 457 | ||
| 486 | /* | 458 | /* |
| 459 | * NMI Handler | ||
| 460 | */ | ||
| 461 | static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason, | ||
| 462 | void *data) | ||
| 463 | { | ||
| 464 | unsigned long rom_pl; | ||
| 465 | static int die_nmi_called; | ||
| 466 | |||
| 467 | if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI) | ||
| 468 | return NOTIFY_OK; | ||
| 469 | |||
| 470 | spin_lock_irqsave(&rom_lock, rom_pl); | ||
| 471 | if (!die_nmi_called) | ||
| 472 | asminline_call(&cmn_regs, cru_rom_addr); | ||
| 473 | die_nmi_called = 1; | ||
| 474 | spin_unlock_irqrestore(&rom_lock, rom_pl); | ||
| 475 | if (cmn_regs.u1.ral == 0) { | ||
| 476 | printk(KERN_WARNING "hpwdt: An NMI occurred, " | ||
| 477 | "but unable to determine source.\n"); | ||
| 478 | } else { | ||
| 479 | if (allow_kdump) | ||
| 480 | hpwdt_stop(); | ||
| 481 | panic("An NMI occurred, please see the Integrated " | ||
| 482 | "Management Log for details.\n"); | ||
| 483 | } | ||
| 484 | |||
| 485 | return NOTIFY_STOP; | ||
| 486 | } | ||
| 487 | |||
| 488 | /* | ||
| 487 | * /dev/watchdog handling | 489 | * /dev/watchdog handling |
| 488 | */ | 490 | */ |
| 489 | static int hpwdt_open(struct inode *inode, struct file *file) | 491 | static int hpwdt_open(struct inode *inode, struct file *file) |
| @@ -625,17 +627,18 @@ static struct notifier_block die_notifier = { | |||
| 625 | */ | 627 | */ |
| 626 | 628 | ||
| 627 | static int __devinit hpwdt_init_one(struct pci_dev *dev, | 629 | static int __devinit hpwdt_init_one(struct pci_dev *dev, |
| 628 | const struct pci_device_id *ent) | 630 | const struct pci_device_id *ent) |
| 629 | { | 631 | { |
| 630 | int retval; | 632 | int retval; |
| 631 | 633 | ||
| 632 | /* | 634 | /* |
| 633 | * First let's find out if we are on an iLO2 server. We will | 635 | * First let's find out if we are on an iLO2 server. We will |
| 634 | * not run on a legacy ASM box. | 636 | * not run on a legacy ASM box. |
| 637 | * So we only support the G5 ProLiant servers and higher. | ||
| 635 | */ | 638 | */ |
| 636 | if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) { | 639 | if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) { |
| 637 | dev_warn(&dev->dev, | 640 | dev_warn(&dev->dev, |
| 638 | "This server does not have an iLO2 ASIC.\n"); | 641 | "This server does not have an iLO2 ASIC.\n"); |
| 639 | return -ENODEV; | 642 | return -ENODEV; |
| 640 | } | 643 | } |
| 641 | 644 | ||
| @@ -669,7 +672,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
| 669 | retval = detect_cru_service(); | 672 | retval = detect_cru_service(); |
| 670 | if (retval < 0) { | 673 | if (retval < 0) { |
| 671 | dev_warn(&dev->dev, | 674 | dev_warn(&dev->dev, |
| 672 | "Unable to detect the %d Bit CRU Service.\n", | 675 | "Unable to detect the %d Bit CRU Service.\n", |
| 673 | HPWDT_ARCH); | 676 | HPWDT_ARCH); |
| 674 | goto error_get_cru; | 677 | goto error_get_cru; |
| 675 | } | 678 | } |
| @@ -684,7 +687,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
| 684 | retval = register_die_notifier(&die_notifier); | 687 | retval = register_die_notifier(&die_notifier); |
| 685 | if (retval != 0) { | 688 | if (retval != 0) { |
| 686 | dev_warn(&dev->dev, | 689 | dev_warn(&dev->dev, |
| 687 | "Unable to register a die notifier (err=%d).\n", | 690 | "Unable to register a die notifier (err=%d).\n", |
| 688 | retval); | 691 | retval); |
| 689 | goto error_die_notifier; | 692 | goto error_die_notifier; |
| 690 | } | 693 | } |
| @@ -699,8 +702,9 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
| 699 | 702 | ||
| 700 | printk(KERN_INFO | 703 | printk(KERN_INFO |
| 701 | "hp Watchdog Timer Driver: 1.00" | 704 | "hp Watchdog Timer Driver: 1.00" |
| 702 | ", timer margin: %d seconds( nowayout=%d).\n", | 705 | ", timer margin: %d seconds (nowayout=%d)" |
| 703 | soft_margin, nowayout); | 706 | ", allow kernel dump: %s (default = 0/OFF).\n", |
| 707 | soft_margin, nowayout, (allow_kdump == 0) ? "OFF" : "ON"); | ||
| 704 | 708 | ||
| 705 | return 0; | 709 | return 0; |
| 706 | 710 | ||
| @@ -755,6 +759,9 @@ MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | |||
| 755 | module_param(soft_margin, int, 0); | 759 | module_param(soft_margin, int, 0); |
| 756 | MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); | 760 | MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); |
| 757 | 761 | ||
| 762 | module_param(allow_kdump, int, 0); | ||
| 763 | MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs"); | ||
| 764 | |||
| 758 | module_param(nowayout, int, 0); | 765 | module_param(nowayout, int, 0); |
| 759 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 766 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
| 760 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 767 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c deleted file mode 100644 index 1336425acf20..000000000000 --- a/drivers/watchdog/mpc8xx_wdt.c +++ /dev/null | |||
| @@ -1,170 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * mpc8xx_wdt.c - MPC8xx watchdog userspace interface | ||
| 3 | * | ||
| 4 | * Author: Florian Schirmer <jolt@tuxbox.org> | ||
| 5 | * | ||
| 6 | * 2002 (c) Florian Schirmer <jolt@tuxbox.org> This file is licensed under | ||
| 7 | * the terms of the GNU General Public License version 2. This program | ||
| 8 | * is licensed "as is" without any warranty of any kind, whether express | ||
| 9 | * or implied. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/fs.h> | ||
| 13 | #include <linux/init.h> | ||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/miscdevice.h> | ||
| 16 | #include <linux/module.h> | ||
| 17 | #include <linux/watchdog.h> | ||
| 18 | #include <asm/8xx_immap.h> | ||
| 19 | #include <linux/uaccess.h> | ||
| 20 | #include <linux/io.h> | ||
| 21 | #include <syslib/m8xx_wdt.h> | ||
| 22 | |||
| 23 | static unsigned long wdt_opened; | ||
| 24 | static int wdt_status; | ||
| 25 | static spinlock_t wdt_lock; | ||
| 26 | |||
| 27 | static void mpc8xx_wdt_handler_disable(void) | ||
| 28 | { | ||
| 29 | volatile uint __iomem *piscr; | ||
| 30 | piscr = (uint *)&((immap_t *)IMAP_ADDR)->im_sit.sit_piscr; | ||
| 31 | |||
| 32 | if (!m8xx_has_internal_rtc) | ||
| 33 | m8xx_wdt_stop_timer(); | ||
| 34 | else | ||
| 35 | out_be32(piscr, in_be32(piscr) & ~(PISCR_PIE | PISCR_PTE)); | ||
| 36 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler deactivated\n"); | ||
| 37 | } | ||
| 38 | |||
| 39 | static void mpc8xx_wdt_handler_enable(void) | ||
| 40 | { | ||
| 41 | volatile uint __iomem *piscr; | ||
| 42 | piscr = (uint *)&((immap_t *)IMAP_ADDR)->im_sit.sit_piscr; | ||
| 43 | |||
| 44 | if (!m8xx_has_internal_rtc) | ||
| 45 | m8xx_wdt_install_timer(); | ||
| 46 | else | ||
| 47 | out_be32(piscr, in_be32(piscr) | PISCR_PIE | PISCR_PTE); | ||
| 48 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler activated\n"); | ||
| 49 | } | ||
| 50 | |||
| 51 | static int mpc8xx_wdt_open(struct inode *inode, struct file *file) | ||
| 52 | { | ||
| 53 | if (test_and_set_bit(0, &wdt_opened)) | ||
| 54 | return -EBUSY; | ||
| 55 | m8xx_wdt_reset(); | ||
| 56 | mpc8xx_wdt_handler_disable(); | ||
| 57 | return nonseekable_open(inode, file); | ||
| 58 | } | ||
| 59 | |||
| 60 | static int mpc8xx_wdt_release(struct inode *inode, struct file *file) | ||
| 61 | { | ||
| 62 | m8xx_wdt_reset(); | ||
| 63 | #if !defined(CONFIG_WATCHDOG_NOWAYOUT) | ||
| 64 | mpc8xx_wdt_handler_enable(); | ||
| 65 | #endif | ||
| 66 | clear_bit(0, &wdt_opened); | ||
| 67 | return 0; | ||
| 68 | } | ||
| 69 | |||
| 70 | static ssize_t mpc8xx_wdt_write(struct file *file, const char *data, | ||
| 71 | size_t len, loff_t *ppos) | ||
| 72 | { | ||
| 73 | if (len) { | ||
| 74 | spin_lock(&wdt_lock); | ||
| 75 | m8xx_wdt_reset(); | ||
| 76 | spin_unlock(&wdt_lock); | ||
| 77 | } | ||
| 78 | return len; | ||
| 79 | } | ||
| 80 | |||
| 81 | static long mpc8xx_wdt_ioctl(struct file *file, | ||
| 82 | unsigned int cmd, unsigned long arg) | ||
| 83 | { | ||
| 84 | int timeout; | ||
| 85 | static struct watchdog_info info = { | ||
| 86 | .options = WDIOF_KEEPALIVEPING, | ||
| 87 | .firmware_version = 0, | ||
| 88 | .identity = "MPC8xx watchdog", | ||
| 89 | }; | ||
| 90 | |||
| 91 | switch (cmd) { | ||
| 92 | case WDIOC_GETSUPPORT: | ||
| 93 | if (copy_to_user((void *)arg, &info, sizeof(info))) | ||
| 94 | return -EFAULT; | ||
| 95 | break; | ||
| 96 | |||
| 97 | case WDIOC_GETSTATUS: | ||
| 98 | case WDIOC_GETBOOTSTATUS: | ||
| 99 | if (put_user(wdt_status, (int *)arg)) | ||
| 100 | return -EFAULT; | ||
| 101 | wdt_status &= ~WDIOF_KEEPALIVEPING; | ||
| 102 | break; | ||
| 103 | |||
| 104 | case WDIOC_GETTEMP: | ||
| 105 | return -EOPNOTSUPP; | ||
| 106 | |||
| 107 | case WDIOC_SETOPTIONS: | ||
| 108 | return -EOPNOTSUPP; | ||
| 109 | |||
| 110 | case WDIOC_KEEPALIVE: | ||
| 111 | spin_lock(&wdt_lock); | ||
| 112 | m8xx_wdt_reset(); | ||
| 113 | wdt_status |= WDIOF_KEEPALIVEPING; | ||
| 114 | spin_unlock(&wdt_lock); | ||
| 115 | break; | ||
| 116 | |||
| 117 | case WDIOC_SETTIMEOUT: | ||
| 118 | return -EOPNOTSUPP; | ||
| 119 | |||
| 120 | case WDIOC_GETTIMEOUT: | ||
| 121 | spin_lock(&wdt_lock); | ||
| 122 | timeout = m8xx_wdt_get_timeout(); | ||
| 123 | spin_unlock(&wdt_lock); | ||
| 124 | if (put_user(timeout, (int *)arg)) | ||
| 125 | return -EFAULT; | ||
| 126 | break; | ||
| 127 | |||
| 128 | default: | ||
| 129 | return -ENOTTY; | ||
| 130 | } | ||
| 131 | |||
| 132 | return 0; | ||
| 133 | } | ||
| 134 | |||
| 135 | static const struct file_operations mpc8xx_wdt_fops = { | ||
| 136 | .owner = THIS_MODULE, | ||
| 137 | .llseek = no_llseek, | ||
| 138 | .write = mpc8xx_wdt_write, | ||
| 139 | .unlocked_ioctl = mpc8xx_wdt_ioctl, | ||
| 140 | .open = mpc8xx_wdt_open, | ||
| 141 | .release = mpc8xx_wdt_release, | ||
| 142 | }; | ||
| 143 | |||
| 144 | static struct miscdevice mpc8xx_wdt_miscdev = { | ||
| 145 | .minor = WATCHDOG_MINOR, | ||
| 146 | .name = "watchdog", | ||
| 147 | .fops = &mpc8xx_wdt_fops, | ||
| 148 | }; | ||
| 149 | |||
| 150 | static int __init mpc8xx_wdt_init(void) | ||
| 151 | { | ||
| 152 | spin_lock_init(&wdt_lock); | ||
| 153 | return misc_register(&mpc8xx_wdt_miscdev); | ||
| 154 | } | ||
| 155 | |||
| 156 | static void __exit mpc8xx_wdt_exit(void) | ||
| 157 | { | ||
| 158 | misc_deregister(&mpc8xx_wdt_miscdev); | ||
| 159 | |||
| 160 | m8xx_wdt_reset(); | ||
| 161 | mpc8xx_wdt_handler_enable(); | ||
| 162 | } | ||
| 163 | |||
| 164 | module_init(mpc8xx_wdt_init); | ||
| 165 | module_exit(mpc8xx_wdt_exit); | ||
| 166 | |||
| 167 | MODULE_AUTHOR("Florian Schirmer <jolt@tuxbox.org>"); | ||
| 168 | MODULE_DESCRIPTION("MPC8xx watchdog driver"); | ||
| 169 | MODULE_LICENSE("GPL"); | ||
| 170 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index f2094960e662..38c588ee694f 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c | |||
| @@ -48,6 +48,7 @@ struct mpc8xxx_wdt_type { | |||
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | static struct mpc8xxx_wdt __iomem *wd_base; | 50 | static struct mpc8xxx_wdt __iomem *wd_base; |
| 51 | static int mpc8xxx_wdt_init_late(void); | ||
| 51 | 52 | ||
| 52 | static u16 timeout = 0xffff; | 53 | static u16 timeout = 0xffff; |
| 53 | module_param(timeout, ushort, 0); | 54 | module_param(timeout, ushort, 0); |
| @@ -213,6 +214,12 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev, | |||
| 213 | else | 214 | else |
| 214 | timeout_sec = timeout / freq; | 215 | timeout_sec = timeout / freq; |
| 215 | 216 | ||
| 217 | #ifdef MODULE | ||
| 218 | ret = mpc8xxx_wdt_init_late(); | ||
| 219 | if (ret) | ||
| 220 | goto err_unmap; | ||
| 221 | #endif | ||
| 222 | |||
| 216 | pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d " | 223 | pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d " |
| 217 | "(%d seconds)\n", reset ? "reset" : "interrupt", timeout, | 224 | "(%d seconds)\n", reset ? "reset" : "interrupt", timeout, |
| 218 | timeout_sec); | 225 | timeout_sec); |
| @@ -280,7 +287,7 @@ static struct of_platform_driver mpc8xxx_wdt_driver = { | |||
| 280 | * very early to start pinging the watchdog (misc devices are not yet | 287 | * very early to start pinging the watchdog (misc devices are not yet |
| 281 | * available), and later module_init() just registers the misc device. | 288 | * available), and later module_init() just registers the misc device. |
| 282 | */ | 289 | */ |
| 283 | static int __init mpc8xxx_wdt_init_late(void) | 290 | static int mpc8xxx_wdt_init_late(void) |
| 284 | { | 291 | { |
| 285 | int ret; | 292 | int ret; |
| 286 | 293 | ||
| @@ -295,7 +302,9 @@ static int __init mpc8xxx_wdt_init_late(void) | |||
| 295 | } | 302 | } |
| 296 | return 0; | 303 | return 0; |
| 297 | } | 304 | } |
| 305 | #ifndef MODULE | ||
| 298 | module_init(mpc8xxx_wdt_init_late); | 306 | module_init(mpc8xxx_wdt_init_late); |
| 307 | #endif | ||
| 299 | 308 | ||
| 300 | static int __init mpc8xxx_wdt_init(void) | 309 | static int __init mpc8xxx_wdt_init(void) |
| 301 | { | 310 | { |
diff --git a/drivers/watchdog/pc87413_wdt.c b/drivers/watchdog/pc87413_wdt.c index e91ada72da1d..484c215e9f3f 100644 --- a/drivers/watchdog/pc87413_wdt.c +++ b/drivers/watchdog/pc87413_wdt.c | |||
| @@ -30,7 +30,6 @@ | |||
| 30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
| 31 | #include <linux/spinlock.h> | 31 | #include <linux/spinlock.h> |
| 32 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
| 33 | #include <linux/version.h> | ||
| 34 | #include <linux/io.h> | 33 | #include <linux/io.h> |
| 35 | #include <linux/uaccess.h> | 34 | #include <linux/uaccess.h> |
| 36 | 35 | ||
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c new file mode 100644 index 000000000000..6756bcb009ed --- /dev/null +++ b/drivers/watchdog/rc32434_wdt.c | |||
| @@ -0,0 +1,344 @@ | |||
| 1 | /* | ||
| 2 | * IDT Interprise 79RC32434 watchdog driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006, Ondrej Zajicek <santiago@crfreenet.org> | ||
| 5 | * Copyright (C) 2008, Florian Fainelli <florian@openwrt.org> | ||
| 6 | * | ||
| 7 | * based on | ||
| 8 | * SoftDog 0.05: A Software Watchdog Device | ||
| 9 | * | ||
| 10 | * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved. | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or | ||
| 13 | * modify it under the terms of the GNU General Public License | ||
| 14 | * as published by the Free Software Foundation; either version | ||
| 15 | * 2 of the License, or (at your option) any later version. | ||
| 16 | * | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/types.h> | ||
| 21 | #include <linux/kernel.h> | ||
| 22 | #include <linux/fs.h> | ||
| 23 | #include <linux/mm.h> | ||
| 24 | #include <linux/miscdevice.h> | ||
| 25 | #include <linux/watchdog.h> | ||
| 26 | #include <linux/reboot.h> | ||
| 27 | #include <linux/smp_lock.h> | ||
| 28 | #include <linux/init.h> | ||
| 29 | #include <linux/platform_device.h> | ||
| 30 | #include <linux/uaccess.h> | ||
| 31 | |||
| 32 | #include <asm/bootinfo.h> | ||
| 33 | #include <asm/time.h> | ||
| 34 | #include <asm/mach-rc32434/integ.h> | ||
| 35 | |||
| 36 | #define MAX_TIMEOUT 20 | ||
| 37 | #define RC32434_WDT_INTERVAL (15 * HZ) | ||
| 38 | |||
| 39 | #define VERSION "0.2" | ||
| 40 | |||
| 41 | static struct { | ||
| 42 | struct completion stop; | ||
| 43 | int running; | ||
| 44 | struct timer_list timer; | ||
| 45 | int queue; | ||
| 46 | int default_ticks; | ||
| 47 | unsigned long inuse; | ||
| 48 | } rc32434_wdt_device; | ||
| 49 | |||
| 50 | static struct integ __iomem *wdt_reg; | ||
| 51 | static int ticks = 100 * HZ; | ||
| 52 | |||
| 53 | static int expect_close; | ||
| 54 | static int timeout; | ||
| 55 | |||
| 56 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
| 57 | module_param(nowayout, int, 0); | ||
| 58 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | ||
| 59 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
| 60 | |||
| 61 | |||
| 62 | static void rc32434_wdt_start(void) | ||
| 63 | { | ||
| 64 | u32 val; | ||
| 65 | |||
| 66 | if (!rc32434_wdt_device.inuse) { | ||
| 67 | writel(0, &wdt_reg->wtcount); | ||
| 68 | |||
| 69 | val = RC32434_ERR_WRE; | ||
| 70 | writel(readl(&wdt_reg->errcs) | val, &wdt_reg->errcs); | ||
| 71 | |||
| 72 | val = RC32434_WTC_EN; | ||
| 73 | writel(readl(&wdt_reg->wtc) | val, &wdt_reg->wtc); | ||
| 74 | } | ||
| 75 | rc32434_wdt_device.running++; | ||
| 76 | } | ||
| 77 | |||
| 78 | static void rc32434_wdt_stop(void) | ||
| 79 | { | ||
| 80 | u32 val; | ||
| 81 | |||
| 82 | if (rc32434_wdt_device.running) { | ||
| 83 | |||
| 84 | val = ~RC32434_WTC_EN; | ||
| 85 | writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); | ||
| 86 | |||
| 87 | val = ~RC32434_ERR_WRE; | ||
| 88 | writel(readl(&wdt_reg->errcs) & val, &wdt_reg->errcs); | ||
| 89 | |||
| 90 | rc32434_wdt_device.running = 0; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | static void rc32434_wdt_set(int new_timeout) | ||
| 95 | { | ||
| 96 | u32 cmp = new_timeout * HZ; | ||
| 97 | u32 state, val; | ||
| 98 | |||
| 99 | timeout = new_timeout; | ||
| 100 | /* | ||
| 101 | * store and disable WTC | ||
| 102 | */ | ||
| 103 | state = (u32)(readl(&wdt_reg->wtc) & RC32434_WTC_EN); | ||
| 104 | val = ~RC32434_WTC_EN; | ||
| 105 | writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); | ||
| 106 | |||
| 107 | writel(0, &wdt_reg->wtcount); | ||
| 108 | writel(cmp, &wdt_reg->wtcompare); | ||
| 109 | |||
| 110 | /* | ||
| 111 | * restore WTC | ||
| 112 | */ | ||
| 113 | |||
| 114 | writel(readl(&wdt_reg->wtc) | state, &wdt_reg); | ||
| 115 | } | ||
| 116 | |||
| 117 | static void rc32434_wdt_reset(void) | ||
| 118 | { | ||
| 119 | ticks = rc32434_wdt_device.default_ticks; | ||
| 120 | } | ||
| 121 | |||
| 122 | static void rc32434_wdt_update(unsigned long unused) | ||
| 123 | { | ||
| 124 | if (rc32434_wdt_device.running) | ||
| 125 | ticks--; | ||
| 126 | |||
| 127 | writel(0, &wdt_reg->wtcount); | ||
| 128 | |||
| 129 | if (rc32434_wdt_device.queue && ticks) | ||
| 130 | mod_timer(&rc32434_wdt_device.timer, | ||
| 131 | jiffies + RC32434_WDT_INTERVAL); | ||
| 132 | else | ||
| 133 | complete(&rc32434_wdt_device.stop); | ||
| 134 | } | ||
| 135 | |||
| 136 | static int rc32434_wdt_open(struct inode *inode, struct file *file) | ||
| 137 | { | ||
| 138 | if (test_and_set_bit(0, &rc32434_wdt_device.inuse)) | ||
| 139 | return -EBUSY; | ||
| 140 | |||
| 141 | if (nowayout) | ||
| 142 | __module_get(THIS_MODULE); | ||
| 143 | |||
| 144 | return nonseekable_open(inode, file); | ||
| 145 | } | ||
| 146 | |||
| 147 | static int rc32434_wdt_release(struct inode *inode, struct file *file) | ||
| 148 | { | ||
| 149 | if (expect_close && nowayout == 0) { | ||
| 150 | rc32434_wdt_stop(); | ||
| 151 | printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n"); | ||
| 152 | module_put(THIS_MODULE); | ||
| 153 | } else | ||
| 154 | printk(KERN_CRIT KBUILD_MODNAME | ||
| 155 | ": device closed unexpectedly. WDT will not stop !\n"); | ||
| 156 | |||
| 157 | clear_bit(0, &rc32434_wdt_device.inuse); | ||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | static ssize_t rc32434_wdt_write(struct file *file, const char *data, | ||
| 162 | size_t len, loff_t *ppos) | ||
| 163 | { | ||
| 164 | if (len) { | ||
| 165 | if (!nowayout) { | ||
| 166 | size_t i; | ||
| 167 | |||
| 168 | /* In case it was set long ago */ | ||
| 169 | expect_close = 0; | ||
| 170 | |||
| 171 | for (i = 0; i != len; i++) { | ||
| 172 | char c; | ||
| 173 | if (get_user(c, data + i)) | ||
| 174 | return -EFAULT; | ||
| 175 | if (c == 'V') | ||
| 176 | expect_close = 1; | ||
| 177 | } | ||
| 178 | } | ||
| 179 | rc32434_wdt_update(0); | ||
| 180 | return len; | ||
| 181 | } | ||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | static int rc32434_wdt_ioctl(struct inode *inode, struct file *file, | ||
| 186 | unsigned int cmd, unsigned long arg) | ||
| 187 | { | ||
| 188 | void __user *argp = (void __user *)arg; | ||
| 189 | int new_timeout; | ||
| 190 | unsigned int value; | ||
| 191 | static struct watchdog_info ident = { | ||
| 192 | .options = WDIOF_SETTIMEOUT | | ||
| 193 | WDIOF_KEEPALIVEPING | | ||
| 194 | WDIOF_MAGICCLOSE, | ||
| 195 | .identity = "RC32434_WDT Watchdog", | ||
| 196 | }; | ||
| 197 | switch (cmd) { | ||
| 198 | case WDIOC_KEEPALIVE: | ||
| 199 | rc32434_wdt_reset(); | ||
| 200 | break; | ||
| 201 | case WDIOC_GETSTATUS: | ||
| 202 | case WDIOC_GETBOOTSTATUS: | ||
| 203 | value = readl(&wdt_reg->wtcount); | ||
| 204 | if (copy_to_user(argp, &value, sizeof(int))) | ||
| 205 | return -EFAULT; | ||
| 206 | break; | ||
| 207 | case WDIOC_GETSUPPORT: | ||
| 208 | if (copy_to_user(argp, &ident, sizeof(ident))) | ||
| 209 | return -EFAULT; | ||
| 210 | break; | ||
| 211 | case WDIOC_SETOPTIONS: | ||
| 212 | if (copy_from_user(&value, argp, sizeof(int))) | ||
| 213 | return -EFAULT; | ||
| 214 | switch (value) { | ||
| 215 | case WDIOS_ENABLECARD: | ||
| 216 | rc32434_wdt_start(); | ||
| 217 | break; | ||
| 218 | case WDIOS_DISABLECARD: | ||
| 219 | rc32434_wdt_stop(); | ||
| 220 | default: | ||
| 221 | return -EINVAL; | ||
| 222 | } | ||
| 223 | break; | ||
| 224 | case WDIOC_SETTIMEOUT: | ||
| 225 | if (copy_from_user(&new_timeout, argp, sizeof(int))) | ||
| 226 | return -EFAULT; | ||
| 227 | if (new_timeout < 1) | ||
| 228 | return -EINVAL; | ||
| 229 | if (new_timeout > MAX_TIMEOUT) | ||
| 230 | return -EINVAL; | ||
| 231 | rc32434_wdt_set(new_timeout); | ||
| 232 | case WDIOC_GETTIMEOUT: | ||
| 233 | return copy_to_user(argp, &timeout, sizeof(int)); | ||
| 234 | default: | ||
| 235 | return -ENOTTY; | ||
| 236 | } | ||
| 237 | |||
| 238 | return 0; | ||
| 239 | } | ||
| 240 | |||
| 241 | static struct file_operations rc32434_wdt_fops = { | ||
| 242 | .owner = THIS_MODULE, | ||
| 243 | .llseek = no_llseek, | ||
| 244 | .write = rc32434_wdt_write, | ||
| 245 | .ioctl = rc32434_wdt_ioctl, | ||
| 246 | .open = rc32434_wdt_open, | ||
| 247 | .release = rc32434_wdt_release, | ||
| 248 | }; | ||
| 249 | |||
| 250 | static struct miscdevice rc32434_wdt_miscdev = { | ||
| 251 | .minor = WATCHDOG_MINOR, | ||
| 252 | .name = "watchdog", | ||
| 253 | .fops = &rc32434_wdt_fops, | ||
| 254 | }; | ||
| 255 | |||
| 256 | static char banner[] = KERN_INFO KBUILD_MODNAME | ||
| 257 | ": Watchdog Timer version " VERSION ", timer margin: %d sec\n"; | ||
| 258 | |||
| 259 | static int rc32434_wdt_probe(struct platform_device *pdev) | ||
| 260 | { | ||
| 261 | int ret; | ||
| 262 | struct resource *r; | ||
| 263 | |||
| 264 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb500_wdt_res"); | ||
| 265 | if (!r) { | ||
| 266 | printk(KERN_ERR KBUILD_MODNAME | ||
| 267 | "failed to retrieve resources\n"); | ||
| 268 | return -ENODEV; | ||
| 269 | } | ||
| 270 | |||
| 271 | wdt_reg = ioremap_nocache(r->start, r->end - r->start); | ||
| 272 | if (!wdt_reg) { | ||
| 273 | printk(KERN_ERR KBUILD_MODNAME | ||
| 274 | "failed to remap I/O resources\n"); | ||
| 275 | return -ENXIO; | ||
| 276 | } | ||
| 277 | |||
| 278 | ret = misc_register(&rc32434_wdt_miscdev); | ||
| 279 | |||
| 280 | if (ret < 0) { | ||
| 281 | printk(KERN_ERR KBUILD_MODNAME | ||
| 282 | "failed to register watchdog device\n"); | ||
| 283 | goto unmap; | ||
| 284 | } | ||
| 285 | |||
| 286 | init_completion(&rc32434_wdt_device.stop); | ||
| 287 | rc32434_wdt_device.queue = 0; | ||
| 288 | |||
| 289 | clear_bit(0, &rc32434_wdt_device.inuse); | ||
| 290 | |||
| 291 | setup_timer(&rc32434_wdt_device.timer, rc32434_wdt_update, 0L); | ||
| 292 | |||
| 293 | rc32434_wdt_device.default_ticks = ticks; | ||
| 294 | |||
| 295 | rc32434_wdt_start(); | ||
| 296 | |||
| 297 | printk(banner, timeout); | ||
| 298 | |||
| 299 | return 0; | ||
| 300 | |||
| 301 | unmap: | ||
| 302 | iounmap(wdt_reg); | ||
| 303 | return ret; | ||
| 304 | } | ||
| 305 | |||
| 306 | static int rc32434_wdt_remove(struct platform_device *pdev) | ||
| 307 | { | ||
| 308 | if (rc32434_wdt_device.queue) { | ||
| 309 | rc32434_wdt_device.queue = 0; | ||
| 310 | wait_for_completion(&rc32434_wdt_device.stop); | ||
| 311 | } | ||
| 312 | misc_deregister(&rc32434_wdt_miscdev); | ||
| 313 | |||
| 314 | iounmap(wdt_reg); | ||
| 315 | |||
| 316 | return 0; | ||
| 317 | } | ||
| 318 | |||
| 319 | static struct platform_driver rc32434_wdt = { | ||
| 320 | .probe = rc32434_wdt_probe, | ||
| 321 | .remove = rc32434_wdt_remove, | ||
| 322 | .driver = { | ||
| 323 | .name = "rc32434_wdt", | ||
| 324 | } | ||
| 325 | }; | ||
| 326 | |||
| 327 | static int __init rc32434_wdt_init(void) | ||
| 328 | { | ||
| 329 | return platform_driver_register(&rc32434_wdt); | ||
| 330 | } | ||
| 331 | |||
| 332 | static void __exit rc32434_wdt_exit(void) | ||
| 333 | { | ||
| 334 | platform_driver_unregister(&rc32434_wdt); | ||
| 335 | } | ||
| 336 | |||
| 337 | module_init(rc32434_wdt_init); | ||
| 338 | module_exit(rc32434_wdt_exit); | ||
| 339 | |||
| 340 | MODULE_AUTHOR("Ondrej Zajicek <santiago@crfreenet.org>," | ||
| 341 | "Florian Fainelli <florian@openwrt.org>"); | ||
| 342 | MODULE_DESCRIPTION("Driver for the IDT RC32434 SoC watchdog"); | ||
| 343 | MODULE_LICENSE("GPL"); | ||
| 344 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c new file mode 100644 index 000000000000..9108efa73e7d --- /dev/null +++ b/drivers/watchdog/rdc321x_wdt.c | |||
| @@ -0,0 +1,285 @@ | |||
| 1 | /* | ||
| 2 | * RDC321x watchdog driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> | ||
| 5 | * | ||
| 6 | * This driver is highly inspired from the cpu5_wdt driver | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 21 | * | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/moduleparam.h> | ||
| 26 | #include <linux/types.h> | ||
| 27 | #include <linux/errno.h> | ||
| 28 | #include <linux/miscdevice.h> | ||
| 29 | #include <linux/fs.h> | ||
| 30 | #include <linux/init.h> | ||
| 31 | #include <linux/ioport.h> | ||
| 32 | #include <linux/timer.h> | ||
| 33 | #include <linux/completion.h> | ||
| 34 | #include <linux/jiffies.h> | ||
| 35 | #include <linux/platform_device.h> | ||
| 36 | #include <linux/watchdog.h> | ||
| 37 | #include <linux/io.h> | ||
| 38 | #include <linux/uaccess.h> | ||
| 39 | |||
| 40 | #include <asm/mach-rdc321x/rdc321x_defs.h> | ||
| 41 | |||
| 42 | #define RDC_WDT_MASK 0x80000000 /* Mask */ | ||
| 43 | #define RDC_WDT_EN 0x00800000 /* Enable bit */ | ||
| 44 | #define RDC_WDT_WTI 0x00200000 /* Generate CPU reset/NMI/WDT on timeout */ | ||
| 45 | #define RDC_WDT_RST 0x00100000 /* Reset bit */ | ||
| 46 | #define RDC_WDT_WIF 0x00040000 /* WDT IRQ Flag */ | ||
| 47 | #define RDC_WDT_IRT 0x00000100 /* IRQ Routing table */ | ||
| 48 | #define RDC_WDT_CNT 0x00000001 /* WDT count */ | ||
| 49 | |||
| 50 | #define RDC_CLS_TMR 0x80003844 /* Clear timer */ | ||
| 51 | |||
| 52 | #define RDC_WDT_INTERVAL (HZ/10+1) | ||
| 53 | |||
| 54 | static int ticks = 1000; | ||
| 55 | |||
| 56 | /* some device data */ | ||
| 57 | |||
| 58 | static struct { | ||
| 59 | struct completion stop; | ||
| 60 | int running; | ||
| 61 | struct timer_list timer; | ||
| 62 | int queue; | ||
| 63 | int default_ticks; | ||
| 64 | unsigned long inuse; | ||
| 65 | spinlock_t lock; | ||
| 66 | } rdc321x_wdt_device; | ||
| 67 | |||
| 68 | /* generic helper functions */ | ||
| 69 | |||
| 70 | static void rdc321x_wdt_trigger(unsigned long unused) | ||
| 71 | { | ||
| 72 | unsigned long flags; | ||
| 73 | |||
| 74 | if (rdc321x_wdt_device.running) | ||
| 75 | ticks--; | ||
| 76 | |||
| 77 | /* keep watchdog alive */ | ||
| 78 | spin_lock_irqsave(&rdc321x_wdt_device.lock, flags); | ||
| 79 | outl(RDC_WDT_EN | inl(RDC3210_CFGREG_DATA), | ||
| 80 | RDC3210_CFGREG_DATA); | ||
| 81 | spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags); | ||
| 82 | |||
| 83 | /* requeue?? */ | ||
| 84 | if (rdc321x_wdt_device.queue && ticks) | ||
| 85 | mod_timer(&rdc321x_wdt_device.timer, | ||
| 86 | jiffies + RDC_WDT_INTERVAL); | ||
| 87 | else { | ||
| 88 | /* ticks doesn't matter anyway */ | ||
| 89 | complete(&rdc321x_wdt_device.stop); | ||
| 90 | } | ||
| 91 | |||
| 92 | } | ||
| 93 | |||
| 94 | static void rdc321x_wdt_reset(void) | ||
| 95 | { | ||
| 96 | ticks = rdc321x_wdt_device.default_ticks; | ||
| 97 | } | ||
| 98 | |||
| 99 | static void rdc321x_wdt_start(void) | ||
| 100 | { | ||
| 101 | unsigned long flags; | ||
| 102 | |||
| 103 | if (!rdc321x_wdt_device.queue) { | ||
| 104 | rdc321x_wdt_device.queue = 1; | ||
| 105 | |||
| 106 | /* Clear the timer */ | ||
| 107 | spin_lock_irqsave(&rdc321x_wdt_device.lock, flags); | ||
| 108 | outl(RDC_CLS_TMR, RDC3210_CFGREG_ADDR); | ||
| 109 | |||
| 110 | /* Enable watchdog and set the timeout to 81.92 us */ | ||
| 111 | outl(RDC_WDT_EN | RDC_WDT_CNT, RDC3210_CFGREG_DATA); | ||
| 112 | spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags); | ||
| 113 | |||
| 114 | mod_timer(&rdc321x_wdt_device.timer, | ||
| 115 | jiffies + RDC_WDT_INTERVAL); | ||
| 116 | } | ||
| 117 | |||
| 118 | /* if process dies, counter is not decremented */ | ||
| 119 | rdc321x_wdt_device.running++; | ||
| 120 | } | ||
| 121 | |||
| 122 | static int rdc321x_wdt_stop(void) | ||
| 123 | { | ||
| 124 | if (rdc321x_wdt_device.running) | ||
| 125 | rdc321x_wdt_device.running = 0; | ||
| 126 | |||
| 127 | ticks = rdc321x_wdt_device.default_ticks; | ||
| 128 | |||
| 129 | return -EIO; | ||
| 130 | } | ||
| 131 | |||
| 132 | /* filesystem operations */ | ||
| 133 | static int rdc321x_wdt_open(struct inode *inode, struct file *file) | ||
| 134 | { | ||
| 135 | if (test_and_set_bit(0, &rdc321x_wdt_device.inuse)) | ||
| 136 | return -EBUSY; | ||
| 137 | |||
| 138 | return nonseekable_open(inode, file); | ||
| 139 | } | ||
| 140 | |||
| 141 | static int rdc321x_wdt_release(struct inode *inode, struct file *file) | ||
| 142 | { | ||
| 143 | clear_bit(0, &rdc321x_wdt_device.inuse); | ||
| 144 | return 0; | ||
| 145 | } | ||
| 146 | |||
| 147 | static int rdc321x_wdt_ioctl(struct inode *inode, struct file *file, | ||
| 148 | unsigned int cmd, unsigned long arg) | ||
| 149 | { | ||
| 150 | void __user *argp = (void __user *)arg; | ||
| 151 | unsigned int value; | ||
| 152 | static struct watchdog_info ident = { | ||
| 153 | .options = WDIOF_CARDRESET, | ||
| 154 | .identity = "RDC321x WDT", | ||
| 155 | }; | ||
| 156 | unsigned long flags; | ||
| 157 | |||
| 158 | switch (cmd) { | ||
| 159 | case WDIOC_KEEPALIVE: | ||
| 160 | rdc321x_wdt_reset(); | ||
| 161 | break; | ||
| 162 | case WDIOC_GETSTATUS: | ||
| 163 | /* Read the value from the DATA register */ | ||
| 164 | spin_lock_irqsave(&rdc321x_wdt_device.lock, flags); | ||
| 165 | value = inl(RDC3210_CFGREG_DATA); | ||
| 166 | spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags); | ||
| 167 | if (copy_to_user(argp, &value, sizeof(int))) | ||
| 168 | return -EFAULT; | ||
| 169 | break; | ||
| 170 | case WDIOC_GETSUPPORT: | ||
| 171 | if (copy_to_user(argp, &ident, sizeof(ident))) | ||
| 172 | return -EFAULT; | ||
| 173 | break; | ||
| 174 | case WDIOC_SETOPTIONS: | ||
| 175 | if (copy_from_user(&value, argp, sizeof(int))) | ||
| 176 | return -EFAULT; | ||
| 177 | switch (value) { | ||
| 178 | case WDIOS_ENABLECARD: | ||
| 179 | rdc321x_wdt_start(); | ||
| 180 | break; | ||
| 181 | case WDIOS_DISABLECARD: | ||
| 182 | return rdc321x_wdt_stop(); | ||
| 183 | default: | ||
| 184 | return -EINVAL; | ||
| 185 | } | ||
| 186 | break; | ||
| 187 | default: | ||
| 188 | return -ENOTTY; | ||
| 189 | } | ||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | |||
| 193 | static ssize_t rdc321x_wdt_write(struct file *file, const char __user *buf, | ||
| 194 | size_t count, loff_t *ppos) | ||
| 195 | { | ||
| 196 | if (!count) | ||
| 197 | return -EIO; | ||
| 198 | |||
| 199 | rdc321x_wdt_reset(); | ||
| 200 | |||
| 201 | return count; | ||
| 202 | } | ||
| 203 | |||
| 204 | static const struct file_operations rdc321x_wdt_fops = { | ||
| 205 | .owner = THIS_MODULE, | ||
| 206 | .llseek = no_llseek, | ||
| 207 | .ioctl = rdc321x_wdt_ioctl, | ||
| 208 | .open = rdc321x_wdt_open, | ||
| 209 | .write = rdc321x_wdt_write, | ||
| 210 | .release = rdc321x_wdt_release, | ||
| 211 | }; | ||
| 212 | |||
| 213 | static struct miscdevice rdc321x_wdt_misc = { | ||
| 214 | .minor = WATCHDOG_MINOR, | ||
| 215 | .name = "watchdog", | ||
| 216 | .fops = &rdc321x_wdt_fops, | ||
| 217 | }; | ||
| 218 | |||
| 219 | static int __devinit rdc321x_wdt_probe(struct platform_device *pdev) | ||
| 220 | { | ||
| 221 | int err; | ||
| 222 | |||
| 223 | err = misc_register(&rdc321x_wdt_misc); | ||
| 224 | if (err < 0) { | ||
| 225 | printk(KERN_ERR PFX "watchdog misc_register failed\n"); | ||
| 226 | return err; | ||
| 227 | } | ||
| 228 | |||
| 229 | spin_lock_init(&rdc321x_wdt_device.lock); | ||
| 230 | |||
| 231 | /* Reset the watchdog */ | ||
| 232 | outl(RDC_WDT_RST, RDC3210_CFGREG_DATA); | ||
| 233 | |||
| 234 | init_completion(&rdc321x_wdt_device.stop); | ||
| 235 | rdc321x_wdt_device.queue = 0; | ||
| 236 | |||
| 237 | clear_bit(0, &rdc321x_wdt_device.inuse); | ||
| 238 | |||
| 239 | setup_timer(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0); | ||
| 240 | |||
| 241 | rdc321x_wdt_device.default_ticks = ticks; | ||
| 242 | |||
| 243 | printk(KERN_INFO PFX "watchdog init success\n"); | ||
| 244 | |||
| 245 | return 0; | ||
| 246 | } | ||
| 247 | |||
| 248 | static int rdc321x_wdt_remove(struct platform_device *pdev) | ||
| 249 | { | ||
| 250 | if (rdc321x_wdt_device.queue) { | ||
| 251 | rdc321x_wdt_device.queue = 0; | ||
| 252 | wait_for_completion(&rdc321x_wdt_device.stop); | ||
| 253 | } | ||
| 254 | |||
| 255 | misc_deregister(&rdc321x_wdt_misc); | ||
| 256 | |||
| 257 | return 0; | ||
| 258 | } | ||
| 259 | |||
| 260 | static struct platform_driver rdc321x_wdt_driver = { | ||
| 261 | .probe = rdc321x_wdt_probe, | ||
| 262 | .remove = rdc321x_wdt_remove, | ||
| 263 | .driver = { | ||
| 264 | .owner = THIS_MODULE, | ||
| 265 | .name = "rdc321x-wdt", | ||
| 266 | }, | ||
| 267 | }; | ||
| 268 | |||
| 269 | static int __init rdc321x_wdt_init(void) | ||
| 270 | { | ||
| 271 | return platform_driver_register(&rdc321x_wdt_driver); | ||
| 272 | } | ||
| 273 | |||
| 274 | static void __exit rdc321x_wdt_exit(void) | ||
| 275 | { | ||
| 276 | platform_driver_unregister(&rdc321x_wdt_driver); | ||
| 277 | } | ||
| 278 | |||
| 279 | module_init(rdc321x_wdt_init); | ||
| 280 | module_exit(rdc321x_wdt_exit); | ||
| 281 | |||
| 282 | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); | ||
| 283 | MODULE_DESCRIPTION("RDC321x watchdog driver"); | ||
| 284 | MODULE_LICENSE("GPL"); | ||
| 285 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 22715e3be5e7..86d42801de45 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c | |||
| @@ -21,18 +21,6 @@ | |||
| 21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | * | ||
| 25 | * Changelog: | ||
| 26 | * 05-Oct-2004 BJD Added semaphore init to stop crashes on open | ||
| 27 | * Fixed tmr_count / wdt_count confusion | ||
| 28 | * Added configurable debug | ||
| 29 | * | ||
| 30 | * 11-Jan-2005 BJD Fixed divide-by-2 in timeout code | ||
| 31 | * | ||
| 32 | * 25-Jan-2005 DA Added suspend/resume support | ||
| 33 | * Replaced reboot notifier with .shutdown method | ||
| 34 | * | ||
| 35 | * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA | ||
| 36 | */ | 24 | */ |
| 37 | 25 | ||
| 38 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| @@ -365,7 +353,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
| 365 | return -ENOENT; | 353 | return -ENOENT; |
| 366 | } | 354 | } |
| 367 | 355 | ||
| 368 | size = (res->end-res->start)+1; | 356 | size = (res->end - res->start) + 1; |
| 369 | wdt_mem = request_mem_region(res->start, size, pdev->name); | 357 | wdt_mem = request_mem_region(res->start, size, pdev->name); |
| 370 | if (wdt_mem == NULL) { | 358 | if (wdt_mem == NULL) { |
| 371 | dev_err(dev, "failed to get memory region\n"); | 359 | dev_err(dev, "failed to get memory region\n"); |
| @@ -374,7 +362,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
| 374 | } | 362 | } |
| 375 | 363 | ||
| 376 | wdt_base = ioremap(res->start, size); | 364 | wdt_base = ioremap(res->start, size); |
| 377 | if (wdt_base == 0) { | 365 | if (wdt_base == NULL) { |
| 378 | dev_err(dev, "failed to ioremap() region\n"); | 366 | dev_err(dev, "failed to ioremap() region\n"); |
| 379 | ret = -EINVAL; | 367 | ret = -EINVAL; |
| 380 | goto err_req; | 368 | goto err_req; |
