Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.git] / drivers / char / watchdog / wdt_pci.c
1 /*
2  *      Industrial Computer Source PCI-WDT500/501 driver
3  *
4  *      (c) Copyright 1996-1997 Alan Cox <alan@redhat.com>, All Rights Reserved.
5  *                              http://www.redhat.com
6  *
7  *      This program is free software; you can redistribute it and/or
8  *      modify it under the terms of the GNU General Public License
9  *      as published by the Free Software Foundation; either version
10  *      2 of the License, or (at your option) any later version.
11  *
12  *      Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
13  *      warranty for any of this software. This material is provided
14  *      "AS-IS" and at no charge.
15  *
16  *      (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
17  *
18  *      Release 0.10.
19  *
20  *      Fixes
21  *              Dave Gregorich  :       Modularisation and minor bugs
22  *              Alan Cox        :       Added the watchdog ioctl() stuff
23  *              Alan Cox        :       Fixed the reboot problem (as noted by
24  *                                      Matt Crocker).
25  *              Alan Cox        :       Added wdt= boot option
26  *              Alan Cox        :       Cleaned up copy/user stuff
27  *              Tim Hockin      :       Added insmod parameters, comment cleanup
28  *                                      Parameterized timeout
29  *              JP Nollmann     :       Added support for PCI wdt501p
30  *              Alan Cox        :       Split ISA and PCI cards into two drivers
31  *              Jeff Garzik     :       PCI cleanups
32  *              Tigran Aivazian :       Restructured wdtpci_init_one() to handle failures
33  *              Joel Becker     :       Added WDIOC_GET/SETTIMEOUT
34  *              Zwane Mwaikambo :       Magic char closing, locking changes, cleanups
35  *              Matt Domsch     :       nowayout module option
36  */
37
38 #include <linux/config.h>
39 #include <linux/interrupt.h>
40 #include <linux/module.h>
41 #include <linux/moduleparam.h>
42 #include <linux/types.h>
43 #include <linux/miscdevice.h>
44 #include <linux/watchdog.h>
45 #include <linux/ioport.h>
46 #include <linux/notifier.h>
47 #include <linux/reboot.h>
48 #include <linux/init.h>
49 #include <linux/fs.h>
50 #include <linux/pci.h>
51
52 #include <asm/io.h>
53 #include <asm/uaccess.h>
54 #include <asm/system.h>
55
56 #define WDT_IS_PCI
57 #include "wd501p.h"
58
59 #define PFX "wdt_pci: "
60
61 /*
62  * Until Access I/O gets their application for a PCI vendor ID approved,
63  * I don't think that it's appropriate to move these constants into the
64  * regular pci_ids.h file. -- JPN 2000/01/18
65  */
66
67 #ifndef PCI_VENDOR_ID_ACCESSIO
68 #define PCI_VENDOR_ID_ACCESSIO 0x494f
69 #endif
70 #ifndef PCI_DEVICE_ID_WDG_CSM
71 #define PCI_DEVICE_ID_WDG_CSM 0x22c0
72 #endif
73
74 /* We can only use 1 card due to the /dev/watchdog restriction */
75 static int dev_count;
76
77 static struct semaphore open_sem;
78 static spinlock_t wdtpci_lock;
79 static char expect_close;
80
81 static int io;
82 static int irq;
83
84 /* Default timeout */
85 #define WD_TIMO 60                      /* Default heartbeat = 60 seconds */
86
87 static int heartbeat = WD_TIMO;
88 static int wd_heartbeat;
89 module_param(heartbeat, int, 0);
90 MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WD_TIMO) ")");
91
92 static int nowayout = WATCHDOG_NOWAYOUT;
93 module_param(nowayout, int, 0);
94 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
95
96 #ifdef CONFIG_WDT_501_PCI
97 /* Support for the Fan Tachometer on the PCI-WDT501 */
98 static int tachometer;
99
100 module_param(tachometer, int, 0);
101 MODULE_PARM_DESC(tachometer, "PCI-WDT501 Fan Tachometer support (0=disable, default=0)");
102 #endif /* CONFIG_WDT_501_PCI */
103
104 /*
105  *      Programming support
106  */
107
108 static void wdtpci_ctr_mode(int ctr, int mode)
109 {
110         ctr<<=6;
111         ctr|=0x30;
112         ctr|=(mode<<1);
113         outb_p(ctr, WDT_CR);
114 }
115
116 static void wdtpci_ctr_load(int ctr, int val)
117 {
118         outb_p(val&0xFF, WDT_COUNT0+ctr);
119         outb_p(val>>8, WDT_COUNT0+ctr);
120 }
121
122 /**
123  *      wdtpci_start:
124  *
125  *      Start the watchdog driver.
126  */
127
128 static int wdtpci_start(void)
129 {
130         unsigned long flags;
131
132         spin_lock_irqsave(&wdtpci_lock, flags);
133
134         /*
135          * "pet" the watchdog, as Access says.
136          * This resets the clock outputs.
137          */
138         inb_p(WDT_DC);                  /* Disable watchdog */
139         wdtpci_ctr_mode(2,0);           /* Program CTR2 for Mode 0: Pulse on Terminal Count */
140         outb_p(0, WDT_DC);              /* Enable watchdog */
141
142         inb_p(WDT_DC);                  /* Disable watchdog */
143         outb_p(0, WDT_CLOCK);           /* 2.0833MHz clock */
144         inb_p(WDT_BUZZER);              /* disable */
145         inb_p(WDT_OPTONOTRST);          /* disable */
146         inb_p(WDT_OPTORST);             /* disable */
147         inb_p(WDT_PROGOUT);             /* disable */
148         wdtpci_ctr_mode(0,3);           /* Program CTR0 for Mode 3: Square Wave Generator */
149         wdtpci_ctr_mode(1,2);           /* Program CTR1 for Mode 2: Rate Generator */
150         wdtpci_ctr_mode(2,1);           /* Program CTR2 for Mode 1: Retriggerable One-Shot */
151         wdtpci_ctr_load(0,20833);       /* count at 100Hz */
152         wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */
153         /* DO NOT LOAD CTR2 on PCI card! -- JPN */
154         outb_p(0, WDT_DC);              /* Enable watchdog */
155
156         spin_unlock_irqrestore(&wdtpci_lock, flags);
157         return 0;
158 }
159
160 /**
161  *      wdtpci_stop:
162  *
163  *      Stop the watchdog driver.
164  */
165
166 static int wdtpci_stop (void)
167 {
168         unsigned long flags;
169
170         /* Turn the card off */
171         spin_lock_irqsave(&wdtpci_lock, flags);
172         inb_p(WDT_DC);                  /* Disable watchdog */
173         wdtpci_ctr_load(2,0);           /* 0 length reset pulses now */
174         spin_unlock_irqrestore(&wdtpci_lock, flags);
175         return 0;
176 }
177
178 /**
179  *      wdtpci_ping:
180  *
181  *      Reload counter one with the watchdog heartbeat. We don't bother reloading
182  *      the cascade counter.
183  */
184
185 static int wdtpci_ping(void)
186 {
187         unsigned long flags;
188
189         /* Write a watchdog value */
190         spin_lock_irqsave(&wdtpci_lock, flags);
191         inb_p(WDT_DC);                  /* Disable watchdog */
192         wdtpci_ctr_mode(1,2);           /* Re-Program CTR1 for Mode 2: Rate Generator */
193         wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */
194         outb_p(0, WDT_DC);              /* Enable watchdog */
195         spin_unlock_irqrestore(&wdtpci_lock, flags);
196         return 0;
197 }
198
199 /**
200  *      wdtpci_set_heartbeat:
201  *      @t:             the new heartbeat value that needs to be set.
202  *
203  *      Set a new heartbeat value for the watchdog device. If the heartbeat value is
204  *      incorrect we keep the old value and return -EINVAL. If successfull we
205  *      return 0.
206  */
207 static int wdtpci_set_heartbeat(int t)
208 {
209         /* Arbitrary, can't find the card's limits */
210         if ((t < 1) || (t > 65535))
211                 return -EINVAL;
212
213         heartbeat = t;
214         wd_heartbeat = t * 100;
215         return 0;
216 }
217
218 /**
219  *      wdtpci_get_status:
220  *      @status:                the new status.
221  *
222  *      Extract the status information from a WDT watchdog device. There are
223  *      several board variants so we have to know which bits are valid. Some
224  *      bits default to one and some to zero in order to be maximally painful.
225  *
226  *      we then map the bits onto the status ioctl flags.
227  */
228
229 static int wdtpci_get_status(int *status)
230 {
231         unsigned char new_status=inb_p(WDT_SR);
232
233         *status=0;
234         if (new_status & WDC_SR_ISOI0)
235                 *status |= WDIOF_EXTERN1;
236         if (new_status & WDC_SR_ISII1)
237                 *status |= WDIOF_EXTERN2;
238 #ifdef CONFIG_WDT_501_PCI
239         if (!(new_status & WDC_SR_TGOOD))
240                 *status |= WDIOF_OVERHEAT;
241         if (!(new_status & WDC_SR_PSUOVER))
242                 *status |= WDIOF_POWEROVER;
243         if (!(new_status & WDC_SR_PSUUNDR))
244                 *status |= WDIOF_POWERUNDER;
245         if (tachometer) {
246                 if (!(new_status & WDC_SR_FANGOOD))
247                         *status |= WDIOF_FANFAULT;
248         }
249 #endif /* CONFIG_WDT_501_PCI */
250         return 0;
251 }
252
253 #ifdef CONFIG_WDT_501_PCI
254 /**
255  *      wdtpci_get_temperature:
256  *
257  *      Reports the temperature in degrees Fahrenheit. The API is in
258  *      farenheit. It was designed by an imperial measurement luddite.
259  */
260
261 static int wdtpci_get_temperature(int *temperature)
262 {
263         unsigned short c=inb_p(WDT_RT);
264
265         *temperature = (c * 11 / 15) + 7;
266         return 0;
267 }
268 #endif /* CONFIG_WDT_501_PCI */
269
270 /**
271  *      wdtpci_interrupt:
272  *      @irq:           Interrupt number
273  *      @dev_id:        Unused as we don't allow multiple devices.
274  *      @regs:          Unused.
275  *
276  *      Handle an interrupt from the board. These are raised when the status
277  *      map changes in what the board considers an interesting way. That means
278  *      a failure condition occurring.
279  */
280
281 static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
282 {
283         /*
284          *      Read the status register see what is up and
285          *      then printk it.
286          */
287         unsigned char status=inb_p(WDT_SR);
288
289         printk(KERN_CRIT PFX "status %d\n", status);
290
291 #ifdef CONFIG_WDT_501_PCI
292         if (!(status & WDC_SR_TGOOD))
293                 printk(KERN_CRIT PFX "Overheat alarm.(%d)\n",inb_p(WDT_RT));
294         if (!(status & WDC_SR_PSUOVER))
295                 printk(KERN_CRIT PFX "PSU over voltage.\n");
296         if (!(status & WDC_SR_PSUUNDR))
297                 printk(KERN_CRIT PFX "PSU under voltage.\n");
298         if (tachometer) {
299                 if (!(status & WDC_SR_FANGOOD))
300                         printk(KERN_CRIT PFX "Possible fan fault.\n");
301         }
302 #endif /* CONFIG_WDT_501_PCI */
303         if (!(status&WDC_SR_WCCR))
304 #ifdef SOFTWARE_REBOOT
305 #ifdef ONLY_TESTING
306                 printk(KERN_CRIT PFX "Would Reboot.\n");
307 #else
308                 printk(KERN_CRIT PFX "Initiating system reboot.\n");
309                 emergency_restart(NULL);
310 #endif
311 #else
312                 printk(KERN_CRIT PFX "Reset in 5ms.\n");
313 #endif
314         return IRQ_HANDLED;
315 }
316
317
318 /**
319  *      wdtpci_write:
320  *      @file: file handle to the watchdog
321  *      @buf: buffer to write (unused as data does not matter here
322  *      @count: count of bytes
323  *      @ppos: pointer to the position to write. No seeks allowed
324  *
325  *      A write to a watchdog device is defined as a keepalive signal. Any
326  *      write of data will do, as we we don't define content meaning.
327  */
328
329 static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
330 {
331         if (count) {
332                 if (!nowayout) {
333                         size_t i;
334
335                         expect_close = 0;
336
337                         for (i = 0; i != count; i++) {
338                                 char c;
339                                 if(get_user(c, buf+i))
340                                         return -EFAULT;
341                                 if (c == 'V')
342                                         expect_close = 42;
343                         }
344                 }
345                 wdtpci_ping();
346         }
347
348         return count;
349 }
350
351 /**
352  *      wdtpci_ioctl:
353  *      @inode: inode of the device
354  *      @file: file handle to the device
355  *      @cmd: watchdog command
356  *      @arg: argument pointer
357  *
358  *      The watchdog API defines a common set of functions for all watchdogs
359  *      according to their available features. We only actually usefully support
360  *      querying capabilities and current status.
361  */
362
363 static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
364         unsigned long arg)
365 {
366         int new_heartbeat;
367         int status;
368         void __user *argp = (void __user *)arg;
369         int __user *p = argp;
370
371         static struct watchdog_info ident = {
372                 .options =              WDIOF_SETTIMEOUT|
373                                         WDIOF_MAGICCLOSE|
374                                         WDIOF_KEEPALIVEPING,
375                 .firmware_version =     1,
376                 .identity =             "PCI-WDT500/501",
377         };
378
379         /* Add options according to the card we have */
380         ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
381 #ifdef CONFIG_WDT_501_PCI
382         ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER);
383         if (tachometer)
384                 ident.options |= WDIOF_FANFAULT;
385 #endif /* CONFIG_WDT_501_PCI */
386
387         switch(cmd)
388         {
389                 default:
390                         return -ENOIOCTLCMD;
391                 case WDIOC_GETSUPPORT:
392                         return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0;
393
394                 case WDIOC_GETSTATUS:
395                         wdtpci_get_status(&status);
396                         return put_user(status, p);
397                 case WDIOC_GETBOOTSTATUS:
398                         return put_user(0, p);
399                 case WDIOC_KEEPALIVE:
400                         wdtpci_ping();
401                         return 0;
402                 case WDIOC_SETTIMEOUT:
403                         if (get_user(new_heartbeat, p))
404                                 return -EFAULT;
405
406                         if (wdtpci_set_heartbeat(new_heartbeat))
407                                 return -EINVAL;
408
409                         wdtpci_ping();
410                         /* Fall */
411                 case WDIOC_GETTIMEOUT:
412                         return put_user(heartbeat, p);
413         }
414 }
415
416 /**
417  *      wdtpci_open:
418  *      @inode: inode of device
419  *      @file: file handle to device
420  *
421  *      The watchdog device has been opened. The watchdog device is single
422  *      open and on opening we load the counters. Counter zero is a 100Hz
423  *      cascade, into counter 1 which downcounts to reboot. When the counter
424  *      triggers counter 2 downcounts the length of the reset pulse which
425  *      set set to be as long as possible.
426  */
427
428 static int wdtpci_open(struct inode *inode, struct file *file)
429 {
430         if (down_trylock(&open_sem))
431                 return -EBUSY;
432
433         if (nowayout) {
434                 __module_get(THIS_MODULE);
435         }
436         /*
437          *      Activate
438          */
439         wdtpci_start();
440         return nonseekable_open(inode, file);
441 }
442
443 /**
444  *      wdtpci_release:
445  *      @inode: inode to board
446  *      @file: file handle to board
447  *
448  *      The watchdog has a configurable API. There is a religious dispute
449  *      between people who want their watchdog to be able to shut down and
450  *      those who want to be sure if the watchdog manager dies the machine
451  *      reboots. In the former case we disable the counters, in the latter
452  *      case you have to open it again very soon.
453  */
454
455 static int wdtpci_release(struct inode *inode, struct file *file)
456 {
457         if (expect_close == 42) {
458                 wdtpci_stop();
459         } else {
460                 printk(KERN_CRIT PFX "Unexpected close, not stopping timer!");
461                 wdtpci_ping();
462         }
463         expect_close = 0;
464         up(&open_sem);
465         return 0;
466 }
467
468 #ifdef CONFIG_WDT_501_PCI
469 /**
470  *      wdtpci_temp_read:
471  *      @file: file handle to the watchdog board
472  *      @buf: buffer to write 1 byte into
473  *      @count: length of buffer
474  *      @ptr: offset (no seek allowed)
475  *
476  *      Read reports the temperature in degrees Fahrenheit. The API is in
477  *      fahrenheit. It was designed by an imperial measurement luddite.
478  */
479
480 static ssize_t wdtpci_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
481 {
482         int temperature;
483
484         if (wdtpci_get_temperature(&temperature))
485                 return -EFAULT;
486
487         if (copy_to_user (buf, &temperature, 1))
488                 return -EFAULT;
489
490         return 1;
491 }
492
493 /**
494  *      wdtpci_temp_open:
495  *      @inode: inode of device
496  *      @file: file handle to device
497  *
498  *      The temperature device has been opened.
499  */
500
501 static int wdtpci_temp_open(struct inode *inode, struct file *file)
502 {
503         return nonseekable_open(inode, file);
504 }
505
506 /**
507  *      wdtpci_temp_release:
508  *      @inode: inode to board
509  *      @file: file handle to board
510  *
511  *      The temperature device has been closed.
512  */
513
514 static int wdtpci_temp_release(struct inode *inode, struct file *file)
515 {
516         return 0;
517 }
518 #endif /* CONFIG_WDT_501_PCI */
519
520 /**
521  *      notify_sys:
522  *      @this: our notifier block
523  *      @code: the event being reported
524  *      @unused: unused
525  *
526  *      Our notifier is called on system shutdowns. We want to turn the card
527  *      off at reboot otherwise the machine will reboot again during memory
528  *      test or worse yet during the following fsck. This would suck, in fact
529  *      trust me - if it happens it does suck.
530  */
531
532 static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
533         void *unused)
534 {
535         if (code==SYS_DOWN || code==SYS_HALT) {
536                 /* Turn the card off */
537                 wdtpci_stop();
538         }
539         return NOTIFY_DONE;
540 }
541
542 /*
543  *      Kernel Interfaces
544  */
545
546
547 static struct file_operations wdtpci_fops = {
548         .owner          = THIS_MODULE,
549         .llseek         = no_llseek,
550         .write          = wdtpci_write,
551         .ioctl          = wdtpci_ioctl,
552         .open           = wdtpci_open,
553         .release        = wdtpci_release,
554 };
555
556 static struct miscdevice wdtpci_miscdev = {
557         .minor  = WATCHDOG_MINOR,
558         .name   = "watchdog",
559         .fops   = &wdtpci_fops,
560 };
561
562 #ifdef CONFIG_WDT_501_PCI
563 static struct file_operations wdtpci_temp_fops = {
564         .owner          = THIS_MODULE,
565         .llseek         = no_llseek,
566         .read           = wdtpci_temp_read,
567         .open           = wdtpci_temp_open,
568         .release        = wdtpci_temp_release,
569 };
570
571 static struct miscdevice temp_miscdev = {
572         .minor  = TEMP_MINOR,
573         .name   = "temperature",
574         .fops   = &wdtpci_temp_fops,
575 };
576 #endif /* CONFIG_WDT_501_PCI */
577
578 /*
579  *      The WDT card needs to learn about soft shutdowns in order to
580  *      turn the timebomb registers off.
581  */
582
583 static struct notifier_block wdtpci_notifier = {
584         .notifier_call = wdtpci_notify_sys,
585 };
586
587
588 static int __devinit wdtpci_init_one (struct pci_dev *dev,
589                                    const struct pci_device_id *ent)
590 {
591         int ret = -EIO;
592
593         dev_count++;
594         if (dev_count > 1) {
595                 printk (KERN_ERR PFX "this driver only supports 1 device\n");
596                 return -ENODEV;
597         }
598
599         if (pci_enable_device (dev)) {
600                 printk (KERN_ERR PFX "Not possible to enable PCI Device\n");
601                 return -ENODEV;
602         }
603
604         if (pci_resource_start (dev, 2) == 0x0000) {
605                 printk (KERN_ERR PFX "No I/O-Address for card detected\n");
606                 ret = -ENODEV;
607                 goto out_pci;
608         }
609
610         sema_init(&open_sem, 1);
611         spin_lock_init(&wdtpci_lock);
612
613         irq = dev->irq;
614         io = pci_resource_start (dev, 2);
615
616         if (request_region (io, 16, "wdt_pci") == NULL) {
617                 printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", io);
618                 goto out_pci;
619         }
620
621         if (request_irq (irq, wdtpci_interrupt, SA_INTERRUPT | SA_SHIRQ,
622                          "wdt_pci", &wdtpci_miscdev)) {
623                 printk (KERN_ERR PFX "IRQ %d is not free\n", irq);
624                 goto out_reg;
625         }
626
627         printk ("PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%04x (Interrupt %d)\n",
628                 io, irq);
629
630         /* Check that the heartbeat value is within it's range ; if not reset to the default */
631         if (wdtpci_set_heartbeat(heartbeat)) {
632                 wdtpci_set_heartbeat(WD_TIMO);
633                 printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n",
634                         WD_TIMO);
635         }
636
637         ret = register_reboot_notifier (&wdtpci_notifier);
638         if (ret) {
639                 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret);
640                 goto out_irq;
641         }
642
643 #ifdef CONFIG_WDT_501_PCI
644         ret = misc_register (&temp_miscdev);
645         if (ret) {
646                 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
647                         TEMP_MINOR, ret);
648                 goto out_rbt;
649         }
650 #endif /* CONFIG_WDT_501_PCI */
651
652         ret = misc_register (&wdtpci_miscdev);
653         if (ret) {
654                 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
655                         WATCHDOG_MINOR, ret);
656                 goto out_misc;
657         }
658
659         printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
660                 heartbeat, nowayout);
661 #ifdef CONFIG_WDT_501_PCI
662         printk(KERN_INFO "wdt: Fan Tachometer is %s\n", (tachometer ? "Enabled" : "Disabled"));
663 #endif /* CONFIG_WDT_501_PCI */
664
665         ret = 0;
666 out:
667         return ret;
668
669 out_misc:
670 #ifdef CONFIG_WDT_501_PCI
671         misc_deregister(&temp_miscdev);
672 out_rbt:
673 #endif /* CONFIG_WDT_501_PCI */
674         unregister_reboot_notifier(&wdtpci_notifier);
675 out_irq:
676         free_irq(irq, &wdtpci_miscdev);
677 out_reg:
678         release_region (io, 16);
679 out_pci:
680         pci_disable_device(dev);
681         goto out;
682 }
683
684
685 static void __devexit wdtpci_remove_one (struct pci_dev *pdev)
686 {
687         /* here we assume only one device will ever have
688          * been picked up and registered by probe function */
689         misc_deregister(&wdtpci_miscdev);
690 #ifdef CONFIG_WDT_501_PCI
691         misc_deregister(&temp_miscdev);
692 #endif /* CONFIG_WDT_501_PCI */
693         unregister_reboot_notifier(&wdtpci_notifier);
694         free_irq(irq, &wdtpci_miscdev);
695         release_region(io, 16);
696         pci_disable_device(pdev);
697         dev_count--;
698 }
699
700
701 static struct pci_device_id wdtpci_pci_tbl[] = {
702         {
703                 .vendor    = PCI_VENDOR_ID_ACCESSIO,
704                 .device    = PCI_DEVICE_ID_WDG_CSM,
705                 .subvendor = PCI_ANY_ID,
706                 .subdevice = PCI_ANY_ID,
707         },
708         { 0, }, /* terminate list */
709 };
710 MODULE_DEVICE_TABLE(pci, wdtpci_pci_tbl);
711
712
713 static struct pci_driver wdtpci_driver = {
714         .name           = "wdt_pci",
715         .id_table       = wdtpci_pci_tbl,
716         .probe          = wdtpci_init_one,
717         .remove         = __devexit_p(wdtpci_remove_one),
718 };
719
720
721 /**
722  *      wdtpci_cleanup:
723  *
724  *      Unload the watchdog. You cannot do this with any file handles open.
725  *      If your watchdog is set to continue ticking on close and you unload
726  *      it, well it keeps ticking. We won't get the interrupt but the board
727  *      will not touch PC memory so all is fine. You just have to load a new
728  *      module in xx seconds or reboot.
729  */
730
731 static void __exit wdtpci_cleanup(void)
732 {
733         pci_unregister_driver (&wdtpci_driver);
734 }
735
736
737 /**
738  *      wdtpci_init:
739  *
740  *      Set up the WDT watchdog board. All we have to do is grab the
741  *      resources we require and bitch if anyone beat us to them.
742  *      The open() function will actually kick the board off.
743  */
744
745 static int __init wdtpci_init(void)
746 {
747         return pci_register_driver (&wdtpci_driver);
748 }
749
750
751 module_init(wdtpci_init);
752 module_exit(wdtpci_cleanup);
753
754 MODULE_AUTHOR("JP Nollmann, Alan Cox");
755 MODULE_DESCRIPTION("Driver for the ICS PCI-WDT500/501 watchdog cards");
756 MODULE_LICENSE("GPL");
757 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
758 MODULE_ALIAS_MISCDEV(TEMP_MINOR);