33 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
35 #include <linux/module.h>
37 #include <linux/types.h>
39 #include <linux/watchdog.h>
43 #include <linux/reboot.h>
50 #define WATCHDOG_NAME "w83697ug/uf WDT"
51 #define WATCHDOG_TIMEOUT 60
53 static unsigned long wdt_is_open;
57 static int wdt_io = 0x2e;
64 "Watchdog timeout in seconds. 1<= timeout <=255 (default="
70 "Watchdog cannot be stopped once started (default="
77 #define WDT_EFER (wdt_io+0)
78 #define WDT_EFIR (wdt_io+0)
80 #define WDT_EFDR (WDT_EFIR+1)
82 static int w83697ug_select_wd_register(
void)
93 if (version == 0x68) {
94 pr_info(
"Watchdog chip version 0x%02x = W83697UG/UF found at 0x%04x\n",
104 pr_err(
"No W83697UG/UF could be found\n");
117 static void w83697ug_unselect_wd_register(
void)
122 static int w83697ug_init(
void)
127 ret = w83697ug_select_wd_register();
134 pr_info(
"Watchdog already running. Resetting timeout to %d sec\n",
144 w83697ug_unselect_wd_register();
148 static void wdt_ctrl(
int timeout)
152 if (w83697ug_select_wd_register() < 0) {
160 w83697ug_unselect_wd_register();
165 static int wdt_ping(
void)
171 static int wdt_disable(
void)
177 static int wdt_set_heartbeat(
int t)
179 if (t < 1 || t > 255)
187 size_t count, loff_t *ppos)
195 for (i = 0; i !=
count; i++) {
208 static long wdt_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
217 .firmware_version = 1,
218 .identity =
"W83697UG WDT",
258 if (wdt_set_heartbeat(new_timeout))
272 static int wdt_open(
struct inode *
inode,
struct file *file)
284 static int wdt_close(
struct inode *inode,
struct file *file)
286 if (expect_close == 42)
289 pr_crit(
"Unexpected close, not stopping watchdog!\n");
318 .unlocked_ioctl = wdt_ioctl,
320 .release = wdt_close,
335 .notifier_call = wdt_notify_sys,
342 pr_info(
"WDT driver for the Winbond(TM) W83697UG/UF Super I/O chip initialising\n");
344 if (wdt_set_heartbeat(timeout)) {
346 pr_info(
"timeout value must be 1<=timeout<=255, using %d\n",
351 pr_err(
"I/O address 0x%04x already in use\n", wdt_io);
356 ret = w83697ug_init();
362 pr_err(
"cannot register reboot notifier (err=%d)\n", ret);
368 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
373 pr_info(
"initialized. timeout=%d sec (nowayout=%d)\n",
385 static void __exit wdt_exit(
void)