diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-08-08 12:33:47 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-08-08 14:18:18 -0400 |
commit | 097d9eb537ff4d88b74c3fe67392e27c478ca3c5 (patch) | |
tree | 9034d676d9096857a380aab9d99e3e88fccb6bfe /drivers/watchdog/iTCO_wdt.c | |
parent | c41107c2d4fd31924533f4dbc4c3428acc2b5894 (diff) | |
parent | aeee90dfa01844168cd7f8051d0a0f969c573067 (diff) |
Merge Linus' latest into master
Conflicts:
drivers/watchdog/at91rm9200_wdt.c
drivers/watchdog/davinci_wdt.c
drivers/watchdog/ep93xx_wdt.c
drivers/watchdog/ixp2000_wdt.c
drivers/watchdog/ixp4xx_wdt.c
drivers/watchdog/ks8695_wdt.c
drivers/watchdog/omap_wdt.c
drivers/watchdog/pnx4008_wdt.c
drivers/watchdog/sa1100_wdt.c
drivers/watchdog/wdt285.c
Diffstat (limited to 'drivers/watchdog/iTCO_wdt.c')
-rw-r--r-- | drivers/watchdog/iTCO_wdt.c | 310 |
1 files changed, 152 insertions, 158 deletions
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index 95ba985bd341..bfb93bc2ca9f 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c | |||
@@ -55,9 +55,9 @@ | |||
55 | */ | 55 | */ |
56 | 56 | ||
57 | /* Module and version information */ | 57 | /* Module and version information */ |
58 | #define DRV_NAME "iTCO_wdt" | 58 | #define DRV_NAME "iTCO_wdt" |
59 | #define DRV_VERSION "1.03" | 59 | #define DRV_VERSION "1.03" |
60 | #define DRV_RELDATE "30-Apr-2008" | 60 | #define DRV_RELDATE "30-Apr-2008" |
61 | #define PFX DRV_NAME ": " | 61 | #define PFX DRV_NAME ": " |
62 | 62 | ||
63 | /* Includes */ | 63 | /* Includes */ |
@@ -66,7 +66,8 @@ | |||
66 | #include <linux/types.h> /* For standard types (like size_t) */ | 66 | #include <linux/types.h> /* For standard types (like size_t) */ |
67 | #include <linux/errno.h> /* For the -ENODEV/... values */ | 67 | #include <linux/errno.h> /* For the -ENODEV/... values */ |
68 | #include <linux/kernel.h> /* For printk/panic/... */ | 68 | #include <linux/kernel.h> /* For printk/panic/... */ |
69 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ | 69 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV |
70 | (WATCHDOG_MINOR) */ | ||
70 | #include <linux/watchdog.h> /* For the watchdog specific items */ | 71 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
71 | #include <linux/init.h> /* For __init/__exit/... */ | 72 | #include <linux/init.h> /* For __init/__exit/... */ |
72 | #include <linux/fs.h> /* For file operations */ | 73 | #include <linux/fs.h> /* For file operations */ |
@@ -74,9 +75,10 @@ | |||
74 | #include <linux/pci.h> /* For pci functions */ | 75 | #include <linux/pci.h> /* For pci functions */ |
75 | #include <linux/ioport.h> /* For io-port access */ | 76 | #include <linux/ioport.h> /* For io-port access */ |
76 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ | 77 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ |
78 | #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ | ||
79 | #include <linux/io.h> /* For inb/outb/... */ | ||
77 | 80 | ||
78 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ | 81 | #include "iTCO_vendor.h" |
79 | #include <asm/io.h> /* For inb/outb/... */ | ||
80 | 82 | ||
81 | /* TCO related info */ | 83 | /* TCO related info */ |
82 | enum iTCO_chipsets { | 84 | enum iTCO_chipsets { |
@@ -105,7 +107,7 @@ enum iTCO_chipsets { | |||
105 | TCO_ICH9, /* ICH9 */ | 107 | TCO_ICH9, /* ICH9 */ |
106 | TCO_ICH9R, /* ICH9R */ | 108 | TCO_ICH9R, /* ICH9R */ |
107 | TCO_ICH9DH, /* ICH9DH */ | 109 | TCO_ICH9DH, /* ICH9DH */ |
108 | TCO_ICH9DO, /* ICH9DO */ | 110 | TCO_ICH9DO, /* ICH9DO */ |
109 | TCO_631XESB, /* 631xESB/632xESB */ | 111 | TCO_631XESB, /* 631xESB/632xESB */ |
110 | }; | 112 | }; |
111 | 113 | ||
@@ -140,7 +142,7 @@ static struct { | |||
140 | {"ICH9DH", 2}, | 142 | {"ICH9DH", 2}, |
141 | {"ICH9DO", 2}, | 143 | {"ICH9DO", 2}, |
142 | {"631xESB/632xESB", 2}, | 144 | {"631xESB/632xESB", 2}, |
143 | {NULL,0} | 145 | {NULL, 0} |
144 | }; | 146 | }; |
145 | 147 | ||
146 | #define ITCO_PCI_DEVICE(dev, data) \ | 148 | #define ITCO_PCI_DEVICE(dev, data) \ |
@@ -159,32 +161,32 @@ static struct { | |||
159 | * functions that probably will be registered by other drivers. | 161 | * functions that probably will be registered by other drivers. |
160 | */ | 162 | */ |
161 | static struct pci_device_id iTCO_wdt_pci_tbl[] = { | 163 | static struct pci_device_id iTCO_wdt_pci_tbl[] = { |
162 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801AA_0, TCO_ICH )}, | 164 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801AA_0, TCO_ICH)}, |
163 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801AB_0, TCO_ICH0 )}, | 165 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801AB_0, TCO_ICH0)}, |
164 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801BA_0, TCO_ICH2 )}, | 166 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801BA_0, TCO_ICH2)}, |
165 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801BA_10, TCO_ICH2M )}, | 167 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801BA_10, TCO_ICH2M)}, |
166 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801CA_0, TCO_ICH3 )}, | 168 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801CA_0, TCO_ICH3)}, |
167 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801CA_12, TCO_ICH3M )}, | 169 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801CA_12, TCO_ICH3M)}, |
168 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801DB_0, TCO_ICH4 )}, | 170 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801DB_0, TCO_ICH4)}, |
169 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801DB_12, TCO_ICH4M )}, | 171 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801DB_12, TCO_ICH4M)}, |
170 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801E_0, TCO_CICH )}, | 172 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801E_0, TCO_CICH)}, |
171 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801EB_0, TCO_ICH5 )}, | 173 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_82801EB_0, TCO_ICH5)}, |
172 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ESB_1, TCO_6300ESB)}, | 174 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ESB_1, TCO_6300ESB)}, |
173 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_0, TCO_ICH6 )}, | 175 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_0, TCO_ICH6)}, |
174 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_1, TCO_ICH6M )}, | 176 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_1, TCO_ICH6M)}, |
175 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_2, TCO_ICH6W )}, | 177 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_2, TCO_ICH6W)}, |
176 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_0, TCO_ICH7 )}, | 178 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_0, TCO_ICH7)}, |
177 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_1, TCO_ICH7M )}, | 179 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_1, TCO_ICH7M)}, |
178 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_31, TCO_ICH7MDH)}, | 180 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH7_31, TCO_ICH7MDH)}, |
179 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_0, TCO_ICH8 )}, | 181 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_0, TCO_ICH8)}, |
180 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_1, TCO_ICH8ME )}, | 182 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_1, TCO_ICH8ME)}, |
181 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_2, TCO_ICH8DH )}, | 183 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_2, TCO_ICH8DH)}, |
182 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_3, TCO_ICH8DO )}, | 184 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_3, TCO_ICH8DO)}, |
183 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_4, TCO_ICH8M )}, | 185 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH8_4, TCO_ICH8M)}, |
184 | { ITCO_PCI_DEVICE(0x2918, TCO_ICH9 )}, | 186 | { ITCO_PCI_DEVICE(0x2918, TCO_ICH9)}, |
185 | { ITCO_PCI_DEVICE(0x2916, TCO_ICH9R )}, | 187 | { ITCO_PCI_DEVICE(0x2916, TCO_ICH9R)}, |
186 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_2, TCO_ICH9DH )}, | 188 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_2, TCO_ICH9DH)}, |
187 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_4, TCO_ICH9DO )}, | 189 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ICH9_4, TCO_ICH9DO)}, |
188 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ESB2_0, TCO_631XESB)}, | 190 | { ITCO_PCI_DEVICE(PCI_DEVICE_ID_INTEL_ESB2_0, TCO_631XESB)}, |
189 | { ITCO_PCI_DEVICE(0x2671, TCO_631XESB)}, | 191 | { ITCO_PCI_DEVICE(0x2671, TCO_631XESB)}, |
190 | { ITCO_PCI_DEVICE(0x2672, TCO_631XESB)}, | 192 | { ITCO_PCI_DEVICE(0x2672, TCO_631XESB)}, |
@@ -203,13 +205,15 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = { | |||
203 | { ITCO_PCI_DEVICE(0x267f, TCO_631XESB)}, | 205 | { ITCO_PCI_DEVICE(0x267f, TCO_631XESB)}, |
204 | { 0, }, /* End of list */ | 206 | { 0, }, /* End of list */ |
205 | }; | 207 | }; |
206 | MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl); | 208 | MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); |
207 | 209 | ||
208 | /* Address definitions for the TCO */ | 210 | /* Address definitions for the TCO */ |
209 | #define TCOBASE iTCO_wdt_private.ACPIBASE + 0x60 /* TCO base address */ | 211 | /* TCO base address */ |
210 | #define SMI_EN iTCO_wdt_private.ACPIBASE + 0x30 /* SMI Control and Enable Register */ | 212 | #define TCOBASE iTCO_wdt_private.ACPIBASE + 0x60 |
213 | /* SMI Control and Enable Register */ | ||
214 | #define SMI_EN iTCO_wdt_private.ACPIBASE + 0x30 | ||
211 | 215 | ||
212 | #define TCO_RLD TCOBASE + 0x00 /* TCO Timer Reload and Current Value */ | 216 | #define TCO_RLD TCOBASE + 0x00 /* TCO Timer Reload and Curr. Value */ |
213 | #define TCOv1_TMR TCOBASE + 0x01 /* TCOv1 Timer Initial Value */ | 217 | #define TCOv1_TMR TCOBASE + 0x01 /* TCOv1 Timer Initial Value */ |
214 | #define TCO_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */ | 218 | #define TCO_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */ |
215 | #define TCO_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */ | 219 | #define TCO_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */ |
@@ -222,15 +226,21 @@ MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl); | |||
222 | /* internal variables */ | 226 | /* internal variables */ |
223 | static unsigned long is_active; | 227 | static unsigned long is_active; |
224 | static char expect_release; | 228 | static char expect_release; |
225 | static struct { /* this is private data for the iTCO_wdt device */ | 229 | static struct { /* this is private data for the iTCO_wdt device */ |
226 | unsigned int iTCO_version; /* TCO version/generation */ | 230 | /* TCO version/generation */ |
227 | unsigned long ACPIBASE; /* The cards ACPIBASE address (TCOBASE = ACPIBASE+0x60) */ | 231 | unsigned int iTCO_version; |
228 | unsigned long __iomem *gcs; /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2) */ | 232 | /* The cards ACPIBASE address (TCOBASE = ACPIBASE+0x60) */ |
229 | spinlock_t io_lock; /* the lock for io operations */ | 233 | unsigned long ACPIBASE; |
230 | struct pci_dev *pdev; /* the PCI-device */ | 234 | /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2)*/ |
235 | unsigned long __iomem *gcs; | ||
236 | /* the lock for io operations */ | ||
237 | spinlock_t io_lock; | ||
238 | /* the PCI-device */ | ||
239 | struct pci_dev *pdev; | ||
231 | } iTCO_wdt_private; | 240 | } iTCO_wdt_private; |
232 | 241 | ||
233 | static struct platform_device *iTCO_wdt_platform_device; /* the watchdog platform device */ | 242 | /* the watchdog platform device */ |
243 | static struct platform_device *iTCO_wdt_platform_device; | ||
234 | 244 | ||
235 | /* module parameters */ | 245 | /* module parameters */ |
236 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ | 246 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ |
@@ -240,22 +250,9 @@ MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39 (TCO | |||
240 | 250 | ||
241 | static int nowayout = WATCHDOG_NOWAYOUT; | 251 | static int nowayout = WATCHDOG_NOWAYOUT; |
242 | module_param(nowayout, int, 0); | 252 | module_param(nowayout, int, 0); |
243 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 253 | MODULE_PARM_DESC(nowayout, |
244 | 254 | "Watchdog cannot be stopped once started (default=" | |
245 | /* iTCO Vendor Specific Support hooks */ | 255 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
246 | #ifdef CONFIG_ITCO_VENDOR_SUPPORT | ||
247 | extern void iTCO_vendor_pre_start(unsigned long, unsigned int); | ||
248 | extern void iTCO_vendor_pre_stop(unsigned long); | ||
249 | extern void iTCO_vendor_pre_keepalive(unsigned long, unsigned int); | ||
250 | extern void iTCO_vendor_pre_set_heartbeat(unsigned int); | ||
251 | extern int iTCO_vendor_check_noreboot_on(void); | ||
252 | #else | ||
253 | #define iTCO_vendor_pre_start(acpibase, heartbeat) {} | ||
254 | #define iTCO_vendor_pre_stop(acpibase) {} | ||
255 | #define iTCO_vendor_pre_keepalive(acpibase,heartbeat) {} | ||
256 | #define iTCO_vendor_pre_set_heartbeat(heartbeat) {} | ||
257 | #define iTCO_vendor_check_noreboot_on() 1 /* 1=check noreboot; 0=don't check */ | ||
258 | #endif | ||
259 | 256 | ||
260 | /* | 257 | /* |
261 | * Some TCO specific functions | 258 | * Some TCO specific functions |
@@ -369,11 +366,10 @@ static int iTCO_wdt_keepalive(void) | |||
369 | iTCO_vendor_pre_keepalive(iTCO_wdt_private.ACPIBASE, heartbeat); | 366 | iTCO_vendor_pre_keepalive(iTCO_wdt_private.ACPIBASE, heartbeat); |
370 | 367 | ||
371 | /* Reload the timer by writing to the TCO Timer Counter register */ | 368 | /* Reload the timer by writing to the TCO Timer Counter register */ |
372 | if (iTCO_wdt_private.iTCO_version == 2) { | 369 | if (iTCO_wdt_private.iTCO_version == 2) |
373 | outw(0x01, TCO_RLD); | 370 | outw(0x01, TCO_RLD); |
374 | } else if (iTCO_wdt_private.iTCO_version == 1) { | 371 | else if (iTCO_wdt_private.iTCO_version == 1) |
375 | outb(0x01, TCO_RLD); | 372 | outb(0x01, TCO_RLD); |
376 | } | ||
377 | 373 | ||
378 | spin_unlock(&iTCO_wdt_private.io_lock); | 374 | spin_unlock(&iTCO_wdt_private.io_lock); |
379 | return 0; | 375 | return 0; |
@@ -425,7 +421,7 @@ static int iTCO_wdt_set_heartbeat(int t) | |||
425 | return 0; | 421 | return 0; |
426 | } | 422 | } |
427 | 423 | ||
428 | static int iTCO_wdt_get_timeleft (int *time_left) | 424 | static int iTCO_wdt_get_timeleft(int *time_left) |
429 | { | 425 | { |
430 | unsigned int val16; | 426 | unsigned int val16; |
431 | unsigned char val8; | 427 | unsigned char val8; |
@@ -454,7 +450,7 @@ static int iTCO_wdt_get_timeleft (int *time_left) | |||
454 | * /dev/watchdog handling | 450 | * /dev/watchdog handling |
455 | */ | 451 | */ |
456 | 452 | ||
457 | static int iTCO_wdt_open (struct inode *inode, struct file *file) | 453 | static int iTCO_wdt_open(struct inode *inode, struct file *file) |
458 | { | 454 | { |
459 | /* /dev/watchdog can only be opened once */ | 455 | /* /dev/watchdog can only be opened once */ |
460 | if (test_and_set_bit(0, &is_active)) | 456 | if (test_and_set_bit(0, &is_active)) |
@@ -468,7 +464,7 @@ static int iTCO_wdt_open (struct inode *inode, struct file *file) | |||
468 | return nonseekable_open(inode, file); | 464 | return nonseekable_open(inode, file); |
469 | } | 465 | } |
470 | 466 | ||
471 | static int iTCO_wdt_release (struct inode *inode, struct file *file) | 467 | static int iTCO_wdt_release(struct inode *inode, struct file *file) |
472 | { | 468 | { |
473 | /* | 469 | /* |
474 | * Shut off the timer. | 470 | * Shut off the timer. |
@@ -476,7 +472,8 @@ static int iTCO_wdt_release (struct inode *inode, struct file *file) | |||
476 | if (expect_release == 42) { | 472 | if (expect_release == 42) { |
477 | iTCO_wdt_stop(); | 473 | iTCO_wdt_stop(); |
478 | } else { | 474 | } else { |
479 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); | 475 | printk(KERN_CRIT PFX |
476 | "Unexpected close, not stopping watchdog!\n"); | ||
480 | iTCO_wdt_keepalive(); | 477 | iTCO_wdt_keepalive(); |
481 | } | 478 | } |
482 | clear_bit(0, &is_active); | 479 | clear_bit(0, &is_active); |
@@ -484,22 +481,23 @@ static int iTCO_wdt_release (struct inode *inode, struct file *file) | |||
484 | return 0; | 481 | return 0; |
485 | } | 482 | } |
486 | 483 | ||
487 | static ssize_t iTCO_wdt_write (struct file *file, const char __user *data, | 484 | static ssize_t iTCO_wdt_write(struct file *file, const char __user *data, |
488 | size_t len, loff_t * ppos) | 485 | size_t len, loff_t *ppos) |
489 | { | 486 | { |
490 | /* See if we got the magic character 'V' and reload the timer */ | 487 | /* See if we got the magic character 'V' and reload the timer */ |
491 | if (len) { | 488 | if (len) { |
492 | if (!nowayout) { | 489 | if (!nowayout) { |
493 | size_t i; | 490 | size_t i; |
494 | 491 | ||
495 | /* note: just in case someone wrote the magic character | 492 | /* note: just in case someone wrote the magic |
496 | * five months ago... */ | 493 | character five months ago... */ |
497 | expect_release = 0; | 494 | expect_release = 0; |
498 | 495 | ||
499 | /* scan to see whether or not we got the magic character */ | 496 | /* scan to see whether or not we got the |
497 | magic character */ | ||
500 | for (i = 0; i != len; i++) { | 498 | for (i = 0; i != len; i++) { |
501 | char c; | 499 | char c; |
502 | if (get_user(c, data+i)) | 500 | if (get_user(c, data + i)) |
503 | return -EFAULT; | 501 | return -EFAULT; |
504 | if (c == 'V') | 502 | if (c == 'V') |
505 | expect_release = 42; | 503 | expect_release = 42; |
@@ -512,8 +510,8 @@ static ssize_t iTCO_wdt_write (struct file *file, const char __user *data, | |||
512 | return len; | 510 | return len; |
513 | } | 511 | } |
514 | 512 | ||
515 | static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, | 513 | static long iTCO_wdt_ioctl(struct file *file, unsigned int cmd, |
516 | unsigned int cmd, unsigned long arg) | 514 | unsigned long arg) |
517 | { | 515 | { |
518 | int new_options, retval = -EINVAL; | 516 | int new_options, retval = -EINVAL; |
519 | int new_heartbeat; | 517 | int new_heartbeat; |
@@ -528,64 +526,52 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, | |||
528 | }; | 526 | }; |
529 | 527 | ||
530 | switch (cmd) { | 528 | switch (cmd) { |
531 | case WDIOC_GETSUPPORT: | 529 | case WDIOC_GETSUPPORT: |
532 | return copy_to_user(argp, &ident, | 530 | return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; |
533 | sizeof (ident)) ? -EFAULT : 0; | 531 | case WDIOC_GETSTATUS: |
534 | 532 | case WDIOC_GETBOOTSTATUS: | |
535 | case WDIOC_GETSTATUS: | 533 | return put_user(0, p); |
536 | case WDIOC_GETBOOTSTATUS: | 534 | |
537 | return put_user(0, p); | 535 | case WDIOC_SETOPTIONS: |
538 | 536 | { | |
539 | case WDIOC_KEEPALIVE: | 537 | if (get_user(new_options, p)) |
540 | iTCO_wdt_keepalive(); | 538 | return -EFAULT; |
541 | return 0; | 539 | |
542 | 540 | if (new_options & WDIOS_DISABLECARD) { | |
543 | case WDIOC_SETOPTIONS: | 541 | iTCO_wdt_stop(); |
544 | { | 542 | retval = 0; |
545 | if (get_user(new_options, p)) | ||
546 | return -EFAULT; | ||
547 | |||
548 | if (new_options & WDIOS_DISABLECARD) { | ||
549 | iTCO_wdt_stop(); | ||
550 | retval = 0; | ||
551 | } | ||
552 | |||
553 | if (new_options & WDIOS_ENABLECARD) { | ||
554 | iTCO_wdt_keepalive(); | ||
555 | iTCO_wdt_start(); | ||
556 | retval = 0; | ||
557 | } | ||
558 | |||
559 | return retval; | ||
560 | } | 543 | } |
561 | 544 | if (new_options & WDIOS_ENABLECARD) { | |
562 | case WDIOC_SETTIMEOUT: | ||
563 | { | ||
564 | if (get_user(new_heartbeat, p)) | ||
565 | return -EFAULT; | ||
566 | |||
567 | if (iTCO_wdt_set_heartbeat(new_heartbeat)) | ||
568 | return -EINVAL; | ||
569 | |||
570 | iTCO_wdt_keepalive(); | 545 | iTCO_wdt_keepalive(); |
571 | /* Fall */ | 546 | iTCO_wdt_start(); |
572 | } | 547 | retval = 0; |
573 | |||
574 | case WDIOC_GETTIMEOUT: | ||
575 | return put_user(heartbeat, p); | ||
576 | |||
577 | case WDIOC_GETTIMELEFT: | ||
578 | { | ||
579 | int time_left; | ||
580 | |||
581 | if (iTCO_wdt_get_timeleft(&time_left)) | ||
582 | return -EINVAL; | ||
583 | |||
584 | return put_user(time_left, p); | ||
585 | } | 548 | } |
549 | return retval; | ||
550 | } | ||
551 | case WDIOC_KEEPALIVE: | ||
552 | iTCO_wdt_keepalive(); | ||
553 | return 0; | ||
586 | 554 | ||
587 | default: | 555 | case WDIOC_SETTIMEOUT: |
588 | return -ENOTTY; | 556 | { |
557 | if (get_user(new_heartbeat, p)) | ||
558 | return -EFAULT; | ||
559 | if (iTCO_wdt_set_heartbeat(new_heartbeat)) | ||
560 | return -EINVAL; | ||
561 | iTCO_wdt_keepalive(); | ||
562 | /* Fall */ | ||
563 | } | ||
564 | case WDIOC_GETTIMEOUT: | ||
565 | return put_user(heartbeat, p); | ||
566 | case WDIOC_GETTIMELEFT: | ||
567 | { | ||
568 | int time_left; | ||
569 | if (iTCO_wdt_get_timeleft(&time_left)) | ||
570 | return -EINVAL; | ||
571 | return put_user(time_left, p); | ||
572 | } | ||
573 | default: | ||
574 | return -ENOTTY; | ||
589 | } | 575 | } |
590 | } | 576 | } |
591 | 577 | ||
@@ -594,12 +580,12 @@ static int iTCO_wdt_ioctl (struct inode *inode, struct file *file, | |||
594 | */ | 580 | */ |
595 | 581 | ||
596 | static const struct file_operations iTCO_wdt_fops = { | 582 | static const struct file_operations iTCO_wdt_fops = { |
597 | .owner = THIS_MODULE, | 583 | .owner = THIS_MODULE, |
598 | .llseek = no_llseek, | 584 | .llseek = no_llseek, |
599 | .write = iTCO_wdt_write, | 585 | .write = iTCO_wdt_write, |
600 | .ioctl = iTCO_wdt_ioctl, | 586 | .unlocked_ioctl = iTCO_wdt_ioctl, |
601 | .open = iTCO_wdt_open, | 587 | .open = iTCO_wdt_open, |
602 | .release = iTCO_wdt_release, | 588 | .release = iTCO_wdt_release, |
603 | }; | 589 | }; |
604 | 590 | ||
605 | static struct miscdevice iTCO_wdt_miscdev = { | 591 | static struct miscdevice iTCO_wdt_miscdev = { |
@@ -612,7 +598,8 @@ static struct miscdevice iTCO_wdt_miscdev = { | |||
612 | * Init & exit routines | 598 | * Init & exit routines |
613 | */ | 599 | */ |
614 | 600 | ||
615 | static int __devinit iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent, struct platform_device *dev) | 601 | static int __devinit iTCO_wdt_init(struct pci_dev *pdev, |
602 | const struct pci_device_id *ent, struct platform_device *dev) | ||
616 | { | 603 | { |
617 | int ret; | 604 | int ret; |
618 | u32 base_address; | 605 | u32 base_address; |
@@ -632,17 +619,19 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device | |||
632 | pci_dev_put(pdev); | 619 | pci_dev_put(pdev); |
633 | return -ENODEV; | 620 | return -ENODEV; |
634 | } | 621 | } |
635 | iTCO_wdt_private.iTCO_version = iTCO_chipset_info[ent->driver_data].iTCO_version; | 622 | iTCO_wdt_private.iTCO_version = |
623 | iTCO_chipset_info[ent->driver_data].iTCO_version; | ||
636 | iTCO_wdt_private.ACPIBASE = base_address; | 624 | iTCO_wdt_private.ACPIBASE = base_address; |
637 | iTCO_wdt_private.pdev = pdev; | 625 | iTCO_wdt_private.pdev = pdev; |
638 | 626 | ||
639 | /* Get the Memory-Mapped GCS register, we need it for the NO_REBOOT flag (TCO v2) */ | 627 | /* Get the Memory-Mapped GCS register, we need it for the |
640 | /* To get access to it you have to read RCBA from PCI Config space 0xf0 | 628 | NO_REBOOT flag (TCO v2). To get access to it you have to |
641 | and use it as base. GCS = RCBA + ICH6_GCS(0x3410). */ | 629 | read RCBA from PCI Config space 0xf0 and use it as base. |
630 | GCS = RCBA + ICH6_GCS(0x3410). */ | ||
642 | if (iTCO_wdt_private.iTCO_version == 2) { | 631 | if (iTCO_wdt_private.iTCO_version == 2) { |
643 | pci_read_config_dword(pdev, 0xf0, &base_address); | 632 | pci_read_config_dword(pdev, 0xf0, &base_address); |
644 | RCBA = base_address & 0xffffc000; | 633 | RCBA = base_address & 0xffffc000; |
645 | iTCO_wdt_private.gcs = ioremap((RCBA + 0x3410),4); | 634 | iTCO_wdt_private.gcs = ioremap((RCBA + 0x3410), 4); |
646 | } | 635 | } |
647 | 636 | ||
648 | /* Check chipset's NO_REBOOT bit */ | 637 | /* Check chipset's NO_REBOOT bit */ |
@@ -657,8 +646,8 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device | |||
657 | 646 | ||
658 | /* Set the TCO_EN bit in SMI_EN register */ | 647 | /* Set the TCO_EN bit in SMI_EN register */ |
659 | if (!request_region(SMI_EN, 4, "iTCO_wdt")) { | 648 | if (!request_region(SMI_EN, 4, "iTCO_wdt")) { |
660 | printk(KERN_ERR PFX "I/O address 0x%04lx already in use\n", | 649 | printk(KERN_ERR PFX |
661 | SMI_EN ); | 650 | "I/O address 0x%04lx already in use\n", SMI_EN); |
662 | ret = -EIO; | 651 | ret = -EIO; |
663 | goto out; | 652 | goto out; |
664 | } | 653 | } |
@@ -667,18 +656,20 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device | |||
667 | outl(val32, SMI_EN); | 656 | outl(val32, SMI_EN); |
668 | release_region(SMI_EN, 4); | 657 | release_region(SMI_EN, 4); |
669 | 658 | ||
670 | /* The TCO I/O registers reside in a 32-byte range pointed to by the TCOBASE value */ | 659 | /* The TCO I/O registers reside in a 32-byte range pointed to |
671 | if (!request_region (TCOBASE, 0x20, "iTCO_wdt")) { | 660 | by the TCOBASE value */ |
672 | printk (KERN_ERR PFX "I/O address 0x%04lx already in use\n", | 661 | if (!request_region(TCOBASE, 0x20, "iTCO_wdt")) { |
662 | printk(KERN_ERR PFX "I/O address 0x%04lx already in use\n", | ||
673 | TCOBASE); | 663 | TCOBASE); |
674 | ret = -EIO; | 664 | ret = -EIO; |
675 | goto out; | 665 | goto out; |
676 | } | 666 | } |
677 | 667 | ||
678 | printk(KERN_INFO PFX "Found a %s TCO device (Version=%d, TCOBASE=0x%04lx)\n", | 668 | printk(KERN_INFO PFX |
679 | iTCO_chipset_info[ent->driver_data].name, | 669 | "Found a %s TCO device (Version=%d, TCOBASE=0x%04lx)\n", |
680 | iTCO_chipset_info[ent->driver_data].iTCO_version, | 670 | iTCO_chipset_info[ent->driver_data].name, |
681 | TCOBASE); | 671 | iTCO_chipset_info[ent->driver_data].iTCO_version, |
672 | TCOBASE); | ||
682 | 673 | ||
683 | /* Clear out the (probably old) status */ | 674 | /* Clear out the (probably old) status */ |
684 | outb(0, TCO1_STS); | 675 | outb(0, TCO1_STS); |
@@ -687,27 +678,29 @@ static int __devinit iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device | |||
687 | /* Make sure the watchdog is not running */ | 678 | /* Make sure the watchdog is not running */ |
688 | iTCO_wdt_stop(); | 679 | iTCO_wdt_stop(); |
689 | 680 | ||
690 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | 681 | /* Check that the heartbeat value is within it's range; |
682 | if not reset to the default */ | ||
691 | if (iTCO_wdt_set_heartbeat(heartbeat)) { | 683 | if (iTCO_wdt_set_heartbeat(heartbeat)) { |
692 | iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT); | 684 | iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT); |
693 | printk(KERN_INFO PFX "heartbeat value must be 2<heartbeat<39 (TCO v1) or 613 (TCO v2), using %d\n", | 685 | printk(KERN_INFO PFX "heartbeat value must be 2 < heartbeat < 39 (TCO v1) or 613 (TCO v2), using %d\n", |
694 | heartbeat); | 686 | heartbeat); |
695 | } | 687 | } |
696 | 688 | ||
697 | ret = misc_register(&iTCO_wdt_miscdev); | 689 | ret = misc_register(&iTCO_wdt_miscdev); |
698 | if (ret != 0) { | 690 | if (ret != 0) { |
699 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | 691 | printk(KERN_ERR PFX |
700 | WATCHDOG_MINOR, ret); | 692 | "cannot register miscdev on minor=%d (err=%d)\n", |
693 | WATCHDOG_MINOR, ret); | ||
701 | goto unreg_region; | 694 | goto unreg_region; |
702 | } | 695 | } |
703 | 696 | ||
704 | printk (KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", | 697 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", |
705 | heartbeat, nowayout); | 698 | heartbeat, nowayout); |
706 | 699 | ||
707 | return 0; | 700 | return 0; |
708 | 701 | ||
709 | unreg_region: | 702 | unreg_region: |
710 | release_region (TCOBASE, 0x20); | 703 | release_region(TCOBASE, 0x20); |
711 | out: | 704 | out: |
712 | if (iTCO_wdt_private.iTCO_version == 2) | 705 | if (iTCO_wdt_private.iTCO_version == 2) |
713 | iounmap(iTCO_wdt_private.gcs); | 706 | iounmap(iTCO_wdt_private.gcs); |
@@ -796,7 +789,8 @@ static int __init iTCO_wdt_init_module(void) | |||
796 | if (err) | 789 | if (err) |
797 | return err; | 790 | return err; |
798 | 791 | ||
799 | iTCO_wdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | 792 | iTCO_wdt_platform_device = platform_device_register_simple(DRV_NAME, |
793 | -1, NULL, 0); | ||
800 | if (IS_ERR(iTCO_wdt_platform_device)) { | 794 | if (IS_ERR(iTCO_wdt_platform_device)) { |
801 | err = PTR_ERR(iTCO_wdt_platform_device); | 795 | err = PTR_ERR(iTCO_wdt_platform_device); |
802 | goto unreg_platform_driver; | 796 | goto unreg_platform_driver; |