1 #include <linux/autoconf.h>
2 #include <linux/module.h>
3 #include <linux/types.h>
4 #include <linux/miscdevice.h>
5 #include <linux/watchdog.h>
7 #include <linux/jiffies.h>
8 #include <linux/timer.h>
11 #include <asm/uaccess.h>
12 #include <asm/system.h>
13 #include <asm/bootinfo.h>
15 extern unsigned long mips_machtype
;
17 static unsigned long wdt_is_open
;
18 static struct timer_list wdt_timer
;
20 static void wdt_merlot_refresh(void)
23 switch (mips_machtype
) {
25 wdt
= (__u32
*) 0xb8030034;
29 wdt
= (__u32
*) 0xbc00300c;
35 static void wdt_merlot_timer_fn(unsigned long data
)
38 if (!test_bit(1, &wdt_is_open
))
39 mod_timer(&wdt_timer
, jiffies
+ HZ
);
42 static int wdt_merlot_setup_timer(void)
45 init_timer(&wdt_timer
);
46 wdt_timer
.function
= wdt_merlot_timer_fn
;
48 wdt_timer
.expires
= jiffies
+ HZ
;
49 add_timer(&wdt_timer
);
53 static int wdt_open(struct inode
*inode
, struct file
*file
)
55 if (test_and_set_bit(0, &wdt_is_open
))
57 set_bit(1, &wdt_is_open
);
58 return nonseekable_open(inode
, file
);
61 static ssize_t
wdt_write(struct file
*file
, const char __user
* buf
, size_t count
, loff_t
* ppos
)
63 if (count
) /* something was written */
68 static int wdt_release(struct inode
*inode
, struct file
*file
)
70 clear_bit(0, &wdt_is_open
);
74 static struct file_operations wdt_fops
= {
79 .release
= wdt_release
,
82 static struct miscdevice wdt_miscdev
= {
83 .minor
= WATCHDOG_MINOR
,
88 static void __exit
wdt_exit(void)
90 misc_deregister(&wdt_miscdev
);
93 static int __init
wdt_init(void)
96 ret
= misc_register(&wdt_miscdev
);
99 "wdt: cannot register miscdev on minor=%d (err=%d)\n",
100 WATCHDOG_MINOR
, ret
);
101 misc_deregister(&wdt_miscdev
);
104 printk("wdt: registered with refresh\n");
105 wdt_merlot_refresh();
106 wdt_merlot_setup_timer();
111 module_init(wdt_init
);
112 module_exit(wdt_exit
);
This page took 0.052106 seconds and 5 git commands to generate.