42 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
45 #define WATCHDOG_NAME "mixcomwd"
47 #include <linux/module.h>
49 #include <linux/types.h>
52 #include <linux/watchdog.h>
54 #include <linux/reboot.h>
71 #define MIXCOM_ID 0x11
72 #define FLASHCOM_ID 0x18
102 static void mixcomwd_timerfun(
unsigned long d);
104 static unsigned long mixcomwd_opened;
106 static int watchdog_port;
107 static int mixcomwd_timer_alive;
108 static DEFINE_TIMER(mixcomwd_timer, mixcomwd_timerfun, 0, 0);
114 "Watchdog cannot be stopped once started (default="
117 static void mixcomwd_ping(
void)
119 outb_p(55, watchdog_port);
123 static void mixcomwd_timerfun(
unsigned long d)
148 if (mixcomwd_timer_alive) {
150 mixcomwd_timer_alive = 0;
156 static int mixcomwd_release(
struct inode *inode,
struct file *file)
158 if (expect_close == 42) {
159 if (mixcomwd_timer_alive) {
160 pr_err(
"release called while internal timer alive\n");
163 mixcomwd_timer_alive = 1;
166 pr_crit(
"WDT device closed unexpectedly. WDT will not stop!\n");
174 static ssize_t mixcomwd_write(
struct file *file,
const char __user *
data,
175 size_t len, loff_t *ppos)
184 for (i = 0; i != len; i++) {
197 static long mixcomwd_ioctl(
struct file *file,
198 unsigned int cmd,
unsigned long arg)
205 .firmware_version = 1,
206 .identity =
"MixCOM watchdog",
215 status = mixcomwd_opened;
217 status |= mixcomwd_timer_alive;
233 .write = mixcomwd_write,
234 .unlocked_ioctl = mixcomwd_ioctl,
235 .open = mixcomwd_open,
236 .release = mixcomwd_release,
242 .fops = &mixcomwd_fops,
245 static int __init checkcard(
int port,
int card_id)
263 static int __init mixcomwd_init(
void)
265 int i,
ret, found = 0;
267 for (i = 0; !found && mixcomwd_io_info[
i].ioport != 0; i++) {
268 if (checkcard(mixcomwd_io_info[i].
ioport,
269 mixcomwd_io_info[i].
id)) {
271 watchdog_port = mixcomwd_io_info[
i].ioport;
276 pr_err(
"No card detected, or port not available\n");
282 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
284 goto error_misc_register_watchdog;
287 pr_info(
"MixCOM watchdog driver v%s, watchdog port at 0x%3x\n",
292 error_misc_register_watchdog:
294 watchdog_port = 0x0000;
298 static void __exit mixcomwd_exit(
void)
301 if (mixcomwd_timer_alive) {
302 pr_warn(
"I quit now, hardware will probably reboot!\n");
304 mixcomwd_timer_alive = 0;