12 #include <linux/bitops.h>
13 #include <linux/errno.h>
18 #include <linux/kernel.h>
20 #include <linux/module.h>
23 #include <linux/slab.h>
25 #include <linux/types.h>
26 #include <linux/watchdog.h>
30 #define WTCLK (0x01 << 10)
31 #define WTE (0x01 << 7)
32 #define WTIS (0x03 << 4)
33 #define WTIF (0x01 << 3)
34 #define WTRF (0x01 << 2)
35 #define WTRE (0x01 << 1)
36 #define WTR (0x01 << 0)
49 #define WDT_HW_TIMEOUT 0x02
50 #define WDT_TIMEOUT (HZ/2)
51 #define WDT_HEARTBEAT 15
74 static unsigned long nuc900wdt_busy;
77 static inline void nuc900_wdt_keepalive(
void)
90 static inline void nuc900_wdt_start(
void)
108 static inline void nuc900_wdt_stop(
void)
123 static inline void nuc900_wdt_ping(
void)
139 static int nuc900_wdt_close(
struct inode *inode,
struct file *file)
144 dev_crit(&nuc900_wdt->
pdev->dev,
145 "Unexpected close, not stopping watchdog!\n");
155 .identity =
"nuc900 watchdog",
160 static long nuc900_wdt_ioctl(
struct file *file,
161 unsigned int cmd,
unsigned long arg)
170 sizeof(nuc900_wdt_info)) ? -
EFAULT : 0;
194 static ssize_t nuc900_wdt_write(
struct file *file,
const char __user *
data,
195 size_t len, loff_t *ppos)
206 for (i = 0; i < len; i++) {
221 static void nuc900_wdt_timer_ping(
unsigned long data)
224 nuc900_wdt_keepalive();
227 dev_warn(&nuc900_wdt->
pdev->dev,
"Will reset the machine !\n");
233 .unlocked_ioctl = nuc900_wdt_ioctl,
234 .open = nuc900_wdt_open,
235 .release = nuc900_wdt_close,
236 .write = nuc900_wdt_write,
239 static struct miscdevice nuc900wdt_miscdev = {
242 .fops = &nuc900wdt_fops,
249 nuc900_wdt = kzalloc(
sizeof(
struct nuc900_wdt),
GFP_KERNEL);
253 nuc900_wdt->
pdev = pdev;
259 dev_err(&pdev->
dev,
"no memory resource specified\n");
265 resource_size(nuc900_wdt->
res), pdev->
name)) {
266 dev_err(&pdev->
dev,
"failed to get memory region\n");
272 resource_size(nuc900_wdt->
res));
274 dev_err(&pdev->
dev,
"failed to ioremap() region\n");
281 dev_err(&pdev->
dev,
"failed to find watchdog clock source\n");
292 dev_err(&pdev->
dev,
"err register miscdev on minor=%d (%d)\n",
306 resource_size(nuc900_wdt->
res));
322 resource_size(nuc900_wdt->
res));
330 .probe = nuc900wdt_probe,
333 .name =
"nuc900-wdt",