37 #include <linux/module.h>
39 #include <linux/types.h>
40 #include <linux/errno.h>
48 #include <linux/watchdog.h>
56 #define MTX1_WDT_INTERVAL (5 * HZ)
72 static void mtx1_wdt_trigger(
unsigned long unused)
74 spin_lock(&mtx1_wdt_device.lock);
75 if (mtx1_wdt_device.running)
79 mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate;
82 if (mtx1_wdt_device.queue &&
ticks)
86 spin_unlock(&mtx1_wdt_device.lock);
89 static void mtx1_wdt_reset(
void)
91 ticks = mtx1_wdt_device.default_ticks;
95 static void mtx1_wdt_start(
void)
100 if (!mtx1_wdt_device.queue) {
101 mtx1_wdt_device.queue = 1;
102 mtx1_wdt_device.gstate = 1;
106 mtx1_wdt_device.running++;
107 spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
110 static int mtx1_wdt_stop(
void)
115 if (mtx1_wdt_device.queue) {
116 mtx1_wdt_device.queue = 0;
117 mtx1_wdt_device.gstate = 0;
120 ticks = mtx1_wdt_device.default_ticks;
121 spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
135 static int mtx1_wdt_release(
struct inode *inode,
struct file *file)
141 static long mtx1_wdt_ioctl(
struct file *file,
unsigned int cmd,
149 .identity =
"MTX-1 WDT",
181 static ssize_t mtx1_wdt_write(
struct file *file,
const char *
buf,
182 size_t count, loff_t *ppos)
193 .unlocked_ioctl = mtx1_wdt_ioctl,
194 .open = mtx1_wdt_open,
195 .write = mtx1_wdt_write,
196 .release = mtx1_wdt_release,
203 .fops = &mtx1_wdt_fops,
211 mtx1_wdt_device.gpio = pdev->
resource[0].start;
215 dev_err(&pdev->
dev,
"failed to request gpio");
220 init_completion(&mtx1_wdt_device.stop);
221 mtx1_wdt_device.queue = 0;
223 setup_timer(&mtx1_wdt_device.timer, mtx1_wdt_trigger, 0L);
224 mtx1_wdt_device.default_ticks =
ticks;
239 if (mtx1_wdt_device.queue) {
240 mtx1_wdt_device.queue = 0;
250 .probe = mtx1_wdt_probe,
252 .driver.name =
"mtx1-wdt",