29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #include <linux/module.h>
34 #include <linux/watchdog.h>
38 #include <linux/reboot.h>
44 #define WATCHDOG_NAME "Wafer 5823 WDT"
45 #define PFX WATCHDOG_NAME ": "
48 static unsigned long wafwdt_is_open;
61 static int wdt_stop = 0x843;
62 static int wdt_start = 0x443;
67 "Watchdog timeout in seconds. 1 <= timeout <= 255, default="
73 "Watchdog cannot be stopped once started (default="
76 static void wafwdt_ping(
void)
79 spin_lock(&wafwdt_lock);
82 spin_unlock(&wafwdt_lock);
85 static void wafwdt_start(
void)
88 outb_p(timeout, wdt_start);
92 static void wafwdt_stop(
void)
99 size_t count, loff_t *ppos)
111 for (i = 0; i !=
count; i++) {
126 static long wafwdt_ioctl(
struct file *file,
unsigned int cmd,
135 .firmware_version = 1,
136 .identity =
"Wafer 5823 WDT",
176 if ((new_timeout < 1) || (new_timeout > 255))
191 static int wafwdt_open(
struct inode *
inode,
struct file *file)
203 static int wafwdt_close(
struct inode *inode,
struct file *file)
205 if (expect_close == 42)
208 pr_crit(
"WDT device closed unexpectedly. WDT will not stop!\n");
235 .write = wafwdt_write,
236 .unlocked_ioctl = wafwdt_ioctl,
238 .release = wafwdt_close,
244 .fops = &wafwdt_fops,
253 .notifier_call = wafwdt_notify_sys,
256 static int __init wafwdt_init(
void)
260 pr_info(
"WDT driver for Wafer 5823 single board computer initialising\n");
262 if (timeout < 1 || timeout > 255) {
264 pr_info(
"timeout value must be 1 <= x <= 255, using %d\n",
268 if (wdt_stop != wdt_start) {
270 pr_err(
"I/O address 0x%04x already in use\n", wdt_stop);
277 pr_err(
"I/O address 0x%04x already in use\n", wdt_start);
284 pr_err(
"cannot register reboot notifier (err=%d)\n", ret);
290 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
295 pr_info(
"initialized. timeout=%d sec (nowayout=%d)\n",
304 if (wdt_stop != wdt_start)
310 static void __exit wafwdt_exit(
void)
314 if (wdt_stop != wdt_start)