aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c103
1 files changed, 79 insertions, 24 deletions
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index c1a5787fde5b..cbdfbf00cfb7 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -45,28 +45,29 @@
45/* Module and version information */ 45/* Module and version information */
46#define DRV_NAME "iTCO_wdt" 46#define DRV_NAME "iTCO_wdt"
47#define DRV_VERSION "1.00" 47#define DRV_VERSION "1.00"
48#define DRV_RELDATE "21-May-2006" 48#define DRV_RELDATE "18-Jun-2006"
49#define PFX DRV_NAME ": " 49#define PFX DRV_NAME ": "
50 50
51/* Includes */ 51/* Includes */
52#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */ 52#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */
53#include <linux/module.h> /* For module specific items */ 53#include <linux/module.h> /* For module specific items */
54#include <linux/moduleparam.h> /* For new moduleparam's */ 54#include <linux/moduleparam.h> /* For new moduleparam's */
55#include <linux/types.h> /* For standard types (like size_t) */ 55#include <linux/types.h> /* For standard types (like size_t) */
56#include <linux/errno.h> /* For the -ENODEV/... values */ 56#include <linux/errno.h> /* For the -ENODEV/... values */
57#include <linux/kernel.h> /* For printk/panic/... */ 57#include <linux/kernel.h> /* For printk/panic/... */
58#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ 58#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */
59#include <linux/watchdog.h> /* For the watchdog specific items */ 59#include <linux/watchdog.h> /* For the watchdog specific items */
60#include <linux/notifier.h> /* For notifier support */ 60#include <linux/notifier.h> /* For notifier support */
61#include <linux/reboot.h> /* For reboot_notifier stuff */ 61#include <linux/reboot.h> /* For reboot_notifier stuff */
62#include <linux/init.h> /* For __init/__exit/... */ 62#include <linux/init.h> /* For __init/__exit/... */
63#include <linux/fs.h> /* For file operations */ 63#include <linux/fs.h> /* For file operations */
64#include <linux/pci.h> /* For pci functions */ 64#include <linux/platform_device.h> /* For platform_driver framework */
65#include <linux/ioport.h> /* For io-port access */ 65#include <linux/pci.h> /* For pci functions */
66#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ 66#include <linux/ioport.h> /* For io-port access */
67 67#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
68#include <asm/uaccess.h> /* For copy_to_user/put_user/... */ 68
69#include <asm/io.h> /* For inb/outb/... */ 69#include <asm/uaccess.h> /* For copy_to_user/put_user/... */
70#include <asm/io.h> /* For inb/outb/... */
70 71
71/* TCO related info */ 72/* TCO related info */
72enum iTCO_chipsets { 73enum iTCO_chipsets {
@@ -166,6 +167,8 @@ static struct { /* this is private data for the iTCO_wdt device */
166 struct pci_dev *pdev; /* the PCI-device */ 167 struct pci_dev *pdev; /* the PCI-device */
167} iTCO_wdt_private; 168} iTCO_wdt_private;
168 169
170static struct platform_device *iTCO_wdt_platform_device; /* the watchdog platform device */
171
169/* module parameters */ 172/* module parameters */
170#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ 173#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */
171static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ 174static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
@@ -538,7 +541,7 @@ static struct notifier_block iTCO_wdt_notifier = {
538 * Init & exit routines 541 * Init & exit routines
539 */ 542 */
540 543
541static int __init iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent) 544static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent, struct platform_device *dev)
542{ 545{
543 int ret; 546 int ret;
544 u32 base_address; 547 u32 base_address;
@@ -649,7 +652,7 @@ out:
649 return ret; 652 return ret;
650} 653}
651 654
652static void __exit iTCO_wdt_cleanup(void) 655static void iTCO_wdt_cleanup(void)
653{ 656{
654 /* Stop the timer before we leave */ 657 /* Stop the timer before we leave */
655 if (!nowayout) 658 if (!nowayout)
@@ -663,7 +666,7 @@ static void __exit iTCO_wdt_cleanup(void)
663 iounmap(iTCO_wdt_private.gcs); 666 iounmap(iTCO_wdt_private.gcs);
664} 667}
665 668
666static int __init iTCO_wdt_init_module(void) 669static int iTCO_wdt_probe(struct platform_device *dev)
667{ 670{
668 int found = 0; 671 int found = 0;
669 struct pci_dev *pdev = NULL; 672 struct pci_dev *pdev = NULL;
@@ -674,7 +677,7 @@ static int __init iTCO_wdt_init_module(void)
674 for_each_pci_dev(pdev) { 677 for_each_pci_dev(pdev) {
675 ent = pci_match_id(iTCO_wdt_pci_tbl, pdev); 678 ent = pci_match_id(iTCO_wdt_pci_tbl, pdev);
676 if (ent) { 679 if (ent) {
677 if (!(iTCO_wdt_init(pdev, ent))) { 680 if (!(iTCO_wdt_init(pdev, ent, dev))) {
678 found++; 681 found++;
679 break; 682 break;
680 } 683 }
@@ -689,11 +692,62 @@ static int __init iTCO_wdt_init_module(void)
689 return 0; 692 return 0;
690} 693}
691 694
692static void __exit iTCO_wdt_cleanup_module(void) 695static int iTCO_wdt_remove(struct platform_device *dev)
693{ 696{
694 if (iTCO_wdt_private.ACPIBASE) 697 if (iTCO_wdt_private.ACPIBASE)
695 iTCO_wdt_cleanup(); 698 iTCO_wdt_cleanup();
696 699
700 return 0;
701}
702
703static void iTCO_wdt_shutdown(struct platform_device *dev)
704{
705 iTCO_wdt_stop();
706}
707
708#define iTCO_wdt_suspend NULL
709#define iTCO_wdt_resume NULL
710
711static struct platform_driver iTCO_wdt_driver = {
712 .probe = iTCO_wdt_probe,
713 .remove = iTCO_wdt_remove,
714 .shutdown = iTCO_wdt_shutdown,
715 .suspend = iTCO_wdt_suspend,
716 .resume = iTCO_wdt_resume,
717 .driver = {
718 .owner = THIS_MODULE,
719 .name = DRV_NAME,
720 },
721};
722
723static int __init iTCO_wdt_init_module(void)
724{
725 int err;
726
727 printk(KERN_INFO PFX "Intel TCO WatchDog Timer Driver v%s (%s)\n",
728 DRV_VERSION, DRV_RELDATE);
729
730 err = platform_driver_register(&iTCO_wdt_driver);
731 if (err)
732 return err;
733
734 iTCO_wdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0);
735 if (IS_ERR(iTCO_wdt_platform_device)) {
736 err = PTR_ERR(iTCO_wdt_platform_device);
737 goto unreg_platform_driver;
738 }
739
740 return 0;
741
742unreg_platform_driver:
743 platform_driver_unregister(&iTCO_wdt_driver);
744 return err;
745}
746
747static void __exit iTCO_wdt_cleanup_module(void)
748{
749 platform_device_unregister(iTCO_wdt_platform_device);
750 platform_driver_unregister(&iTCO_wdt_driver);
697 printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); 751 printk(KERN_INFO PFX "Watchdog Module Unloaded.\n");
698} 752}
699 753
@@ -702,5 +756,6 @@ module_exit(iTCO_wdt_cleanup_module);
702 756
703MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>"); 757MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>");
704MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver"); 758MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver");
759MODULE_VERSION(DRV_VERSION);
705MODULE_LICENSE("GPL"); 760MODULE_LICENSE("GPL");
706MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 761MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);