]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/char/watchdog/pcwd_pci.c
[WATCHDOG] pcwd_pci.c control status + boot-code clean-up
[mirror_ubuntu-zesty-kernel.git] / drivers / char / watchdog / pcwd_pci.c
CommitLineData
1da177e4
LT
1/*
2 * Berkshire PCI-PC Watchdog Card Driver
3 *
4 * (c) Copyright 2003 Wim Van Sebroeck <wim@iguana.be>.
5 *
6 * Based on source code of the following authors:
7 * Ken Hollis <kenji@bitgate.com>,
8 * Lindsay Harris <lindsay@bluegum.com>,
9 * Alan Cox <alan@redhat.com>,
10 * Matt Domsch <Matt_Domsch@dell.com>,
11 * Rob Radez <rob@osinvestor.com>
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 *
18 * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
19 * provide warranty for any of this software. This material is
20 * provided "AS-IS" and at no charge.
21 */
22
23/*
24 * A bells and whistles driver is available from http://www.pcwd.de/
25 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/
26 */
27
28/*
29 * Includes, defines, variables, module parameters, ...
30 */
31
c315b7e8
WVS
32#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */
33#include <linux/module.h> /* For module specific items */
34#include <linux/moduleparam.h> /* For new moduleparam's */
35#include <linux/types.h> /* For standard types (like size_t) */
36#include <linux/errno.h> /* For the -ENODEV/... values */
37#include <linux/kernel.h> /* For printk/panic/... */
38#include <linux/delay.h> /* For mdelay function */
39#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */
40#include <linux/watchdog.h> /* For the watchdog specific items */
41#include <linux/notifier.h> /* For notifier support */
42#include <linux/reboot.h> /* For reboot_notifier stuff */
43#include <linux/init.h> /* For __init/__exit/... */
44#include <linux/fs.h> /* For file operations */
45#include <linux/pci.h> /* For pci functions */
46#include <linux/ioport.h> /* For io-port access */
47#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
48
49#include <asm/uaccess.h> /* For copy_to_user/put_user/... */
50#include <asm/io.h> /* For inb/outb/... */
1da177e4
LT
51
52/* Module and version information */
a0800f6d
WVS
53#define WATCHDOG_VERSION "1.02"
54#define WATCHDOG_DATE "03 Sep 2005"
1da177e4
LT
55#define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog"
56#define WATCHDOG_NAME "pcwd_pci"
57#define PFX WATCHDOG_NAME ": "
58#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n"
59
60/* Stuff for the PCI ID's */
61#ifndef PCI_VENDOR_ID_QUICKLOGIC
62#define PCI_VENDOR_ID_QUICKLOGIC 0x11e3
63#endif
64
65#ifndef PCI_DEVICE_ID_WATCHDOG_PCIPCWD
66#define PCI_DEVICE_ID_WATCHDOG_PCIPCWD 0x5030
67#endif
68
69/*
70 * These are the defines that describe the control status bits for the
71 * PCI-PC Watchdog card.
72 */
a0800f6d
WVS
73/* Port 1 : Control Status #1 */
74#define WD_PCI_WTRP 0x01 /* Watchdog Trip status */
75#define WD_PCI_HRBT 0x02 /* Watchdog Heartbeat */
76#define WD_PCI_TTRP 0x04 /* Temperature Trip status */
77#define WD_PCI_RL2A 0x08 /* Relay 2 Active */
78#define WD_PCI_RL1A 0x10 /* Relay 1 Active */
79#define WD_PCI_R2DS 0x40 /* Relay 2 Disable Temperature-trip/reset */
80#define WD_PCI_RLY2 0x80 /* Activate Relay 2 on the board */
81/* Port 2 : Control Status #2 */
82#define WD_PCI_WDIS 0x10 /* Watchdog Disable */
83#define WD_PCI_ENTP 0x20 /* Enable Temperature Trip Reset */
84#define WD_PCI_WRSP 0x40 /* Watchdog wrote response */
85#define WD_PCI_PCMD 0x80 /* PC has sent command */
1da177e4
LT
86
87/* according to documentation max. time to process a command for the pci
88 * watchdog card is 100 ms, so we give it 150 ms to do it's job */
89#define PCI_COMMAND_TIMEOUT 150
90
91/* Watchdog's internal commands */
a0800f6d
WVS
92#define CMD_GET_STATUS 0x04
93#define CMD_GET_FIRMWARE_VERSION 0x08
94#define CMD_READ_WATCHDOG_TIMEOUT 0x18
95#define CMD_WRITE_WATCHDOG_TIMEOUT 0x19
96#define CMD_GET_CLEAR_RESET_COUNT 0x84
1da177e4
LT
97
98/* We can only use 1 card due to the /dev/watchdog restriction */
99static int cards_found;
100
101/* internal variables */
102static int temp_panic;
103static unsigned long is_active;
104static char expect_release;
a0800f6d
WVS
105static struct { /* this is private data for each PCI-PC watchdog card */
106 int supports_temp; /* Wether or not the card has a temperature device */
107 int boot_status; /* The card's boot status */
108 unsigned long io_addr; /* The cards I/O address */
109 spinlock_t io_lock; /* the lock for io operations */
110 struct pci_dev *pdev; /* the PCI-device */
1da177e4
LT
111} pcipcwd_private;
112
113/* module parameters */
114#define WATCHDOG_HEARTBEAT 2 /* 2 sec default heartbeat */
115static int heartbeat = WATCHDOG_HEARTBEAT;
116module_param(heartbeat, int, 0);
117MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
118
4bfdf378 119static int nowayout = WATCHDOG_NOWAYOUT;
1da177e4
LT
120module_param(nowayout, int, 0);
121MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
122
123/*
124 * Internal functions
125 */
126
127static int send_command(int cmd, int *msb, int *lsb)
128{
129 int got_response, count;
130
131 spin_lock(&pcipcwd_private.io_lock);
132 /* If a command requires data it should be written first.
133 * Data for commands with 8 bits of data should be written to port 4.
134 * Commands with 16 bits of data, should be written as LSB to port 4
135 * and MSB to port 5.
136 * After the required data has been written then write the command to
137 * port 6. */
138 outb_p(*lsb, pcipcwd_private.io_addr + 4);
139 outb_p(*msb, pcipcwd_private.io_addr + 5);
140 outb_p(cmd, pcipcwd_private.io_addr + 6);
141
142 /* wait till the pci card processed the command, signaled by
143 * the WRSP bit in port 2 and give it a max. timeout of
144 * PCI_COMMAND_TIMEOUT to process */
a0800f6d 145 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
1da177e4
LT
146 for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) {
147 mdelay(1);
a0800f6d 148 got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP;
1da177e4
LT
149 }
150
151 if (got_response) {
152 /* read back response */
153 *lsb = inb_p(pcipcwd_private.io_addr + 4);
154 *msb = inb_p(pcipcwd_private.io_addr + 5);
155
156 /* clear WRSP bit */
157 inb_p(pcipcwd_private.io_addr + 6);
158 }
159 spin_unlock(&pcipcwd_private.io_lock);
160
161 return got_response;
162}
163
a0800f6d
WVS
164static inline void pcipcwd_check_temperature_support(void)
165{
166 if (inb_p(pcipcwd_private.io_addr) != 0xF0)
167 pcipcwd_private.supports_temp = 1;
168}
169
170static int pcipcwd_get_option_switches(void)
171{
172 int option_switches;
173
174 option_switches = inb_p(pcipcwd_private.io_addr + 3);
175 return option_switches;
176}
177
178static void pcipcwd_show_card_info(void)
179{
180 int got_fw_rev, fw_rev_major, fw_rev_minor;
181 char fw_ver_str[20]; /* The cards firmware version */
182 int option_switches;
183
184 got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor);
185 if (got_fw_rev) {
186 sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor);
187 } else {
188 sprintf(fw_ver_str, "<card no answer>");
189 }
190
191 /* Get switch settings */
192 option_switches = pcipcwd_get_option_switches();
193
194 printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n",
195 (int) pcipcwd_private.io_addr, fw_ver_str,
196 (pcipcwd_private.supports_temp ? "with" : "without"));
197
198 printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",
199 option_switches,
200 ((option_switches & 0x10) ? "ON" : "OFF"),
201 ((option_switches & 0x08) ? "ON" : "OFF"));
202
203 if (pcipcwd_private.boot_status & WDIOF_CARDRESET)
204 printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n");
205
206 if (pcipcwd_private.boot_status & WDIOF_OVERHEAT)
207 printk(KERN_INFO PFX "Card sensed a CPU Overheat\n");
208
209 if (pcipcwd_private.boot_status == 0)
210 printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");
211}
212
1da177e4
LT
213static int pcipcwd_start(void)
214{
215 int stat_reg;
216
217 spin_lock(&pcipcwd_private.io_lock);
218 outb_p(0x00, pcipcwd_private.io_addr + 3);
219 udelay(1000);
220
221 stat_reg = inb_p(pcipcwd_private.io_addr + 2);
222 spin_unlock(&pcipcwd_private.io_lock);
223
a0800f6d 224 if (stat_reg & WD_PCI_WDIS) {
1da177e4
LT
225 printk(KERN_ERR PFX "Card timer not enabled\n");
226 return -1;
227 }
228
229 return 0;
230}
231
232static int pcipcwd_stop(void)
233{
234 int stat_reg;
235
236 spin_lock(&pcipcwd_private.io_lock);
237 outb_p(0xA5, pcipcwd_private.io_addr + 3);
238 udelay(1000);
239
240 outb_p(0xA5, pcipcwd_private.io_addr + 3);
241 udelay(1000);
242
243 stat_reg = inb_p(pcipcwd_private.io_addr + 2);
244 spin_unlock(&pcipcwd_private.io_lock);
245
a0800f6d 246 if (!(stat_reg & WD_PCI_WDIS)) {
1da177e4
LT
247 printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n");
248 return -1;
249 }
250
251 return 0;
252}
253
254static int pcipcwd_keepalive(void)
255{
256 /* Re-trigger watchdog by writing to port 0 */
a0800f6d 257 outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */
1da177e4
LT
258 return 0;
259}
260
261static int pcipcwd_set_heartbeat(int t)
262{
263 int t_msb = t / 256;
264 int t_lsb = t % 256;
265
266 if ((t < 0x0001) || (t > 0xFFFF))
267 return -EINVAL;
268
269 /* Write new heartbeat to watchdog */
270 send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb);
271
272 heartbeat = t;
273 return 0;
274}
275
276static int pcipcwd_get_status(int *status)
277{
a0800f6d 278 int control_status;
1da177e4
LT
279
280 *status=0;
a0800f6d
WVS
281 control_status = inb_p(pcipcwd_private.io_addr + 1);
282 if (control_status & WD_PCI_WTRP)
1da177e4 283 *status |= WDIOF_CARDRESET;
a0800f6d 284 if (control_status & WD_PCI_TTRP) {
1da177e4
LT
285 *status |= WDIOF_OVERHEAT;
286 if (temp_panic)
287 panic(PFX "Temperature overheat trip!\n");
288 }
289
290 return 0;
291}
292
293static int pcipcwd_clear_status(void)
294{
a0800f6d
WVS
295 int control_status;
296 int msb;
297 int reset_counter;
298
299 control_status = inb_p(pcipcwd_private.io_addr + 1);
300
301 /* clear trip status & LED and keep mode of relay 2 */
302 outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1);
303
304 /* clear reset counter */
305 msb=0;
306 reset_counter=0xff;
307 send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter);
308
1da177e4
LT
309 return 0;
310}
311
312static int pcipcwd_get_temperature(int *temperature)
313{
314 *temperature = 0;
315 if (!pcipcwd_private.supports_temp)
316 return -ENODEV;
317
a0800f6d
WVS
318 *temperature = inb_p(pcipcwd_private.io_addr);
319
1da177e4
LT
320 /*
321 * Convert celsius to fahrenheit, since this was
322 * the decided 'standard' for this return value.
323 */
a0800f6d 324 *temperature = (*temperature * 9 / 5) + 32;
1da177e4
LT
325
326 return 0;
327}
328
329/*
330 * /dev/watchdog handling
331 */
332
333static ssize_t pcipcwd_write(struct file *file, const char __user *data,
a0800f6d 334 size_t len, loff_t *ppos)
1da177e4
LT
335{
336 /* See if we got the magic character 'V' and reload the timer */
337 if (len) {
338 if (!nowayout) {
339 size_t i;
340
341 /* note: just in case someone wrote the magic character
342 * five months ago... */
343 expect_release = 0;
344
345 /* scan to see whether or not we got the magic character */
346 for (i = 0; i != len; i++) {
347 char c;
348 if(get_user(c, data+i))
349 return -EFAULT;
350 if (c == 'V')
351 expect_release = 42;
352 }
353 }
354
355 /* someone wrote to us, we should reload the timer */
356 pcipcwd_keepalive();
357 }
358 return len;
359}
360
361static int pcipcwd_ioctl(struct inode *inode, struct file *file,
362 unsigned int cmd, unsigned long arg)
363{
364 void __user *argp = (void __user *)arg;
365 int __user *p = argp;
366 static struct watchdog_info ident = {
367 .options = WDIOF_OVERHEAT |
368 WDIOF_CARDRESET |
369 WDIOF_KEEPALIVEPING |
370 WDIOF_SETTIMEOUT |
371 WDIOF_MAGICCLOSE,
372 .firmware_version = 1,
373 .identity = WATCHDOG_DRIVER_NAME,
374 };
375
376 switch (cmd) {
377 case WDIOC_GETSUPPORT:
378 return copy_to_user(argp, &ident,
379 sizeof (ident)) ? -EFAULT : 0;
380
381 case WDIOC_GETSTATUS:
382 {
383 int status;
384
385 pcipcwd_get_status(&status);
386
387 return put_user(status, p);
388 }
389
390 case WDIOC_GETBOOTSTATUS:
391 return put_user(pcipcwd_private.boot_status, p);
392
393 case WDIOC_GETTEMP:
394 {
395 int temperature;
396
397 if (pcipcwd_get_temperature(&temperature))
398 return -EFAULT;
399
400 return put_user(temperature, p);
401 }
402
403 case WDIOC_KEEPALIVE:
404 pcipcwd_keepalive();
405 return 0;
406
407 case WDIOC_SETOPTIONS:
408 {
409 int new_options, retval = -EINVAL;
410
411 if (get_user (new_options, p))
412 return -EFAULT;
413
414 if (new_options & WDIOS_DISABLECARD) {
c315b7e8
WVS
415 if (pcipcwd_stop())
416 return -EIO;
1da177e4
LT
417 retval = 0;
418 }
419
420 if (new_options & WDIOS_ENABLECARD) {
c315b7e8
WVS
421 if (pcipcwd_start())
422 return -EIO;
1da177e4
LT
423 retval = 0;
424 }
425
426 if (new_options & WDIOS_TEMPPANIC) {
427 temp_panic = 1;
428 retval = 0;
429 }
430
431 return retval;
432 }
433
434 case WDIOC_SETTIMEOUT:
435 {
436 int new_heartbeat;
437
438 if (get_user(new_heartbeat, p))
439 return -EFAULT;
440
441 if (pcipcwd_set_heartbeat(new_heartbeat))
442 return -EINVAL;
443
444 pcipcwd_keepalive();
445 /* Fall */
446 }
447
448 case WDIOC_GETTIMEOUT:
449 return put_user(heartbeat, p);
450
451 default:
452 return -ENOIOCTLCMD;
453 }
454}
455
456static int pcipcwd_open(struct inode *inode, struct file *file)
457{
458 /* /dev/watchdog can only be opened once */
a0800f6d 459 if (test_and_set_bit(0, &is_active)) {
1da177e4 460 return -EBUSY;
a0800f6d 461 }
1da177e4
LT
462
463 /* Activate */
464 pcipcwd_start();
465 pcipcwd_keepalive();
466 return nonseekable_open(inode, file);
467}
468
469static int pcipcwd_release(struct inode *inode, struct file *file)
470{
471 /*
472 * Shut off the timer.
473 */
474 if (expect_release == 42) {
475 pcipcwd_stop();
476 } else {
477 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
478 pcipcwd_keepalive();
479 }
480 expect_release = 0;
481 clear_bit(0, &is_active);
482 return 0;
483}
484
485/*
486 * /dev/temperature handling
487 */
488
489static ssize_t pcipcwd_temp_read(struct file *file, char __user *data,
490 size_t len, loff_t *ppos)
491{
492 int temperature;
493
494 if (pcipcwd_get_temperature(&temperature))
495 return -EFAULT;
496
497 if (copy_to_user (data, &temperature, 1))
498 return -EFAULT;
499
500 return 1;
501}
502
503static int pcipcwd_temp_open(struct inode *inode, struct file *file)
504{
505 if (!pcipcwd_private.supports_temp)
506 return -ENODEV;
507
508 return nonseekable_open(inode, file);
509}
510
511static int pcipcwd_temp_release(struct inode *inode, struct file *file)
512{
513 return 0;
514}
515
516/*
517 * Notify system
518 */
519
520static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
521{
522 if (code==SYS_DOWN || code==SYS_HALT) {
523 /* Turn the WDT off */
524 pcipcwd_stop();
525 }
526
527 return NOTIFY_DONE;
528}
529
530/*
531 * Kernel Interfaces
532 */
533
534static struct file_operations pcipcwd_fops = {
535 .owner = THIS_MODULE,
536 .llseek = no_llseek,
537 .write = pcipcwd_write,
538 .ioctl = pcipcwd_ioctl,
539 .open = pcipcwd_open,
540 .release = pcipcwd_release,
541};
542
543static struct miscdevice pcipcwd_miscdev = {
544 .minor = WATCHDOG_MINOR,
545 .name = "watchdog",
546 .fops = &pcipcwd_fops,
547};
548
549static struct file_operations pcipcwd_temp_fops = {
550 .owner = THIS_MODULE,
551 .llseek = no_llseek,
552 .read = pcipcwd_temp_read,
553 .open = pcipcwd_temp_open,
554 .release = pcipcwd_temp_release,
555};
556
557static struct miscdevice pcipcwd_temp_miscdev = {
558 .minor = TEMP_MINOR,
559 .name = "temperature",
560 .fops = &pcipcwd_temp_fops,
561};
562
563static struct notifier_block pcipcwd_notifier = {
564 .notifier_call = pcipcwd_notify_sys,
565};
566
567/*
568 * Init & exit routines
569 */
570
1da177e4
LT
571static int __devinit pcipcwd_card_init(struct pci_dev *pdev,
572 const struct pci_device_id *ent)
573{
574 int ret = -EIO;
1da177e4
LT
575
576 cards_found++;
577 if (cards_found == 1)
578 printk(KERN_INFO PFX DRIVER_VERSION);
579
580 if (cards_found > 1) {
581 printk(KERN_ERR PFX "This driver only supports 1 device\n");
582 return -ENODEV;
583 }
584
585 if (pci_enable_device(pdev)) {
586 printk(KERN_ERR PFX "Not possible to enable PCI Device\n");
587 return -ENODEV;
588 }
589
590 if (pci_resource_start(pdev, 0) == 0x0000) {
591 printk(KERN_ERR PFX "No I/O-Address for card detected\n");
592 ret = -ENODEV;
593 goto err_out_disable_device;
594 }
595
596 pcipcwd_private.pdev = pdev;
597 pcipcwd_private.io_addr = pci_resource_start(pdev, 0);
598
599 if (pci_request_regions(pdev, WATCHDOG_NAME)) {
600 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
601 (int) pcipcwd_private.io_addr);
602 ret = -EIO;
603 goto err_out_disable_device;
604 }
605
606 /* get the boot_status */
607 pcipcwd_get_status(&pcipcwd_private.boot_status);
608
609 /* clear the "card caused reboot" flag */
610 pcipcwd_clear_status();
611
612 /* disable card */
613 pcipcwd_stop();
614
615 /* Check whether or not the card supports the temperature device */
a0800f6d 616 pcipcwd_check_temperature_support();
1da177e4 617
a0800f6d
WVS
618 /* Show info about the card itself */
619 pcipcwd_show_card_info();
1da177e4
LT
620
621 /* Check that the heartbeat value is within it's range ; if not reset to the default */
622 if (pcipcwd_set_heartbeat(heartbeat)) {
623 pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT);
624 printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n",
625 WATCHDOG_HEARTBEAT);
626 }
627
628 ret = register_reboot_notifier(&pcipcwd_notifier);
629 if (ret != 0) {
630 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
631 ret);
632 goto err_out_release_region;
633 }
634
635 if (pcipcwd_private.supports_temp) {
636 ret = misc_register(&pcipcwd_temp_miscdev);
637 if (ret != 0) {
638 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
639 TEMP_MINOR, ret);
640 goto err_out_unregister_reboot;
641 }
642 }
643
644 ret = misc_register(&pcipcwd_miscdev);
645 if (ret != 0) {
646 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
647 WATCHDOG_MINOR, ret);
648 goto err_out_misc_deregister;
649 }
650
651 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
652 heartbeat, nowayout);
653
654 return 0;
655
656err_out_misc_deregister:
657 if (pcipcwd_private.supports_temp)
658 misc_deregister(&pcipcwd_temp_miscdev);
659err_out_unregister_reboot:
660 unregister_reboot_notifier(&pcipcwd_notifier);
661err_out_release_region:
662 pci_release_regions(pdev);
663err_out_disable_device:
664 pci_disable_device(pdev);
665 return ret;
666}
667
668static void __devexit pcipcwd_card_exit(struct pci_dev *pdev)
669{
670 /* Stop the timer before we leave */
671 if (!nowayout)
672 pcipcwd_stop();
673
674 /* Deregister */
675 misc_deregister(&pcipcwd_miscdev);
676 if (pcipcwd_private.supports_temp)
677 misc_deregister(&pcipcwd_temp_miscdev);
678 unregister_reboot_notifier(&pcipcwd_notifier);
679 pci_release_regions(pdev);
680 pci_disable_device(pdev);
681 cards_found--;
682}
683
684static struct pci_device_id pcipcwd_pci_tbl[] = {
685 { PCI_VENDOR_ID_QUICKLOGIC, PCI_DEVICE_ID_WATCHDOG_PCIPCWD,
686 PCI_ANY_ID, PCI_ANY_ID, },
687 { 0 }, /* End of list */
688};
689MODULE_DEVICE_TABLE(pci, pcipcwd_pci_tbl);
690
691static struct pci_driver pcipcwd_driver = {
692 .name = WATCHDOG_NAME,
693 .id_table = pcipcwd_pci_tbl,
694 .probe = pcipcwd_card_init,
695 .remove = __devexit_p(pcipcwd_card_exit),
696};
697
698static int __init pcipcwd_init_module(void)
699{
a0800f6d 700 spin_lock_init(&pcipcwd_private.io_lock);
1da177e4
LT
701
702 return pci_register_driver(&pcipcwd_driver);
703}
704
705static void __exit pcipcwd_cleanup_module(void)
706{
707 pci_unregister_driver(&pcipcwd_driver);
708}
709
710module_init(pcipcwd_init_module);
711module_exit(pcipcwd_cleanup_module);
712
713MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>");
714MODULE_DESCRIPTION("Berkshire PCI-PC Watchdog driver");
715MODULE_LICENSE("GPL");
716MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
717MODULE_ALIAS_MISCDEV(TEMP_MINOR);