22 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 #include <linux/module.h>
26 #include <linux/types.h>
27 #include <linux/errno.h>
37 #include <linux/watchdog.h>
42 static int port = 0x91;
43 static int ticks = 10000;
46 #define PFX "cpu5wdt: "
48 #define CPU5WDT_EXTENT 0x0A
50 #define CPU5WDT_STATUS_REG 0x00
51 #define CPU5WDT_TIME_A_REG 0x02
52 #define CPU5WDT_TIME_B_REG 0x03
53 #define CPU5WDT_MODE_REG 0x04
54 #define CPU5WDT_TRIGGER_REG 0x07
55 #define CPU5WDT_ENABLE_REG 0x08
56 #define CPU5WDT_RESET_REG 0x09
58 #define CPU5WDT_INTERVAL (HZ/10+1)
73 static void cpu5wdt_trigger(
unsigned long unused)
78 if (cpu5wdt_device.running)
81 spin_lock(&cpu5wdt_lock);
86 if (cpu5wdt_device.queue &&
ticks)
92 spin_unlock(&cpu5wdt_lock);
96 static void cpu5wdt_reset(
void)
98 ticks = cpu5wdt_device.default_ticks;
105 static void cpu5wdt_start(
void)
110 if (!cpu5wdt_device.queue) {
111 cpu5wdt_device.queue = 1;
120 cpu5wdt_device.running++;
121 spin_unlock_irqrestore(&cpu5wdt_lock, flags);
124 static int cpu5wdt_stop(
void)
129 if (cpu5wdt_device.running)
130 cpu5wdt_device.running = 0;
131 ticks = cpu5wdt_device.default_ticks;
132 spin_unlock_irqrestore(&cpu5wdt_lock, flags);
134 pr_crit(
"stop not possible\n");
147 static int cpu5wdt_release(
struct inode *inode,
struct file *file)
153 static long cpu5wdt_ioctl(
struct file *file,
unsigned int cmd,
161 .identity =
"CPU5 WDT",
171 value = (value >> 2) & 1;
192 static ssize_t cpu5wdt_write(
struct file *file,
const char __user *
buf,
193 size_t count, loff_t *ppos)
204 .unlocked_ioctl = cpu5wdt_ioctl,
205 .open = cpu5wdt_open,
206 .write = cpu5wdt_write,
207 .release = cpu5wdt_release,
213 .fops = &cpu5wdt_fops,
226 init_completion(&cpu5wdt_device.stop);
227 cpu5wdt_device.queue = 0;
228 setup_timer(&cpu5wdt_device.timer, cpu5wdt_trigger, 0);
229 cpu5wdt_device.default_ticks =
ticks;
232 pr_err(
"request_region failed\n");
239 val = (val >> 2) & 1;
241 pr_info(
"sorry, was my fault\n");
245 pr_err(
"misc_register failed\n");
259 static int __devinit cpu5wdt_init_module(
void)
261 return cpu5wdt_init();
266 if (cpu5wdt_device.queue) {
267 cpu5wdt_device.queue = 0;
277 static void __devexit cpu5wdt_exit_module(
void)