source: freewrt/target/linux/aruba-2.6/patches/004-wdt.patch@ 475ad56

freewrt_1_0 freewrt_2_0
Last change on this file since 475ad56 was 475ad56, checked in by Waldemar Brodkorb <wbx@…>, 20 years ago

add OpenWrt trunk revision 3830.

git-svn-id: svn://www.freewrt.org/trunk/freewrt@1 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[475ad56]1diff -Nur linux-2.6.15.1/drivers/char/watchdog/wdt_merlot.c linux-2.6.15.1-openwrt/drivers/char/watchdog/wdt_merlot.c
2--- linux-2.6.15.1/drivers/char/watchdog/wdt_merlot.c 2006-01-26 21:14:02.204626250 -0800
3+++ linux-2.6.15.1-openwrt/drivers/char/watchdog/wdt_merlot.c 2006-02-02 20:31:43.000000000 -0800
4@@ -0,0 +1,110 @@
5+#include <linux/config.h>
6+#include <linux/module.h>
7+#include <linux/types.h>
8+#include <linux/miscdevice.h>
9+#include <linux/watchdog.h>
10+#include <linux/fs.h>
11+
12+#include <asm/io.h>
13+#include <asm/uaccess.h>
14+#include <asm/system.h>
15+#include <asm/bootinfo.h>
16+
17+extern unsigned long mips_machtype;
18+
19+static unsigned long wdt_is_open;
20+static struct timer_list wdt_timer;
21+
22+static void wdt_merlot_refresh(void)
23+{
24+ volatile __u32 *wdt;
25+ switch (mips_machtype) {
26+ case MACH_ARUBA_AP70:
27+ wdt = (__u32 *) 0xb8030034;
28+ *wdt = 0x10000000;
29+ break;
30+ default:
31+ wdt = (__u32 *) 0xbc00300c;
32+ *wdt = 0x40000000;
33+ break;
34+ }
35+}
36+
37+static void wdt_merlot_timer_fn(unsigned long data)
38+{
39+ wdt_merlot_refresh();
40+ if (!test_bit(1, &wdt_is_open))
41+ mod_timer(&wdt_timer, jiffies + HZ);
42+}
43+
44+static int wdt_merlot_setup_timer(void)
45+{
46+
47+ init_timer(&wdt_timer);
48+ wdt_timer.function = wdt_merlot_timer_fn;
49+ wdt_timer.data = 0;
50+ wdt_timer.expires = jiffies + HZ;
51+ add_timer(&wdt_timer);
52+ return 0;
53+}
54+
55+static int wdt_open(struct inode *inode, struct file *file)
56+{
57+ if (test_and_set_bit(0, &wdt_is_open))
58+ return -EBUSY;
59+ set_bit(1, &wdt_is_open);
60+ return nonseekable_open(inode, file);
61+}
62+
63+static ssize_t wdt_write(struct file *file, const char __user * buf, size_t count, loff_t * ppos)
64+{
65+ if (count) /* something was written */
66+ wdt_merlot_refresh();
67+ return count;
68+}
69+
70+static int wdt_release(struct inode *inode, struct file *file)
71+{
72+ clear_bit(0, &wdt_is_open);
73+ return 0;
74+}
75+
76+static struct file_operations wdt_fops = {
77+ .owner = THIS_MODULE,
78+ .llseek = no_llseek,
79+ .write = wdt_write,
80+ .open = wdt_open,
81+ .release = wdt_release,
82+};
83+
84+static struct miscdevice wdt_miscdev = {
85+ .minor = WATCHDOG_MINOR,
86+ .name = "watchdog",
87+ .fops = &wdt_fops,
88+};
89+
90+static void __exit wdt_exit(void)
91+{
92+ misc_deregister(&wdt_miscdev);
93+}
94+
95+static int __init wdt_init(void)
96+{
97+ int ret;
98+ ret = misc_register(&wdt_miscdev);
99+ if (ret) {
100+ printk(KERN_ERR
101+ "wdt: cannot register miscdev on minor=%d (err=%d)\n",
102+ WATCHDOG_MINOR, ret);
103+ misc_deregister(&wdt_miscdev);
104+ goto out;
105+ }
106+ printk("wdt: registered with refresh\n");
107+ wdt_merlot_refresh();
108+ wdt_merlot_setup_timer();
109+ out:
110+ return ret;
111+}
112+
113+module_init(wdt_init);
114+module_exit(wdt_exit);
115diff -Nur linux-2.6.15.3/drivers/char/watchdog/Makefile linux-2.6.15.3-openwrt/drivers/char/watchdog/Makefile
116--- linux-2.6.15.3/drivers/char/watchdog/Makefile 2006-02-22 10:04:18.596278000 -0800
117+++ linux-2.6.15.3-openwrt/drivers/char/watchdog/Makefile 2006-02-22 10:06:21.400960000 -0800
118@@ -71,5 +71,8 @@
119
120 # SPARC64 Architecture
121
122+# Aruba Architecture
123+obj-$(CONFIG_MACH_ARUBA) += wdt_merlot.o
124+
125 # Architecture Independant
126 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
Note: See TracBrowser for help on using the repository browser.