diff options
author | Steve French <sfrench@us.ibm.com> | 2006-01-17 22:49:59 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-01-17 22:49:59 -0500 |
commit | d65177c1ae7f085723154105c5dc8d9e16ae8265 (patch) | |
tree | 14408129d880d89cc5e937f2810f243ed1e6fcde /drivers/char/watchdog | |
parent | d41f084a74de860fe879403fbbad13abdf7aea8e (diff) | |
parent | 15578eeb6cd4b74492f26e60624aa1a9a52ddd7b (diff) |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'drivers/char/watchdog')
-rw-r--r-- | drivers/char/watchdog/Kconfig | 26 | ||||
-rw-r--r-- | drivers/char/watchdog/Makefile | 2 | ||||
-rw-r--r-- | drivers/char/watchdog/mpc83xx_wdt.c | 229 | ||||
-rw-r--r-- | drivers/char/watchdog/sa1100_wdt.c | 12 | ||||
-rw-r--r-- | drivers/char/watchdog/sbc_epx_c3.c | 216 |
5 files changed, 479 insertions, 6 deletions
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index a6544790af60..c0dfcf273f0a 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig | |||
@@ -395,12 +395,38 @@ config MACHZ_WDT | |||
395 | To compile this driver as a module, choose M here: the | 395 | To compile this driver as a module, choose M here: the |
396 | module will be called machzwd. | 396 | module will be called machzwd. |
397 | 397 | ||
398 | config SBC_EPX_C3_WATCHDOG | ||
399 | tristate "Winsystems SBC EPX-C3 watchdog" | ||
400 | depends on WATCHDOG && X86 | ||
401 | ---help--- | ||
402 | This is the driver for the built-in watchdog timer on the EPX-C3 | ||
403 | Single-board computer made by Winsystems, Inc. | ||
404 | |||
405 | *Note*: This hardware watchdog is not probeable and thus there | ||
406 | is no way to know if writing to its IO address will corrupt | ||
407 | your system or have any real effect. The only way to be sure | ||
408 | that this driver does what you want is to make sure you | ||
409 | are runnning it on an EPX-C3 from Winsystems with the watchdog | ||
410 | timer at IO address 0x1ee and 0x1ef. It will write to both those | ||
411 | IO ports. Basically, the assumption is made that if you compile | ||
412 | this driver into your kernel and/or load it as a module, that you | ||
413 | know what you are doing and that you are in fact running on an | ||
414 | EPX-C3 board! | ||
415 | |||
416 | To compile this driver as a module, choose M here: the | ||
417 | module will be called sbc_epx_c3. | ||
418 | |||
419 | |||
398 | # PowerPC Architecture | 420 | # PowerPC Architecture |
399 | 421 | ||
400 | config 8xx_WDT | 422 | config 8xx_WDT |
401 | tristate "MPC8xx Watchdog Timer" | 423 | tristate "MPC8xx Watchdog Timer" |
402 | depends on WATCHDOG && 8xx | 424 | depends on WATCHDOG && 8xx |
403 | 425 | ||
426 | config 83xx_WDT | ||
427 | tristate "MPC83xx Watchdog Timer" | ||
428 | depends on WATCHDOG && PPC_83xx | ||
429 | |||
404 | config MV64X60_WDT | 430 | config MV64X60_WDT |
405 | tristate "MV64X60 (Marvell Discovery) Watchdog Timer" | 431 | tristate "MV64X60 (Marvell Discovery) Watchdog Timer" |
406 | depends on WATCHDOG && MV64X60 | 432 | depends on WATCHDOG && MV64X60 |
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index cfd0a3987710..36c0b282b8ba 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile | |||
@@ -52,9 +52,11 @@ obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o | |||
52 | obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o | 52 | obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o |
53 | obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o | 53 | obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o |
54 | obj-$(CONFIG_MACHZ_WDT) += machzwd.o | 54 | obj-$(CONFIG_MACHZ_WDT) += machzwd.o |
55 | obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o | ||
55 | 56 | ||
56 | # PowerPC Architecture | 57 | # PowerPC Architecture |
57 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o | 58 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o |
59 | obj-$(CONFIG_83xx_WDT) += mpc83xx_wdt.o | ||
58 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o | 60 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o |
59 | obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o | 61 | obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o |
60 | 62 | ||
diff --git a/drivers/char/watchdog/mpc83xx_wdt.c b/drivers/char/watchdog/mpc83xx_wdt.c new file mode 100644 index 000000000000..5d6f5061603a --- /dev/null +++ b/drivers/char/watchdog/mpc83xx_wdt.c | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * mpc83xx_wdt.c - MPC83xx watchdog userspace interface | ||
3 | * | ||
4 | * Authors: Dave Updegraff <dave@cray.org> | ||
5 | * Kumar Gala <galak@kernel.crashing.org> | ||
6 | * Attribution: from 83xx_wst: Florian Schirmer <jolt@tuxbox.org> | ||
7 | * ..and from sc520_wdt | ||
8 | * | ||
9 | * Note: it appears that you can only actually ENABLE or DISABLE the thing | ||
10 | * once after POR. Once enabled, you cannot disable, and vice versa. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License as published by the | ||
14 | * Free Software Foundation; either version 2 of the License, or (at your | ||
15 | * option) any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/config.h> | ||
19 | #include <linux/fs.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/miscdevice.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/watchdog.h> | ||
26 | #include <asm/io.h> | ||
27 | #include <asm/uaccess.h> | ||
28 | |||
29 | struct mpc83xx_wdt { | ||
30 | __be32 res0; | ||
31 | __be32 swcrr; /* System watchdog control register */ | ||
32 | #define SWCRR_SWTC 0xFFFF0000 /* Software Watchdog Time Count. */ | ||
33 | #define SWCRR_SWEN 0x00000004 /* Watchdog Enable bit. */ | ||
34 | #define SWCRR_SWRI 0x00000002 /* Software Watchdog Reset/Interrupt Select bit.*/ | ||
35 | #define SWCRR_SWPR 0x00000001 /* Software Watchdog Counter Prescale bit. */ | ||
36 | __be32 swcnr; /* System watchdog count register */ | ||
37 | u8 res1[2]; | ||
38 | __be16 swsrr; /* System watchdog service register */ | ||
39 | u8 res2[0xF0]; | ||
40 | }; | ||
41 | |||
42 | static struct mpc83xx_wdt __iomem *wd_base; | ||
43 | |||
44 | static u16 timeout = 0xffff; | ||
45 | module_param(timeout, ushort, 0); | ||
46 | MODULE_PARM_DESC(timeout, "Watchdog timeout in ticks. (0<timeout<65536, default=65535"); | ||
47 | |||
48 | static int reset = 1; | ||
49 | module_param(reset, bool, 0); | ||
50 | MODULE_PARM_DESC(reset, "Watchdog Interrupt/Reset Mode. 0 = interrupt, 1 = reset"); | ||
51 | |||
52 | /* | ||
53 | * We always prescale, but if someone really doesn't want to they can set this | ||
54 | * to 0 | ||
55 | */ | ||
56 | static int prescale = 1; | ||
57 | static unsigned int timeout_sec; | ||
58 | |||
59 | static unsigned long wdt_is_open; | ||
60 | static spinlock_t wdt_spinlock; | ||
61 | |||
62 | static void mpc83xx_wdt_keepalive(void) | ||
63 | { | ||
64 | /* Ping the WDT */ | ||
65 | spin_lock(&wdt_spinlock); | ||
66 | out_be16(&wd_base->swsrr, 0x556c); | ||
67 | out_be16(&wd_base->swsrr, 0xaa39); | ||
68 | spin_unlock(&wdt_spinlock); | ||
69 | } | ||
70 | |||
71 | static ssize_t mpc83xx_wdt_write(struct file *file, const char __user *buf, | ||
72 | size_t count, loff_t *ppos) | ||
73 | { | ||
74 | if (count) | ||
75 | mpc83xx_wdt_keepalive(); | ||
76 | return count; | ||
77 | } | ||
78 | |||
79 | static int mpc83xx_wdt_open(struct inode *inode, struct file *file) | ||
80 | { | ||
81 | u32 tmp = SWCRR_SWEN; | ||
82 | if (test_and_set_bit(0, &wdt_is_open)) | ||
83 | return -EBUSY; | ||
84 | |||
85 | /* Once we start the watchdog we can't stop it */ | ||
86 | __module_get(THIS_MODULE); | ||
87 | |||
88 | /* Good, fire up the show */ | ||
89 | if (prescale) | ||
90 | tmp |= SWCRR_SWPR; | ||
91 | if (reset) | ||
92 | tmp |= SWCRR_SWRI; | ||
93 | |||
94 | tmp |= timeout << 16; | ||
95 | |||
96 | out_be32(&wd_base->swcrr, tmp); | ||
97 | |||
98 | return nonseekable_open(inode, file); | ||
99 | } | ||
100 | |||
101 | static int mpc83xx_wdt_release(struct inode *inode, struct file *file) | ||
102 | { | ||
103 | printk(KERN_CRIT "Unexpected close, not stopping watchdog!\n"); | ||
104 | mpc83xx_wdt_keepalive(); | ||
105 | clear_bit(0, &wdt_is_open); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static int mpc83xx_wdt_ioctl(struct inode *inode, struct file *file, | ||
110 | unsigned int cmd, unsigned long arg) | ||
111 | { | ||
112 | void __user *argp = (void __user *)arg; | ||
113 | int __user *p = argp; | ||
114 | static struct watchdog_info ident = { | ||
115 | .options = WDIOF_KEEPALIVEPING, | ||
116 | .firmware_version = 1, | ||
117 | .identity = "MPC83xx", | ||
118 | }; | ||
119 | |||
120 | switch (cmd) { | ||
121 | case WDIOC_GETSUPPORT: | ||
122 | return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; | ||
123 | case WDIOC_KEEPALIVE: | ||
124 | mpc83xx_wdt_keepalive(); | ||
125 | return 0; | ||
126 | case WDIOC_GETTIMEOUT: | ||
127 | return put_user(timeout_sec, p); | ||
128 | default: | ||
129 | return -ENOIOCTLCMD; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | static struct file_operations mpc83xx_wdt_fops = { | ||
134 | .owner = THIS_MODULE, | ||
135 | .llseek = no_llseek, | ||
136 | .write = mpc83xx_wdt_write, | ||
137 | .ioctl = mpc83xx_wdt_ioctl, | ||
138 | .open = mpc83xx_wdt_open, | ||
139 | .release = mpc83xx_wdt_release, | ||
140 | }; | ||
141 | |||
142 | static struct miscdevice mpc83xx_wdt_miscdev = { | ||
143 | .minor = WATCHDOG_MINOR, | ||
144 | .name = "watchdog", | ||
145 | .fops = &mpc83xx_wdt_fops, | ||
146 | }; | ||
147 | |||
148 | static int __devinit mpc83xx_wdt_probe(struct platform_device *dev) | ||
149 | { | ||
150 | struct resource *r; | ||
151 | int ret; | ||
152 | unsigned int *freq = dev->dev.platform_data; | ||
153 | |||
154 | /* get a pointer to the register memory */ | ||
155 | r = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
156 | |||
157 | if (!r) { | ||
158 | ret = -ENODEV; | ||
159 | goto err_out; | ||
160 | } | ||
161 | |||
162 | wd_base = ioremap(r->start, sizeof (struct mpc83xx_wdt)); | ||
163 | |||
164 | if (wd_base == NULL) { | ||
165 | ret = -ENOMEM; | ||
166 | goto err_out; | ||
167 | } | ||
168 | |||
169 | ret = misc_register(&mpc83xx_wdt_miscdev); | ||
170 | if (ret) { | ||
171 | printk(KERN_ERR "cannot register miscdev on minor=%d " | ||
172 | "(err=%d)\n", | ||
173 | WATCHDOG_MINOR, ret); | ||
174 | goto err_unmap; | ||
175 | } | ||
176 | |||
177 | /* Calculate the timeout in seconds */ | ||
178 | if (prescale) | ||
179 | timeout_sec = (timeout * 0x10000) / (*freq); | ||
180 | else | ||
181 | timeout_sec = timeout / (*freq); | ||
182 | |||
183 | printk(KERN_INFO "WDT driver for MPC83xx initialized. " | ||
184 | "mode:%s timeout=%d (%d seconds)\n", | ||
185 | reset ? "reset":"interrupt", timeout, timeout_sec); | ||
186 | |||
187 | spin_lock_init(&wdt_spinlock); | ||
188 | |||
189 | return 0; | ||
190 | |||
191 | err_unmap: | ||
192 | iounmap(wd_base); | ||
193 | err_out: | ||
194 | return ret; | ||
195 | } | ||
196 | |||
197 | static int __devexit mpc83xx_wdt_remove(struct platform_device *dev) | ||
198 | { | ||
199 | misc_deregister(&mpc83xx_wdt_miscdev); | ||
200 | iounmap(wd_base); | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static struct platform_driver mpc83xx_wdt_driver = { | ||
206 | .probe = mpc83xx_wdt_probe, | ||
207 | .remove = __devexit_p(mpc83xx_wdt_remove), | ||
208 | .driver = { | ||
209 | .name = "mpc83xx_wdt", | ||
210 | }, | ||
211 | }; | ||
212 | |||
213 | static int __init mpc83xx_wdt_init(void) | ||
214 | { | ||
215 | return platform_driver_register(&mpc83xx_wdt_driver); | ||
216 | } | ||
217 | |||
218 | static void __exit mpc83xx_wdt_exit(void) | ||
219 | { | ||
220 | platform_driver_unregister(&mpc83xx_wdt_driver); | ||
221 | } | ||
222 | |||
223 | module_init(mpc83xx_wdt_init); | ||
224 | module_exit(mpc83xx_wdt_exit); | ||
225 | |||
226 | MODULE_AUTHOR("Dave Updegraff, Kumar Gala"); | ||
227 | MODULE_DESCRIPTION("Driver for watchdog timer in MPC83xx uProcessor"); | ||
228 | MODULE_LICENSE("GPL"); | ||
229 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/char/watchdog/sa1100_wdt.c b/drivers/char/watchdog/sa1100_wdt.c index fb88b4041dca..b474ea52d6e8 100644 --- a/drivers/char/watchdog/sa1100_wdt.c +++ b/drivers/char/watchdog/sa1100_wdt.c | |||
@@ -74,7 +74,7 @@ static int sa1100dog_release(struct inode *inode, struct file *file) | |||
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | static ssize_t sa1100dog_write(struct file *file, const char *data, size_t len, loff_t *ppos) | 77 | static ssize_t sa1100dog_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) |
78 | { | 78 | { |
79 | if (len) | 79 | if (len) |
80 | /* Refresh OSMR3 timer. */ | 80 | /* Refresh OSMR3 timer. */ |
@@ -96,20 +96,20 @@ static int sa1100dog_ioctl(struct inode *inode, struct file *file, | |||
96 | 96 | ||
97 | switch (cmd) { | 97 | switch (cmd) { |
98 | case WDIOC_GETSUPPORT: | 98 | case WDIOC_GETSUPPORT: |
99 | ret = copy_to_user((struct watchdog_info *)arg, &ident, | 99 | ret = copy_to_user((struct watchdog_info __user *)arg, &ident, |
100 | sizeof(ident)) ? -EFAULT : 0; | 100 | sizeof(ident)) ? -EFAULT : 0; |
101 | break; | 101 | break; |
102 | 102 | ||
103 | case WDIOC_GETSTATUS: | 103 | case WDIOC_GETSTATUS: |
104 | ret = put_user(0, (int *)arg); | 104 | ret = put_user(0, (int __user *)arg); |
105 | break; | 105 | break; |
106 | 106 | ||
107 | case WDIOC_GETBOOTSTATUS: | 107 | case WDIOC_GETBOOTSTATUS: |
108 | ret = put_user(boot_status, (int *)arg); | 108 | ret = put_user(boot_status, (int __user *)arg); |
109 | break; | 109 | break; |
110 | 110 | ||
111 | case WDIOC_SETTIMEOUT: | 111 | case WDIOC_SETTIMEOUT: |
112 | ret = get_user(time, (int *)arg); | 112 | ret = get_user(time, (int __user *)arg); |
113 | if (ret) | 113 | if (ret) |
114 | break; | 114 | break; |
115 | 115 | ||
@@ -123,7 +123,7 @@ static int sa1100dog_ioctl(struct inode *inode, struct file *file, | |||
123 | /*fall through*/ | 123 | /*fall through*/ |
124 | 124 | ||
125 | case WDIOC_GETTIMEOUT: | 125 | case WDIOC_GETTIMEOUT: |
126 | ret = put_user(pre_margin / OSCR_FREQ, (int *)arg); | 126 | ret = put_user(pre_margin / OSCR_FREQ, (int __user *)arg); |
127 | break; | 127 | break; |
128 | 128 | ||
129 | case WDIOC_KEEPALIVE: | 129 | case WDIOC_KEEPALIVE: |
diff --git a/drivers/char/watchdog/sbc_epx_c3.c b/drivers/char/watchdog/sbc_epx_c3.c new file mode 100644 index 000000000000..951764614ebf --- /dev/null +++ b/drivers/char/watchdog/sbc_epx_c3.c | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | * SBC EPX C3 0.1 A Hardware Watchdog Device for the Winsystems EPX-C3 | ||
3 | * single board computer | ||
4 | * | ||
5 | * (c) Copyright 2006 Calin A. Culianu <calin@ajvar.org>, All Rights | ||
6 | * Reserved. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * based on softdog.c by Alan Cox <alan@redhat.com> | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/moduleparam.h> | ||
18 | #include <linux/config.h> | ||
19 | #include <linux/types.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/fs.h> | ||
22 | #include <linux/mm.h> | ||
23 | #include <linux/miscdevice.h> | ||
24 | #include <linux/watchdog.h> | ||
25 | #include <linux/notifier.h> | ||
26 | #include <linux/reboot.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <asm/uaccess.h> | ||
29 | #include <asm/io.h> | ||
30 | |||
31 | #define PFX "epx_c3: " | ||
32 | static int epx_c3_alive; | ||
33 | |||
34 | #define WATCHDOG_TIMEOUT 1 /* 1 sec default timeout */ | ||
35 | |||
36 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
37 | module_param(nowayout, int, 0); | ||
38 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | ||
39 | |||
40 | #define EPXC3_WATCHDOG_CTL_REG 0x1ee /* write 1 to enable, 0 to disable */ | ||
41 | #define EPXC3_WATCHDOG_PET_REG 0x1ef /* write anything to pet once enabled */ | ||
42 | |||
43 | static void epx_c3_start(void) | ||
44 | { | ||
45 | outb(1, EPXC3_WATCHDOG_CTL_REG); | ||
46 | } | ||
47 | |||
48 | static void epx_c3_stop(void) | ||
49 | { | ||
50 | |||
51 | outb(0, EPXC3_WATCHDOG_CTL_REG); | ||
52 | |||
53 | printk(KERN_INFO PFX "Stopped watchdog timer.\n"); | ||
54 | } | ||
55 | |||
56 | static void epx_c3_pet(void) | ||
57 | { | ||
58 | outb(1, EPXC3_WATCHDOG_PET_REG); | ||
59 | } | ||
60 | |||
61 | /* | ||
62 | * Allow only one person to hold it open | ||
63 | */ | ||
64 | static int epx_c3_open(struct inode *inode, struct file *file) | ||
65 | { | ||
66 | if (epx_c3_alive) | ||
67 | return -EBUSY; | ||
68 | |||
69 | if (nowayout) | ||
70 | __module_get(THIS_MODULE); | ||
71 | |||
72 | /* Activate timer */ | ||
73 | epx_c3_start(); | ||
74 | epx_c3_pet(); | ||
75 | |||
76 | epx_c3_alive = 1; | ||
77 | printk(KERN_INFO "Started watchdog timer.\n"); | ||
78 | |||
79 | return nonseekable_open(inode, file); | ||
80 | } | ||
81 | |||
82 | static int epx_c3_release(struct inode *inode, struct file *file) | ||
83 | { | ||
84 | /* Shut off the timer. | ||
85 | * Lock it in if it's a module and we defined ...NOWAYOUT */ | ||
86 | if (!nowayout) | ||
87 | epx_c3_stop(); /* Turn the WDT off */ | ||
88 | |||
89 | epx_c3_alive = 0; | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static ssize_t epx_c3_write(struct file *file, const char *data, | ||
95 | size_t len, loff_t *ppos) | ||
96 | { | ||
97 | /* Refresh the timer. */ | ||
98 | if (len) | ||
99 | epx_c3_pet(); | ||
100 | return len; | ||
101 | } | ||
102 | |||
103 | static int epx_c3_ioctl(struct inode *inode, struct file *file, | ||
104 | unsigned int cmd, unsigned long arg) | ||
105 | { | ||
106 | int options, retval = -EINVAL; | ||
107 | static struct watchdog_info ident = { | ||
108 | .options = WDIOF_KEEPALIVEPING | | ||
109 | WDIOF_MAGICCLOSE, | ||
110 | .firmware_version = 0, | ||
111 | .identity = "Winsystems EPX-C3 H/W Watchdog", | ||
112 | }; | ||
113 | |||
114 | switch (cmd) { | ||
115 | case WDIOC_GETSUPPORT: | ||
116 | if (copy_to_user((struct watchdog_info *)arg, | ||
117 | &ident, sizeof(ident))) | ||
118 | return -EFAULT; | ||
119 | return 0; | ||
120 | case WDIOC_GETSTATUS: | ||
121 | case WDIOC_GETBOOTSTATUS: | ||
122 | return put_user(0,(int *)arg); | ||
123 | case WDIOC_KEEPALIVE: | ||
124 | epx_c3_pet(); | ||
125 | return 0; | ||
126 | case WDIOC_GETTIMEOUT: | ||
127 | return put_user(WATCHDOG_TIMEOUT,(int *)arg); | ||
128 | case WDIOC_SETOPTIONS: { | ||
129 | if (get_user(options, (int *)arg)) | ||
130 | return -EFAULT; | ||
131 | |||
132 | if (options & WDIOS_DISABLECARD) { | ||
133 | epx_c3_stop(); | ||
134 | retval = 0; | ||
135 | } | ||
136 | |||
137 | if (options & WDIOS_ENABLECARD) { | ||
138 | epx_c3_start(); | ||
139 | retval = 0; | ||
140 | } | ||
141 | |||
142 | return retval; | ||
143 | } | ||
144 | default: | ||
145 | return -ENOIOCTLCMD; | ||
146 | } | ||
147 | } | ||
148 | |||
149 | static int epx_c3_notify_sys(struct notifier_block *this, unsigned long code, | ||
150 | void *unused) | ||
151 | { | ||
152 | if (code == SYS_DOWN || code == SYS_HALT) | ||
153 | epx_c3_stop(); /* Turn the WDT off */ | ||
154 | |||
155 | return NOTIFY_DONE; | ||
156 | } | ||
157 | |||
158 | static struct file_operations epx_c3_fops = { | ||
159 | .owner = THIS_MODULE, | ||
160 | .llseek = no_llseek, | ||
161 | .write = epx_c3_write, | ||
162 | .ioctl = epx_c3_ioctl, | ||
163 | .open = epx_c3_open, | ||
164 | .release = epx_c3_release, | ||
165 | }; | ||
166 | |||
167 | static struct miscdevice epx_c3_miscdev = { | ||
168 | .minor = WATCHDOG_MINOR, | ||
169 | .name = "watchdog", | ||
170 | .fops = &epx_c3_fops, | ||
171 | }; | ||
172 | |||
173 | static struct notifier_block epx_c3_notifier = { | ||
174 | .notifier_call = epx_c3_notify_sys, | ||
175 | }; | ||
176 | |||
177 | static const char banner[] __initdata = | ||
178 | KERN_INFO PFX "Hardware Watchdog Timer for Winsystems EPX-C3 SBC: 0.1\n"; | ||
179 | |||
180 | static int __init watchdog_init(void) | ||
181 | { | ||
182 | int ret; | ||
183 | |||
184 | ret = register_reboot_notifier(&epx_c3_notifier); | ||
185 | if (ret) { | ||
186 | printk(KERN_ERR PFX "cannot register reboot notifier " | ||
187 | "(err=%d)\n", ret); | ||
188 | return ret; | ||
189 | } | ||
190 | |||
191 | ret = misc_register(&epx_c3_miscdev); | ||
192 | if (ret) { | ||
193 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d " | ||
194 | "(err=%d)\n", WATCHDOG_MINOR, ret); | ||
195 | unregister_reboot_notifier(&epx_c3_notifier); | ||
196 | return ret; | ||
197 | } | ||
198 | |||
199 | printk(banner); | ||
200 | |||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static void __exit watchdog_exit(void) | ||
205 | { | ||
206 | misc_deregister(&epx_c3_miscdev); | ||
207 | unregister_reboot_notifier(&epx_c3_notifier); | ||
208 | } | ||
209 | |||
210 | module_init(watchdog_init); | ||
211 | module_exit(watchdog_exit); | ||
212 | |||
213 | MODULE_AUTHOR("Calin A. Culianu <calin@ajvar.org>"); | ||
214 | MODULE_DESCRIPTION("Hardware Watchdog Device for Winsystems EPX-C3 SBC. Note that there is no way to probe for this device -- so only use it if you are *sure* you are runnning on this specific SBC system from Winsystems! It writes to IO ports 0x1ee and 0x1ef!"); | ||
215 | MODULE_LICENSE("GPL"); | ||
216 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||