29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #include <linux/module.h>
33 #include <linux/types.h>
35 #include <linux/watchdog.h>
39 #include <linux/reboot.h>
46 #define WATCHDOG_NAME "w83627hf/thf/hg/dhg WDT"
47 #define WATCHDOG_TIMEOUT 60
49 static unsigned long wdt_is_open;
54 static int wdt_io = 0x2E;
61 "Watchdog timeout in seconds. 1 <= timeout <= 255, default="
67 "Watchdog cannot be stopped once started (default="
74 #define WDT_EFER (wdt_io+0)
75 #define WDT_EFIR (wdt_io+0)
77 #define WDT_EFDR (WDT_EFIR+1)
79 static void w83627hf_select_wd_register(
void)
92 }
else if (c == 0x88 || c == 0xa0) {
105 static void w83627hf_unselect_wd_register(
void)
113 static void w83627hf_init(
void)
117 w83627hf_select_wd_register();
122 pr_info(
"Watchdog already running. Resetting timeout to %d sec\n",
141 w83627hf_unselect_wd_register();
144 static void wdt_set_time(
int timeout)
148 w83627hf_select_wd_register();
153 w83627hf_unselect_wd_register();
158 static int wdt_ping(
void)
160 wdt_set_time(timeout);
164 static int wdt_disable(
void)
170 static int wdt_set_heartbeat(
int t)
172 if (t < 1 || t > 255)
178 static int wdt_get_time(
void)
184 w83627hf_select_wd_register();
189 w83627hf_unselect_wd_register();
197 size_t count, loff_t *ppos)
205 for (i = 0; i !=
count; i++) {
218 static long wdt_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
226 .firmware_version = 1,
227 .identity =
"W83627HF WDT",
260 if (wdt_set_heartbeat(timeval))
267 timeval = wdt_get_time();
275 static int wdt_open(
struct inode *
inode,
struct file *file)
287 static int wdt_close(
struct inode *inode,
struct file *file)
289 if (expect_close == 42)
292 pr_crit(
"Unexpected close, not stopping watchdog!\n");
321 .unlocked_ioctl = wdt_ioctl,
323 .release = wdt_close,
338 .notifier_call = wdt_notify_sys,
345 pr_info(
"WDT driver for the Winbond(TM) W83627HF/THF/HG/DHG Super I/O chip initialising\n");
347 if (wdt_set_heartbeat(timeout)) {
349 pr_info(
"timeout value must be 1 <= timeout <= 255, using %d\n",
354 pr_err(
"I/O address 0x%04x already in use\n", wdt_io);
363 pr_err(
"cannot register reboot notifier (err=%d)\n", ret);
369 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
374 pr_info(
"initialized. timeout=%d sec (nowayout=%d)\n",
386 static void __exit wdt_exit(
void)