12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/module.h>
16 #include <linux/types.h>
18 #include <linux/watchdog.h>
21 #include <linux/reboot.h>
26 #define GEODEWDT_HZ 500
27 #define GEODEWDT_SCALE 6
28 #define GEODEWDT_MAX_SECONDS 131
30 #define WDT_FLAGS_OPEN 1
31 #define WDT_FLAGS_ORPHAN 2
33 #define DRV_NAME "geodewdt"
34 #define WATCHDOG_NAME "Geode GX/LX WDT"
35 #define WATCHDOG_TIMEOUT 60
40 "Watchdog timeout in seconds. 1<= timeout <=131, default="
46 "Watchdog cannot be stopped once started (default="
50 static unsigned long wdt_flags;
52 static int safe_close;
54 static void geodewdt_ping(
void)
66 static void geodewdt_disable(
void)
72 static int geodewdt_set_heartbeat(
int val)
98 static int geodewdt_release(
struct inode *inode,
struct file *file)
104 pr_crit(
"Unexpected close - watchdog is not stopping\n");
115 static ssize_t geodewdt_write(
struct file *file,
const char __user *
data,
116 size_t len, loff_t *ppos)
123 for (i = 0; i != len; i++) {
139 static long geodewdt_ioctl(
struct file *file,
unsigned int cmd,
149 .firmware_version = 1,
156 sizeof(ident)) ? -
EFAULT : 0;
190 if (geodewdt_set_heartbeat(interval))
206 .write = geodewdt_write,
207 .unlocked_ioctl = geodewdt_ioctl,
208 .open = geodewdt_open,
209 .release = geodewdt_release,
215 .fops = &geodewdt_fops,
224 pr_err(
"No timers were available\n");
258 .probe = geodewdt_probe,
260 .shutdown = geodewdt_shutdown,
267 static int __init geodewdt_init(
void)
275 geodewdt_platform_device = platform_device_register_simple(
DRV_NAME,
277 if (IS_ERR(geodewdt_platform_device)) {
278 ret = PTR_ERR(geodewdt_platform_device);
288 static void __exit geodewdt_exit(
void)