Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Berkshire PCI-PC Watchdog Card Driver |
| 3 | * |
Wim Van Sebroeck | 39e3a05 | 2007-01-07 21:49:11 +0100 | [diff] [blame] | 4 | * (c) Copyright 2003-2007 Wim Van Sebroeck <wim@iguana.be>. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | /* |
Wim Van Sebroeck | 58b519f | 2006-05-21 12:48:44 +0200 | [diff] [blame] | 24 | * A bells and whistles driver is available from: |
Wim Van Sebroeck | b3faed6 | 2005-10-22 16:27:19 +0200 | [diff] [blame] | 25 | * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ |
| 26 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ |
| 28 | */ |
| 29 | |
| 30 | /* |
| 31 | * Includes, defines, variables, module parameters, ... |
| 32 | */ |
| 33 | |
Wim Van Sebroeck | c315b7e8 | 2005-09-12 00:21:19 +0200 | [diff] [blame] | 34 | #include <linux/module.h> /* For module specific items */ |
| 35 | #include <linux/moduleparam.h> /* For new moduleparam's */ |
| 36 | #include <linux/types.h> /* For standard types (like size_t) */ |
| 37 | #include <linux/errno.h> /* For the -ENODEV/... values */ |
| 38 | #include <linux/kernel.h> /* For printk/panic/... */ |
| 39 | #include <linux/delay.h> /* For mdelay function */ |
| 40 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ |
| 41 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
| 42 | #include <linux/notifier.h> /* For notifier support */ |
| 43 | #include <linux/reboot.h> /* For reboot_notifier stuff */ |
| 44 | #include <linux/init.h> /* For __init/__exit/... */ |
| 45 | #include <linux/fs.h> /* For file operations */ |
| 46 | #include <linux/pci.h> /* For pci functions */ |
| 47 | #include <linux/ioport.h> /* For io-port access */ |
| 48 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ |
Wim Van Sebroeck | 089ab07 | 2008-07-15 11:46:11 +0000 | [diff] [blame^] | 49 | #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ |
| 50 | #include <linux/io.h> /* For inb/outb/... */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | /* Module and version information */ |
Wim Van Sebroeck | 39e3a05 | 2007-01-07 21:49:11 +0100 | [diff] [blame] | 53 | #define WATCHDOG_VERSION "1.03" |
Wim Van Sebroeck | bffda5c | 2007-01-27 20:54:24 +0100 | [diff] [blame] | 54 | #define WATCHDOG_DATE "21 Jan 2007" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 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 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Wim Van Sebroeck | 39e3a05 | 2007-01-07 21:49:11 +0100 | [diff] [blame] | 98 | /* Watchdog's Dip Switch heartbeat values */ |
| 99 | static const int heartbeat_tbl [] = { |
| 100 | 5, /* OFF-OFF-OFF = 5 Sec */ |
| 101 | 10, /* OFF-OFF-ON = 10 Sec */ |
| 102 | 30, /* OFF-ON-OFF = 30 Sec */ |
| 103 | 60, /* OFF-ON-ON = 1 Min */ |
| 104 | 300, /* ON-OFF-OFF = 5 Min */ |
| 105 | 600, /* ON-OFF-ON = 10 Min */ |
| 106 | 1800, /* ON-ON-OFF = 30 Min */ |
| 107 | 3600, /* ON-ON-ON = 1 hour */ |
| 108 | }; |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | /* We can only use 1 card due to the /dev/watchdog restriction */ |
| 111 | static int cards_found; |
| 112 | |
| 113 | /* internal variables */ |
| 114 | static int temp_panic; |
| 115 | static unsigned long is_active; |
| 116 | static char expect_release; |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 117 | static struct { /* this is private data for each PCI-PC watchdog card */ |
| 118 | int supports_temp; /* Wether or not the card has a temperature device */ |
| 119 | int boot_status; /* The card's boot status */ |
| 120 | unsigned long io_addr; /* The cards I/O address */ |
| 121 | spinlock_t io_lock; /* the lock for io operations */ |
| 122 | struct pci_dev *pdev; /* the PCI-device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | } pcipcwd_private; |
| 124 | |
| 125 | /* module parameters */ |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 126 | #define QUIET 0 /* Default */ |
| 127 | #define VERBOSE 1 /* Verbose */ |
| 128 | #define DEBUG 2 /* print fancy stuff too */ |
| 129 | static int debug = QUIET; |
| 130 | module_param(debug, int, 0); |
| 131 | MODULE_PARM_DESC(debug, "Debug level: 0=Quiet, 1=Verbose, 2=Debug (default=0)"); |
| 132 | |
Wim Van Sebroeck | 39e3a05 | 2007-01-07 21:49:11 +0100 | [diff] [blame] | 133 | #define WATCHDOG_HEARTBEAT 0 /* default heartbeat = delay-time from dip-switches */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | static int heartbeat = WATCHDOG_HEARTBEAT; |
| 135 | module_param(heartbeat, int, 0); |
Wim Van Sebroeck | 39e3a05 | 2007-01-07 21:49:11 +0100 | [diff] [blame] | 136 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536 or 0=delay-time from dip-switches, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
Andrey Panin | 4bfdf37 | 2005-07-27 11:43:58 -0700 | [diff] [blame] | 138 | static int nowayout = WATCHDOG_NOWAYOUT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | module_param(nowayout, int, 0); |
Wim Van Sebroeck | bffda5c | 2007-01-27 20:54:24 +0100 | [diff] [blame] | 140 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
| 142 | /* |
| 143 | * Internal functions |
| 144 | */ |
| 145 | |
| 146 | static int send_command(int cmd, int *msb, int *lsb) |
| 147 | { |
| 148 | int got_response, count; |
| 149 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 150 | if (debug >= DEBUG) |
| 151 | printk(KERN_DEBUG PFX "sending following data cmd=0x%02x msb=0x%02x lsb=0x%02x\n", |
| 152 | cmd, *msb, *lsb); |
| 153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | spin_lock(&pcipcwd_private.io_lock); |
| 155 | /* If a command requires data it should be written first. |
| 156 | * Data for commands with 8 bits of data should be written to port 4. |
| 157 | * Commands with 16 bits of data, should be written as LSB to port 4 |
| 158 | * and MSB to port 5. |
| 159 | * After the required data has been written then write the command to |
| 160 | * port 6. */ |
| 161 | outb_p(*lsb, pcipcwd_private.io_addr + 4); |
| 162 | outb_p(*msb, pcipcwd_private.io_addr + 5); |
| 163 | outb_p(cmd, pcipcwd_private.io_addr + 6); |
| 164 | |
| 165 | /* wait till the pci card processed the command, signaled by |
| 166 | * the WRSP bit in port 2 and give it a max. timeout of |
| 167 | * PCI_COMMAND_TIMEOUT to process */ |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 168 | got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | for (count = 0; (count < PCI_COMMAND_TIMEOUT) && (!got_response); count++) { |
| 170 | mdelay(1); |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 171 | got_response = inb_p(pcipcwd_private.io_addr + 2) & WD_PCI_WRSP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 174 | if (debug >= DEBUG) { |
| 175 | if (got_response) { |
| 176 | printk(KERN_DEBUG PFX "time to process command was: %d ms\n", |
| 177 | count); |
| 178 | } else { |
| 179 | printk(KERN_DEBUG PFX "card did not respond on command!\n"); |
| 180 | } |
| 181 | } |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | if (got_response) { |
| 184 | /* read back response */ |
| 185 | *lsb = inb_p(pcipcwd_private.io_addr + 4); |
| 186 | *msb = inb_p(pcipcwd_private.io_addr + 5); |
| 187 | |
| 188 | /* clear WRSP bit */ |
| 189 | inb_p(pcipcwd_private.io_addr + 6); |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 190 | |
| 191 | if (debug >= DEBUG) |
| 192 | printk(KERN_DEBUG PFX "received following data for cmd=0x%02x: msb=0x%02x lsb=0x%02x\n", |
| 193 | cmd, *msb, *lsb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | spin_unlock(&pcipcwd_private.io_lock); |
| 197 | |
| 198 | return got_response; |
| 199 | } |
| 200 | |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 201 | static inline void pcipcwd_check_temperature_support(void) |
| 202 | { |
| 203 | if (inb_p(pcipcwd_private.io_addr) != 0xF0) |
| 204 | pcipcwd_private.supports_temp = 1; |
| 205 | } |
| 206 | |
| 207 | static int pcipcwd_get_option_switches(void) |
| 208 | { |
| 209 | int option_switches; |
| 210 | |
| 211 | option_switches = inb_p(pcipcwd_private.io_addr + 3); |
| 212 | return option_switches; |
| 213 | } |
| 214 | |
| 215 | static void pcipcwd_show_card_info(void) |
| 216 | { |
| 217 | int got_fw_rev, fw_rev_major, fw_rev_minor; |
| 218 | char fw_ver_str[20]; /* The cards firmware version */ |
| 219 | int option_switches; |
| 220 | |
| 221 | got_fw_rev = send_command(CMD_GET_FIRMWARE_VERSION, &fw_rev_major, &fw_rev_minor); |
| 222 | if (got_fw_rev) { |
| 223 | sprintf(fw_ver_str, "%u.%02u", fw_rev_major, fw_rev_minor); |
| 224 | } else { |
| 225 | sprintf(fw_ver_str, "<card no answer>"); |
| 226 | } |
| 227 | |
| 228 | /* Get switch settings */ |
| 229 | option_switches = pcipcwd_get_option_switches(); |
| 230 | |
| 231 | printk(KERN_INFO PFX "Found card at port 0x%04x (Firmware: %s) %s temp option\n", |
| 232 | (int) pcipcwd_private.io_addr, fw_ver_str, |
| 233 | (pcipcwd_private.supports_temp ? "with" : "without")); |
| 234 | |
| 235 | printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", |
| 236 | option_switches, |
| 237 | ((option_switches & 0x10) ? "ON" : "OFF"), |
| 238 | ((option_switches & 0x08) ? "ON" : "OFF")); |
| 239 | |
| 240 | if (pcipcwd_private.boot_status & WDIOF_CARDRESET) |
| 241 | printk(KERN_INFO PFX "Previous reset was caused by the Watchdog card\n"); |
| 242 | |
| 243 | if (pcipcwd_private.boot_status & WDIOF_OVERHEAT) |
| 244 | printk(KERN_INFO PFX "Card sensed a CPU Overheat\n"); |
| 245 | |
| 246 | if (pcipcwd_private.boot_status == 0) |
| 247 | printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); |
| 248 | } |
| 249 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | static int pcipcwd_start(void) |
| 251 | { |
| 252 | int stat_reg; |
| 253 | |
| 254 | spin_lock(&pcipcwd_private.io_lock); |
| 255 | outb_p(0x00, pcipcwd_private.io_addr + 3); |
| 256 | udelay(1000); |
| 257 | |
| 258 | stat_reg = inb_p(pcipcwd_private.io_addr + 2); |
| 259 | spin_unlock(&pcipcwd_private.io_lock); |
| 260 | |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 261 | if (stat_reg & WD_PCI_WDIS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | printk(KERN_ERR PFX "Card timer not enabled\n"); |
| 263 | return -1; |
| 264 | } |
| 265 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 266 | if (debug >= VERBOSE) |
| 267 | printk(KERN_DEBUG PFX "Watchdog started\n"); |
| 268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | static int pcipcwd_stop(void) |
| 273 | { |
| 274 | int stat_reg; |
| 275 | |
| 276 | spin_lock(&pcipcwd_private.io_lock); |
| 277 | outb_p(0xA5, pcipcwd_private.io_addr + 3); |
| 278 | udelay(1000); |
| 279 | |
| 280 | outb_p(0xA5, pcipcwd_private.io_addr + 3); |
| 281 | udelay(1000); |
| 282 | |
| 283 | stat_reg = inb_p(pcipcwd_private.io_addr + 2); |
| 284 | spin_unlock(&pcipcwd_private.io_lock); |
| 285 | |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 286 | if (!(stat_reg & WD_PCI_WDIS)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | printk(KERN_ERR PFX "Card did not acknowledge disable attempt\n"); |
| 288 | return -1; |
| 289 | } |
| 290 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 291 | if (debug >= VERBOSE) |
| 292 | printk(KERN_DEBUG PFX "Watchdog stopped\n"); |
| 293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int pcipcwd_keepalive(void) |
| 298 | { |
| 299 | /* Re-trigger watchdog by writing to port 0 */ |
Wim Van Sebroeck | 045798b | 2007-01-07 21:57:03 +0100 | [diff] [blame] | 300 | spin_lock(&pcipcwd_private.io_lock); |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 301 | outb_p(0x42, pcipcwd_private.io_addr); /* send out any data */ |
Wim Van Sebroeck | 045798b | 2007-01-07 21:57:03 +0100 | [diff] [blame] | 302 | spin_unlock(&pcipcwd_private.io_lock); |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 303 | |
| 304 | if (debug >= DEBUG) |
| 305 | printk(KERN_DEBUG PFX "Watchdog keepalive signal send\n"); |
| 306 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | static int pcipcwd_set_heartbeat(int t) |
| 311 | { |
| 312 | int t_msb = t / 256; |
| 313 | int t_lsb = t % 256; |
| 314 | |
| 315 | if ((t < 0x0001) || (t > 0xFFFF)) |
| 316 | return -EINVAL; |
| 317 | |
| 318 | /* Write new heartbeat to watchdog */ |
| 319 | send_command(CMD_WRITE_WATCHDOG_TIMEOUT, &t_msb, &t_lsb); |
| 320 | |
| 321 | heartbeat = t; |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 322 | if (debug >= VERBOSE) |
| 323 | printk(KERN_DEBUG PFX "New heartbeat: %d\n", |
| 324 | heartbeat); |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | static int pcipcwd_get_status(int *status) |
| 330 | { |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 331 | int control_status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | *status=0; |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 334 | control_status = inb_p(pcipcwd_private.io_addr + 1); |
| 335 | if (control_status & WD_PCI_WTRP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | *status |= WDIOF_CARDRESET; |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 337 | if (control_status & WD_PCI_TTRP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | *status |= WDIOF_OVERHEAT; |
| 339 | if (temp_panic) |
| 340 | panic(PFX "Temperature overheat trip!\n"); |
| 341 | } |
| 342 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 343 | if (debug >= DEBUG) |
| 344 | printk(KERN_DEBUG PFX "Control Status #1: 0x%02x\n", |
| 345 | control_status); |
| 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | static int pcipcwd_clear_status(void) |
| 351 | { |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 352 | int control_status; |
| 353 | int msb; |
| 354 | int reset_counter; |
| 355 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 356 | if (debug >= VERBOSE) |
| 357 | printk(KERN_INFO PFX "clearing watchdog trip status & LED\n"); |
| 358 | |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 359 | control_status = inb_p(pcipcwd_private.io_addr + 1); |
| 360 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 361 | if (debug >= DEBUG) { |
| 362 | printk(KERN_DEBUG PFX "status was: 0x%02x\n", control_status); |
| 363 | printk(KERN_DEBUG PFX "sending: 0x%02x\n", |
| 364 | (control_status & WD_PCI_R2DS) | WD_PCI_WTRP); |
| 365 | } |
| 366 | |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 367 | /* clear trip status & LED and keep mode of relay 2 */ |
| 368 | outb_p((control_status & WD_PCI_R2DS) | WD_PCI_WTRP, pcipcwd_private.io_addr + 1); |
| 369 | |
| 370 | /* clear reset counter */ |
| 371 | msb=0; |
| 372 | reset_counter=0xff; |
| 373 | send_command(CMD_GET_CLEAR_RESET_COUNT, &msb, &reset_counter); |
| 374 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 375 | if (debug >= DEBUG) { |
| 376 | printk(KERN_DEBUG PFX "reset count was: 0x%02x\n", |
| 377 | reset_counter); |
| 378 | } |
| 379 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | static int pcipcwd_get_temperature(int *temperature) |
| 384 | { |
| 385 | *temperature = 0; |
| 386 | if (!pcipcwd_private.supports_temp) |
| 387 | return -ENODEV; |
| 388 | |
Wim Van Sebroeck | 045798b | 2007-01-07 21:57:03 +0100 | [diff] [blame] | 389 | spin_lock(&pcipcwd_private.io_lock); |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 390 | *temperature = inb_p(pcipcwd_private.io_addr); |
Wim Van Sebroeck | 045798b | 2007-01-07 21:57:03 +0100 | [diff] [blame] | 391 | spin_unlock(&pcipcwd_private.io_lock); |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | /* |
| 394 | * Convert celsius to fahrenheit, since this was |
| 395 | * the decided 'standard' for this return value. |
| 396 | */ |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 397 | *temperature = (*temperature * 9 / 5) + 32; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 399 | if (debug >= DEBUG) { |
| 400 | printk(KERN_DEBUG PFX "temperature is: %d F\n", |
| 401 | *temperature); |
| 402 | } |
| 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | return 0; |
| 405 | } |
| 406 | |
Wim Van Sebroeck | 58b519f | 2006-05-21 12:48:44 +0200 | [diff] [blame] | 407 | static int pcipcwd_get_timeleft(int *time_left) |
| 408 | { |
| 409 | int msb; |
| 410 | int lsb; |
| 411 | |
| 412 | /* Read the time that's left before rebooting */ |
| 413 | /* Note: if the board is not yet armed then we will read 0xFFFF */ |
| 414 | send_command(CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb); |
| 415 | |
| 416 | *time_left = (msb << 8) + lsb; |
| 417 | |
| 418 | if (debug >= VERBOSE) |
| 419 | printk(KERN_DEBUG PFX "Time left before next reboot: %d\n", |
| 420 | *time_left); |
| 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | /* |
| 426 | * /dev/watchdog handling |
| 427 | */ |
| 428 | |
| 429 | static ssize_t pcipcwd_write(struct file *file, const char __user *data, |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 430 | size_t len, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | { |
| 432 | /* See if we got the magic character 'V' and reload the timer */ |
| 433 | if (len) { |
| 434 | if (!nowayout) { |
| 435 | size_t i; |
| 436 | |
| 437 | /* note: just in case someone wrote the magic character |
| 438 | * five months ago... */ |
| 439 | expect_release = 0; |
| 440 | |
| 441 | /* scan to see whether or not we got the magic character */ |
| 442 | for (i = 0; i != len; i++) { |
| 443 | char c; |
| 444 | if(get_user(c, data+i)) |
| 445 | return -EFAULT; |
| 446 | if (c == 'V') |
| 447 | expect_release = 42; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /* someone wrote to us, we should reload the timer */ |
| 452 | pcipcwd_keepalive(); |
| 453 | } |
| 454 | return len; |
| 455 | } |
| 456 | |
| 457 | static int pcipcwd_ioctl(struct inode *inode, struct file *file, |
| 458 | unsigned int cmd, unsigned long arg) |
| 459 | { |
| 460 | void __user *argp = (void __user *)arg; |
| 461 | int __user *p = argp; |
| 462 | static struct watchdog_info ident = { |
| 463 | .options = WDIOF_OVERHEAT | |
| 464 | WDIOF_CARDRESET | |
| 465 | WDIOF_KEEPALIVEPING | |
| 466 | WDIOF_SETTIMEOUT | |
| 467 | WDIOF_MAGICCLOSE, |
| 468 | .firmware_version = 1, |
| 469 | .identity = WATCHDOG_DRIVER_NAME, |
| 470 | }; |
| 471 | |
| 472 | switch (cmd) { |
| 473 | case WDIOC_GETSUPPORT: |
| 474 | return copy_to_user(argp, &ident, |
| 475 | sizeof (ident)) ? -EFAULT : 0; |
| 476 | |
| 477 | case WDIOC_GETSTATUS: |
| 478 | { |
| 479 | int status; |
| 480 | |
| 481 | pcipcwd_get_status(&status); |
| 482 | |
| 483 | return put_user(status, p); |
| 484 | } |
| 485 | |
| 486 | case WDIOC_GETBOOTSTATUS: |
| 487 | return put_user(pcipcwd_private.boot_status, p); |
| 488 | |
| 489 | case WDIOC_GETTEMP: |
| 490 | { |
| 491 | int temperature; |
| 492 | |
| 493 | if (pcipcwd_get_temperature(&temperature)) |
| 494 | return -EFAULT; |
| 495 | |
| 496 | return put_user(temperature, p); |
| 497 | } |
| 498 | |
| 499 | case WDIOC_KEEPALIVE: |
| 500 | pcipcwd_keepalive(); |
| 501 | return 0; |
| 502 | |
| 503 | case WDIOC_SETOPTIONS: |
| 504 | { |
| 505 | int new_options, retval = -EINVAL; |
| 506 | |
| 507 | if (get_user (new_options, p)) |
| 508 | return -EFAULT; |
| 509 | |
| 510 | if (new_options & WDIOS_DISABLECARD) { |
Wim Van Sebroeck | c315b7e8 | 2005-09-12 00:21:19 +0200 | [diff] [blame] | 511 | if (pcipcwd_stop()) |
| 512 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | retval = 0; |
| 514 | } |
| 515 | |
| 516 | if (new_options & WDIOS_ENABLECARD) { |
Wim Van Sebroeck | c315b7e8 | 2005-09-12 00:21:19 +0200 | [diff] [blame] | 517 | if (pcipcwd_start()) |
| 518 | return -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | retval = 0; |
| 520 | } |
| 521 | |
| 522 | if (new_options & WDIOS_TEMPPANIC) { |
| 523 | temp_panic = 1; |
| 524 | retval = 0; |
| 525 | } |
| 526 | |
| 527 | return retval; |
| 528 | } |
| 529 | |
| 530 | case WDIOC_SETTIMEOUT: |
| 531 | { |
| 532 | int new_heartbeat; |
| 533 | |
| 534 | if (get_user(new_heartbeat, p)) |
| 535 | return -EFAULT; |
| 536 | |
| 537 | if (pcipcwd_set_heartbeat(new_heartbeat)) |
| 538 | return -EINVAL; |
| 539 | |
| 540 | pcipcwd_keepalive(); |
| 541 | /* Fall */ |
| 542 | } |
| 543 | |
| 544 | case WDIOC_GETTIMEOUT: |
| 545 | return put_user(heartbeat, p); |
| 546 | |
Wim Van Sebroeck | 58b519f | 2006-05-21 12:48:44 +0200 | [diff] [blame] | 547 | case WDIOC_GETTIMELEFT: |
| 548 | { |
| 549 | int time_left; |
| 550 | |
| 551 | if (pcipcwd_get_timeleft(&time_left)) |
| 552 | return -EFAULT; |
| 553 | |
| 554 | return put_user(time_left, p); |
| 555 | } |
| 556 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | default: |
Samuel Tardieu | 795b89d | 2006-09-09 17:34:31 +0200 | [diff] [blame] | 558 | return -ENOTTY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | } |
| 560 | } |
| 561 | |
| 562 | static int pcipcwd_open(struct inode *inode, struct file *file) |
| 563 | { |
| 564 | /* /dev/watchdog can only be opened once */ |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 565 | if (test_and_set_bit(0, &is_active)) { |
Wim Van Sebroeck | 195331d | 2005-09-29 16:22:30 +0200 | [diff] [blame] | 566 | if (debug >= VERBOSE) |
| 567 | printk(KERN_ERR PFX "Attempt to open already opened device.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | return -EBUSY; |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 569 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | |
| 571 | /* Activate */ |
| 572 | pcipcwd_start(); |
| 573 | pcipcwd_keepalive(); |
| 574 | return nonseekable_open(inode, file); |
| 575 | } |
| 576 | |
| 577 | static int pcipcwd_release(struct inode *inode, struct file *file) |
| 578 | { |
| 579 | /* |
| 580 | * Shut off the timer. |
| 581 | */ |
| 582 | if (expect_release == 42) { |
| 583 | pcipcwd_stop(); |
| 584 | } else { |
| 585 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); |
| 586 | pcipcwd_keepalive(); |
| 587 | } |
| 588 | expect_release = 0; |
| 589 | clear_bit(0, &is_active); |
| 590 | return 0; |
| 591 | } |
| 592 | |
| 593 | /* |
| 594 | * /dev/temperature handling |
| 595 | */ |
| 596 | |
| 597 | static ssize_t pcipcwd_temp_read(struct file *file, char __user *data, |
| 598 | size_t len, loff_t *ppos) |
| 599 | { |
| 600 | int temperature; |
| 601 | |
| 602 | if (pcipcwd_get_temperature(&temperature)) |
| 603 | return -EFAULT; |
| 604 | |
| 605 | if (copy_to_user (data, &temperature, 1)) |
| 606 | return -EFAULT; |
| 607 | |
| 608 | return 1; |
| 609 | } |
| 610 | |
| 611 | static int pcipcwd_temp_open(struct inode *inode, struct file *file) |
| 612 | { |
| 613 | if (!pcipcwd_private.supports_temp) |
| 614 | return -ENODEV; |
| 615 | |
| 616 | return nonseekable_open(inode, file); |
| 617 | } |
| 618 | |
| 619 | static int pcipcwd_temp_release(struct inode *inode, struct file *file) |
| 620 | { |
| 621 | return 0; |
| 622 | } |
| 623 | |
| 624 | /* |
| 625 | * Notify system |
| 626 | */ |
| 627 | |
| 628 | static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code, void *unused) |
| 629 | { |
| 630 | if (code==SYS_DOWN || code==SYS_HALT) { |
| 631 | /* Turn the WDT off */ |
| 632 | pcipcwd_stop(); |
| 633 | } |
| 634 | |
| 635 | return NOTIFY_DONE; |
| 636 | } |
| 637 | |
| 638 | /* |
| 639 | * Kernel Interfaces |
| 640 | */ |
| 641 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 642 | static const struct file_operations pcipcwd_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | .owner = THIS_MODULE, |
| 644 | .llseek = no_llseek, |
| 645 | .write = pcipcwd_write, |
| 646 | .ioctl = pcipcwd_ioctl, |
| 647 | .open = pcipcwd_open, |
| 648 | .release = pcipcwd_release, |
| 649 | }; |
| 650 | |
| 651 | static struct miscdevice pcipcwd_miscdev = { |
| 652 | .minor = WATCHDOG_MINOR, |
| 653 | .name = "watchdog", |
| 654 | .fops = &pcipcwd_fops, |
| 655 | }; |
| 656 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 657 | static const struct file_operations pcipcwd_temp_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | .owner = THIS_MODULE, |
| 659 | .llseek = no_llseek, |
| 660 | .read = pcipcwd_temp_read, |
| 661 | .open = pcipcwd_temp_open, |
| 662 | .release = pcipcwd_temp_release, |
| 663 | }; |
| 664 | |
| 665 | static struct miscdevice pcipcwd_temp_miscdev = { |
| 666 | .minor = TEMP_MINOR, |
| 667 | .name = "temperature", |
| 668 | .fops = &pcipcwd_temp_fops, |
| 669 | }; |
| 670 | |
| 671 | static struct notifier_block pcipcwd_notifier = { |
| 672 | .notifier_call = pcipcwd_notify_sys, |
| 673 | }; |
| 674 | |
| 675 | /* |
| 676 | * Init & exit routines |
| 677 | */ |
| 678 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | static int __devinit pcipcwd_card_init(struct pci_dev *pdev, |
| 680 | const struct pci_device_id *ent) |
| 681 | { |
| 682 | int ret = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | |
| 684 | cards_found++; |
| 685 | if (cards_found == 1) |
| 686 | printk(KERN_INFO PFX DRIVER_VERSION); |
| 687 | |
| 688 | if (cards_found > 1) { |
| 689 | printk(KERN_ERR PFX "This driver only supports 1 device\n"); |
| 690 | return -ENODEV; |
| 691 | } |
| 692 | |
| 693 | if (pci_enable_device(pdev)) { |
| 694 | printk(KERN_ERR PFX "Not possible to enable PCI Device\n"); |
| 695 | return -ENODEV; |
| 696 | } |
| 697 | |
| 698 | if (pci_resource_start(pdev, 0) == 0x0000) { |
| 699 | printk(KERN_ERR PFX "No I/O-Address for card detected\n"); |
| 700 | ret = -ENODEV; |
| 701 | goto err_out_disable_device; |
| 702 | } |
| 703 | |
| 704 | pcipcwd_private.pdev = pdev; |
| 705 | pcipcwd_private.io_addr = pci_resource_start(pdev, 0); |
| 706 | |
| 707 | if (pci_request_regions(pdev, WATCHDOG_NAME)) { |
| 708 | printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", |
| 709 | (int) pcipcwd_private.io_addr); |
| 710 | ret = -EIO; |
| 711 | goto err_out_disable_device; |
| 712 | } |
| 713 | |
| 714 | /* get the boot_status */ |
| 715 | pcipcwd_get_status(&pcipcwd_private.boot_status); |
| 716 | |
| 717 | /* clear the "card caused reboot" flag */ |
| 718 | pcipcwd_clear_status(); |
| 719 | |
| 720 | /* disable card */ |
| 721 | pcipcwd_stop(); |
| 722 | |
| 723 | /* Check whether or not the card supports the temperature device */ |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 724 | pcipcwd_check_temperature_support(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 726 | /* Show info about the card itself */ |
| 727 | pcipcwd_show_card_info(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | |
Wim Van Sebroeck | 39e3a05 | 2007-01-07 21:49:11 +0100 | [diff] [blame] | 729 | /* If heartbeat = 0 then we use the heartbeat from the dip-switches */ |
| 730 | if (heartbeat == 0) |
| 731 | heartbeat = heartbeat_tbl[(pcipcwd_get_option_switches() & 0x07)]; |
| 732 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ |
| 734 | if (pcipcwd_set_heartbeat(heartbeat)) { |
| 735 | pcipcwd_set_heartbeat(WATCHDOG_HEARTBEAT); |
| 736 | printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n", |
| 737 | WATCHDOG_HEARTBEAT); |
| 738 | } |
| 739 | |
| 740 | ret = register_reboot_notifier(&pcipcwd_notifier); |
| 741 | if (ret != 0) { |
| 742 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", |
| 743 | ret); |
| 744 | goto err_out_release_region; |
| 745 | } |
| 746 | |
| 747 | if (pcipcwd_private.supports_temp) { |
| 748 | ret = misc_register(&pcipcwd_temp_miscdev); |
| 749 | if (ret != 0) { |
| 750 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
| 751 | TEMP_MINOR, ret); |
| 752 | goto err_out_unregister_reboot; |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | ret = misc_register(&pcipcwd_miscdev); |
| 757 | if (ret != 0) { |
| 758 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", |
| 759 | WATCHDOG_MINOR, ret); |
| 760 | goto err_out_misc_deregister; |
| 761 | } |
| 762 | |
| 763 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", |
| 764 | heartbeat, nowayout); |
| 765 | |
| 766 | return 0; |
| 767 | |
| 768 | err_out_misc_deregister: |
| 769 | if (pcipcwd_private.supports_temp) |
| 770 | misc_deregister(&pcipcwd_temp_miscdev); |
| 771 | err_out_unregister_reboot: |
| 772 | unregister_reboot_notifier(&pcipcwd_notifier); |
| 773 | err_out_release_region: |
| 774 | pci_release_regions(pdev); |
| 775 | err_out_disable_device: |
| 776 | pci_disable_device(pdev); |
| 777 | return ret; |
| 778 | } |
| 779 | |
| 780 | static void __devexit pcipcwd_card_exit(struct pci_dev *pdev) |
| 781 | { |
| 782 | /* Stop the timer before we leave */ |
| 783 | if (!nowayout) |
| 784 | pcipcwd_stop(); |
| 785 | |
| 786 | /* Deregister */ |
| 787 | misc_deregister(&pcipcwd_miscdev); |
| 788 | if (pcipcwd_private.supports_temp) |
| 789 | misc_deregister(&pcipcwd_temp_miscdev); |
| 790 | unregister_reboot_notifier(&pcipcwd_notifier); |
| 791 | pci_release_regions(pdev); |
| 792 | pci_disable_device(pdev); |
| 793 | cards_found--; |
| 794 | } |
| 795 | |
| 796 | static struct pci_device_id pcipcwd_pci_tbl[] = { |
| 797 | { PCI_VENDOR_ID_QUICKLOGIC, PCI_DEVICE_ID_WATCHDOG_PCIPCWD, |
| 798 | PCI_ANY_ID, PCI_ANY_ID, }, |
| 799 | { 0 }, /* End of list */ |
| 800 | }; |
| 801 | MODULE_DEVICE_TABLE(pci, pcipcwd_pci_tbl); |
| 802 | |
| 803 | static struct pci_driver pcipcwd_driver = { |
| 804 | .name = WATCHDOG_NAME, |
| 805 | .id_table = pcipcwd_pci_tbl, |
| 806 | .probe = pcipcwd_card_init, |
| 807 | .remove = __devexit_p(pcipcwd_card_exit), |
| 808 | }; |
| 809 | |
| 810 | static int __init pcipcwd_init_module(void) |
| 811 | { |
Wim Van Sebroeck | a0800f6 | 2005-09-29 16:21:50 +0200 | [diff] [blame] | 812 | spin_lock_init(&pcipcwd_private.io_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
| 814 | return pci_register_driver(&pcipcwd_driver); |
| 815 | } |
| 816 | |
| 817 | static void __exit pcipcwd_cleanup_module(void) |
| 818 | { |
| 819 | pci_unregister_driver(&pcipcwd_driver); |
Wim Van Sebroeck | 045798b | 2007-01-07 21:57:03 +0100 | [diff] [blame] | 820 | |
| 821 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | module_init(pcipcwd_init_module); |
| 825 | module_exit(pcipcwd_cleanup_module); |
| 826 | |
| 827 | MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>"); |
| 828 | MODULE_DESCRIPTION("Berkshire PCI-PC Watchdog driver"); |
| 829 | MODULE_LICENSE("GPL"); |
| 830 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
| 831 | MODULE_ALIAS_MISCDEV(TEMP_MINOR); |