27 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29 #include <linux/module.h>
30 #include <linux/kernel.h>
33 #include <linux/device.h>
35 #include <linux/watchdog.h>
37 #include <mach/hardware.h>
40 static unsigned long wdt_status;
41 static unsigned long boot_status;
45 #define WDT_OK_TO_CLOSE 1
48 static unsigned long iop_watchdog_timeout(
void)
57 static int wdt_supports_disable(
void)
69 static void wdt_enable(
void)
77 spin_unlock(&wdt_lock);
81 static int wdt_disable(
void)
84 if (wdt_supports_disable()) {
89 spin_unlock(&wdt_lock);
107 static ssize_t iop_wdt_write(
struct file *file,
const char *
data,
size_t len,
116 for (i = 0; i != len; i++) {
132 .identity =
"iop watchdog",
135 static long iop_wdt_ioctl(
struct file *file,
136 unsigned int cmd,
unsigned long arg)
164 if (wdt_disable() == 0) {
184 ret =
put_user(iop_watchdog_timeout(), argp);
190 static int iop_wdt_release(
struct inode *inode,
struct file *file)
195 state = wdt_disable();
202 pr_crit(
"Device closed unexpectedly - reset in %lu seconds\n",
203 iop_watchdog_timeout());
215 .write = iop_wdt_write,
216 .unlocked_ioctl = iop_wdt_ioctl,
217 .open = iop_wdt_open,
218 .release = iop_wdt_release,
224 .fops = &iop_wdt_fops,
227 static int __init iop_wdt_init(
void)
243 pr_info(
"timeout %lu sec\n", iop_watchdog_timeout());
248 static void __exit iop_wdt_exit(
void)