|
@@ -2,7 +2,7 @@
|
|
* Industrial Computer Source PCI-WDT500/501 driver
|
|
* Industrial Computer Source PCI-WDT500/501 driver
|
|
*
|
|
*
|
|
* (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
|
|
* (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
|
|
- * All Rights Reserved.
|
|
|
|
|
|
+ * All Rights Reserved.
|
|
*
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* modify it under the terms of the GNU General Public License
|
|
@@ -99,14 +99,16 @@ MODULE_PARM_DESC(nowayout,
|
|
"Watchdog cannot be stopped once started (default="
|
|
"Watchdog cannot be stopped once started (default="
|
|
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
|
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
|
|
|
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
/* Support for the Fan Tachometer on the PCI-WDT501 */
|
|
/* Support for the Fan Tachometer on the PCI-WDT501 */
|
|
static int tachometer;
|
|
static int tachometer;
|
|
-
|
|
|
|
module_param(tachometer, int, 0);
|
|
module_param(tachometer, int, 0);
|
|
MODULE_PARM_DESC(tachometer,
|
|
MODULE_PARM_DESC(tachometer,
|
|
- "PCI-WDT501 Fan Tachometer support (0=disable, default=0)");
|
|
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
+ "PCI-WDT501 Fan Tachometer support (0=disable, default=0)");
|
|
|
|
+
|
|
|
|
+static int type = 500;
|
|
|
|
+module_param(type, int, 0);
|
|
|
|
+MODULE_PARM_DESC(type,
|
|
|
|
+ "PCI-WDT501 Card type (500 or 501 , default=500)");
|
|
|
|
|
|
/*
|
|
/*
|
|
* Programming support
|
|
* Programming support
|
|
@@ -266,22 +268,21 @@ static int wdtpci_get_status(int *status)
|
|
*status |= WDIOF_EXTERN1;
|
|
*status |= WDIOF_EXTERN1;
|
|
if (new_status & WDC_SR_ISII1)
|
|
if (new_status & WDC_SR_ISII1)
|
|
*status |= WDIOF_EXTERN2;
|
|
*status |= WDIOF_EXTERN2;
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- if (!(new_status & WDC_SR_TGOOD))
|
|
|
|
- *status |= WDIOF_OVERHEAT;
|
|
|
|
- if (!(new_status & WDC_SR_PSUOVER))
|
|
|
|
- *status |= WDIOF_POWEROVER;
|
|
|
|
- if (!(new_status & WDC_SR_PSUUNDR))
|
|
|
|
- *status |= WDIOF_POWERUNDER;
|
|
|
|
- if (tachometer) {
|
|
|
|
- if (!(new_status & WDC_SR_FANGOOD))
|
|
|
|
- *status |= WDIOF_FANFAULT;
|
|
|
|
|
|
+ if (type == 501) {
|
|
|
|
+ if (!(new_status & WDC_SR_TGOOD))
|
|
|
|
+ *status |= WDIOF_OVERHEAT;
|
|
|
|
+ if (!(new_status & WDC_SR_PSUOVER))
|
|
|
|
+ *status |= WDIOF_POWEROVER;
|
|
|
|
+ if (!(new_status & WDC_SR_PSUUNDR))
|
|
|
|
+ *status |= WDIOF_POWERUNDER;
|
|
|
|
+ if (tachometer) {
|
|
|
|
+ if (!(new_status & WDC_SR_FANGOOD))
|
|
|
|
+ *status |= WDIOF_FANFAULT;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
/**
|
|
/**
|
|
* wdtpci_get_temperature:
|
|
* wdtpci_get_temperature:
|
|
*
|
|
*
|
|
@@ -300,7 +301,6 @@ static int wdtpci_get_temperature(int *temperature)
|
|
*temperature = (c * 11 / 15) + 7;
|
|
*temperature = (c * 11 / 15) + 7;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* wdtpci_interrupt:
|
|
* wdtpci_interrupt:
|
|
@@ -327,22 +327,22 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
|
|
|
|
|
|
printk(KERN_CRIT PFX "status %d\n", status);
|
|
printk(KERN_CRIT PFX "status %d\n", status);
|
|
|
|
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- if (!(status & WDC_SR_TGOOD)) {
|
|
|
|
- u8 alarm = inb(WDT_RT);
|
|
|
|
- printk(KERN_CRIT PFX "Overheat alarm.(%d)\n", alarm);
|
|
|
|
- udelay(8);
|
|
|
|
- }
|
|
|
|
- if (!(status & WDC_SR_PSUOVER))
|
|
|
|
- printk(KERN_CRIT PFX "PSU over voltage.\n");
|
|
|
|
- if (!(status & WDC_SR_PSUUNDR))
|
|
|
|
- printk(KERN_CRIT PFX "PSU under voltage.\n");
|
|
|
|
- if (tachometer) {
|
|
|
|
- if (!(status & WDC_SR_FANGOOD))
|
|
|
|
- printk(KERN_CRIT PFX "Possible fan fault.\n");
|
|
|
|
|
|
+ if (type == 501) {
|
|
|
|
+ if (!(status & WDC_SR_TGOOD)) {
|
|
|
|
+ printk(KERN_CRIT PFX "Overheat alarm.(%d)\n",
|
|
|
|
+ inb(WDT_RT));
|
|
|
|
+ udelay(8);
|
|
|
|
+ }
|
|
|
|
+ if (!(status & WDC_SR_PSUOVER))
|
|
|
|
+ printk(KERN_CRIT PFX "PSU over voltage.\n");
|
|
|
|
+ if (!(status & WDC_SR_PSUUNDR))
|
|
|
|
+ printk(KERN_CRIT PFX "PSU under voltage.\n");
|
|
|
|
+ if (tachometer) {
|
|
|
|
+ if (!(status & WDC_SR_FANGOOD))
|
|
|
|
+ printk(KERN_CRIT PFX "Possible fan fault.\n");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
- if (!(status&WDC_SR_WCCR)) {
|
|
|
|
|
|
+ if (!(status & WDC_SR_WCCR)) {
|
|
#ifdef SOFTWARE_REBOOT
|
|
#ifdef SOFTWARE_REBOOT
|
|
#ifdef ONLY_TESTING
|
|
#ifdef ONLY_TESTING
|
|
printk(KERN_CRIT PFX "Would Reboot.\n");
|
|
printk(KERN_CRIT PFX "Would Reboot.\n");
|
|
@@ -371,12 +371,13 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
|
|
*/
|
|
*/
|
|
|
|
|
|
static ssize_t wdtpci_write(struct file *file, const char __user *buf,
|
|
static ssize_t wdtpci_write(struct file *file, const char __user *buf,
|
|
- size_t count, loff_t *ppos)
|
|
|
|
|
|
+ size_t count, loff_t *ppos)
|
|
{
|
|
{
|
|
if (count) {
|
|
if (count) {
|
|
if (!nowayout) {
|
|
if (!nowayout) {
|
|
size_t i;
|
|
size_t i;
|
|
|
|
|
|
|
|
+ /* In case it was set long ago */
|
|
expect_close = 0;
|
|
expect_close = 0;
|
|
|
|
|
|
for (i = 0; i != count; i++) {
|
|
for (i = 0; i != count; i++) {
|
|
@@ -406,10 +407,10 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf,
|
|
static long wdtpci_ioctl(struct file *file, unsigned int cmd,
|
|
static long wdtpci_ioctl(struct file *file, unsigned int cmd,
|
|
unsigned long arg)
|
|
unsigned long arg)
|
|
{
|
|
{
|
|
- int new_heartbeat;
|
|
|
|
- int status;
|
|
|
|
void __user *argp = (void __user *)arg;
|
|
void __user *argp = (void __user *)arg;
|
|
int __user *p = argp;
|
|
int __user *p = argp;
|
|
|
|
+ int new_heartbeat;
|
|
|
|
+ int status;
|
|
|
|
|
|
static struct watchdog_info ident = {
|
|
static struct watchdog_info ident = {
|
|
.options = WDIOF_SETTIMEOUT|
|
|
.options = WDIOF_SETTIMEOUT|
|
|
@@ -421,11 +422,12 @@ static long wdtpci_ioctl(struct file *file, unsigned int cmd,
|
|
|
|
|
|
/* Add options according to the card we have */
|
|
/* Add options according to the card we have */
|
|
ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
|
|
ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER);
|
|
|
|
- if (tachometer)
|
|
|
|
- ident.options |= WDIOF_FANFAULT;
|
|
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
+ if (type == 501) {
|
|
|
|
+ ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|
|
|
|
|
+ WDIOF_POWEROVER);
|
|
|
|
+ if (tachometer)
|
|
|
|
+ ident.options |= WDIOF_FANFAULT;
|
|
|
|
+ }
|
|
|
|
|
|
switch (cmd) {
|
|
switch (cmd) {
|
|
case WDIOC_GETSUPPORT:
|
|
case WDIOC_GETSUPPORT:
|
|
@@ -503,7 +505,6 @@ static int wdtpci_release(struct inode *inode, struct file *file)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
/**
|
|
/**
|
|
* wdtpci_temp_read:
|
|
* wdtpci_temp_read:
|
|
* @file: file handle to the watchdog board
|
|
* @file: file handle to the watchdog board
|
|
@@ -554,7 +555,6 @@ static int wdtpci_temp_release(struct inode *inode, struct file *file)
|
|
{
|
|
{
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* notify_sys:
|
|
* notify_sys:
|
|
@@ -596,7 +596,6 @@ static struct miscdevice wdtpci_miscdev = {
|
|
.fops = &wdtpci_fops,
|
|
.fops = &wdtpci_fops,
|
|
};
|
|
};
|
|
|
|
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
static const struct file_operations wdtpci_temp_fops = {
|
|
static const struct file_operations wdtpci_temp_fops = {
|
|
.owner = THIS_MODULE,
|
|
.owner = THIS_MODULE,
|
|
.llseek = no_llseek,
|
|
.llseek = no_llseek,
|
|
@@ -610,7 +609,6 @@ static struct miscdevice temp_miscdev = {
|
|
.name = "temperature",
|
|
.name = "temperature",
|
|
.fops = &wdtpci_temp_fops,
|
|
.fops = &wdtpci_temp_fops,
|
|
};
|
|
};
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
* The WDT card needs to learn about soft shutdowns in order to
|
|
* The WDT card needs to learn about soft shutdowns in order to
|
|
@@ -633,6 +631,11 @@ static int __devinit wdtpci_init_one(struct pci_dev *dev,
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (type != 500 && type != 501) {
|
|
|
|
+ printk(KERN_ERR PFX "unknown card type '%d'.\n", type);
|
|
|
|
+ return -ENODEV;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (pci_enable_device(dev)) {
|
|
if (pci_enable_device(dev)) {
|
|
printk(KERN_ERR PFX "Not possible to enable PCI Device\n");
|
|
printk(KERN_ERR PFX "Not possible to enable PCI Device\n");
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
@@ -678,15 +681,15 @@ static int __devinit wdtpci_init_one(struct pci_dev *dev,
|
|
goto out_irq;
|
|
goto out_irq;
|
|
}
|
|
}
|
|
|
|
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- ret = misc_register(&temp_miscdev);
|
|
|
|
- if (ret) {
|
|
|
|
- printk(KERN_ERR PFX
|
|
|
|
|
|
+ if (type == 501) {
|
|
|
|
+ ret = misc_register(&temp_miscdev);
|
|
|
|
+ if (ret) {
|
|
|
|
+ printk(KERN_ERR PFX
|
|
"cannot register miscdev on minor=%d (err=%d)\n",
|
|
"cannot register miscdev on minor=%d (err=%d)\n",
|
|
- TEMP_MINOR, ret);
|
|
|
|
- goto out_rbt;
|
|
|
|
|
|
+ TEMP_MINOR, ret);
|
|
|
|
+ goto out_rbt;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
|
|
ret = misc_register(&wdtpci_miscdev);
|
|
ret = misc_register(&wdtpci_miscdev);
|
|
if (ret) {
|
|
if (ret) {
|
|
@@ -698,20 +701,18 @@ static int __devinit wdtpci_init_one(struct pci_dev *dev,
|
|
|
|
|
|
printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
|
|
printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
|
|
heartbeat, nowayout);
|
|
heartbeat, nowayout);
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
|
|
|
|
|
|
+ if (type == 501)
|
|
|
|
+ printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
|
|
(tachometer ? "Enabled" : "Disabled"));
|
|
(tachometer ? "Enabled" : "Disabled"));
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
|
|
ret = 0;
|
|
ret = 0;
|
|
out:
|
|
out:
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
out_misc:
|
|
out_misc:
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- misc_deregister(&temp_miscdev);
|
|
|
|
|
|
+ if (type == 501)
|
|
|
|
+ misc_deregister(&temp_miscdev);
|
|
out_rbt:
|
|
out_rbt:
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
unregister_reboot_notifier(&wdtpci_notifier);
|
|
unregister_reboot_notifier(&wdtpci_notifier);
|
|
out_irq:
|
|
out_irq:
|
|
free_irq(irq, &wdtpci_miscdev);
|
|
free_irq(irq, &wdtpci_miscdev);
|
|
@@ -728,9 +729,8 @@ static void __devexit wdtpci_remove_one(struct pci_dev *pdev)
|
|
/* here we assume only one device will ever have
|
|
/* here we assume only one device will ever have
|
|
* been picked up and registered by probe function */
|
|
* been picked up and registered by probe function */
|
|
misc_deregister(&wdtpci_miscdev);
|
|
misc_deregister(&wdtpci_miscdev);
|
|
-#ifdef CONFIG_WDT_501_PCI
|
|
|
|
- misc_deregister(&temp_miscdev);
|
|
|
|
-#endif /* CONFIG_WDT_501_PCI */
|
|
|
|
|
|
+ if (type == 501)
|
|
|
|
+ misc_deregister(&temp_miscdev);
|
|
unregister_reboot_notifier(&wdtpci_notifier);
|
|
unregister_reboot_notifier(&wdtpci_notifier);
|
|
free_irq(irq, &wdtpci_miscdev);
|
|
free_irq(irq, &wdtpci_miscdev);
|
|
release_region(io, 16);
|
|
release_region(io, 16);
|