34 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
36 #include <linux/module.h>
37 #include <linux/types.h>
39 #include <linux/watchdog.h>
51 static unsigned long ibwdt_is_open;
56 #define DRV_NAME "ib700wdt"
94 #define WDT_STOP 0x441
95 #define WDT_START 0x443
98 #define WATCHDOG_TIMEOUT 30
102 "Watchdog timeout in seconds. 0<= timeout <=30, default="
108 "Watchdog cannot be stopped once started (default="
116 static void ibwdt_ping(
void)
118 int wd_margin = 15 - ((
timeout + 1) / 2);
120 spin_lock(&ibwdt_lock);
125 spin_unlock(&ibwdt_lock);
128 static void ibwdt_disable(
void)
130 spin_lock(&ibwdt_lock);
132 spin_unlock(&ibwdt_lock);
135 static int ibwdt_set_heartbeat(
int t)
149 size_t count, loff_t *ppos)
158 for (i = 0; i !=
count; i++) {
171 static long ibwdt_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
180 .firmware_version = 1,
181 .identity =
"IB700 WDT",
218 if (ibwdt_set_heartbeat(new_margin))
232 static int ibwdt_open(
struct inode *
inode,
struct file *file)
244 static int ibwdt_close(
struct inode *inode,
struct file *file)
246 if (expect_close == 42) {
249 pr_crit(
"WDT device closed unexpectedly. WDT will not stop!\n");
264 .write = ibwdt_write,
265 .unlocked_ioctl = ibwdt_ioctl,
267 .release = ibwdt_close,
284 #if WDT_START != WDT_STOP
300 if (ibwdt_set_heartbeat(timeout)) {
302 pr_info(
"timeout value must be 0<=x<=30, using %d\n", timeout);
307 pr_err(
"failed to register misc device\n");
315 #if WDT_START != WDT_STOP
326 #if WDT_START != WDT_STOP
339 .probe = ibwdt_probe,
341 .shutdown = ibwdt_shutdown,
348 static int __init ibwdt_init(
void)
352 pr_info(
"WDT driver for IB700 single board computer initialising\n");
358 ibwdt_platform_device = platform_device_register_simple(
DRV_NAME,
360 if (IS_ERR(ibwdt_platform_device)) {
361 err = PTR_ERR(ibwdt_platform_device);
362 goto unreg_platform_driver;
367 unreg_platform_driver:
372 static void __exit ibwdt_exit(
void)
376 pr_info(
"Watchdog Module Unloaded\n");