cleanup makefiles
[openwrt.git] / openwrt / target / linux / aruba-2.6 / patches / 004-wdt.patch
1 diff -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,141 @@
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 +// refresh the watchdog timer for this many seconds in kernel
18 +// before letting the watchdog process take over.
19 +#define WDT_COUNT 60
20 +
21 +extern unsigned long mips_machtype;
22 +
23 +static unsigned long wdt_is_open;
24 +static struct timer_list wdt_timer;
25 +static int wdt_count = WDT_COUNT;
26 +
27 +static void wdt_merlot_refresh(void){
28 + volatile __u32 *wdt;
29 + switch (mips_machtype) {
30 + case MACH_ARUBA_AP70:
31 + wdt = (__u32 *)0xb8030034;
32 + *wdt = 0x10000000;
33 + break;
34 + default:
35 + wdt = (__u32 *)0xbc00300c;
36 + *wdt = 0x40000000;
37 + break;
38 + }
39 +}
40 +
41 +static void wdt_merlot_disable()
42 +{
43 + volatile __u32 *wdt_errcs;
44 + volatile __u32 *wdt_wtc;
45 + volatile __u32 *wdt_ctl;
46 + volatile __u32 val ;
47 +
48 + switch (mips_machtype) {
49 + case MACH_ARUBA_AP70:
50 + wdt_errcs = (__u32 *)0xb8030030 ;
51 + wdt_wtc = (__u32 *)0xb803003c ;
52 + val = *wdt_errcs ;
53 + val &= ~0x201 ;
54 + *wdt_errcs = val ;
55 + val = *wdt_wtc ;
56 + val &= ~0x1 ;
57 + *wdt_wtc = val ;
58 + break;
59 + default:
60 + wdt_ctl = (__u32 *)0xbc003008;
61 + *wdt_ctl = 0 ;
62 + break;
63 + }
64 +}
65 +
66 +static void wdt_merlot_timer_fn(unsigned long data){
67 +
68 + wdt_merlot_refresh();
69 + if (--wdt_count >= 0)
70 + mod_timer(&wdt_timer, jiffies + HZ);
71 + else
72 + wdt_merlot_disable();
73 +
74 +}
75 +
76 +static int wdt_merlot_setup_timer(void){
77 +
78 + init_timer(&wdt_timer);
79 + wdt_timer.function = wdt_merlot_timer_fn;
80 + wdt_timer.data = 0;
81 + wdt_timer.expires = jiffies + HZ;
82 + add_timer(&wdt_timer);
83 + return 0;
84 +}
85 +
86 +static int wdt_open(struct inode *inode, struct file *file)
87 +{
88 + if(test_and_set_bit(0, &wdt_is_open))
89 + return -EBUSY;
90 + wdt_count=0;
91 + return nonseekable_open(inode, file);
92 +}
93 +
94 +static ssize_t wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
95 +{
96 + if (count) { /* something was written */
97 + wdt_merlot_refresh();
98 + }
99 + return count;
100 +}
101 +
102 +static int wdt_release(struct inode *inode, struct file *file)
103 +{
104 + clear_bit(0, &wdt_is_open);
105 + return 0;
106 +}
107 +
108 +static struct file_operations wdt_fops = {
109 + .owner = THIS_MODULE,
110 + .llseek = no_llseek,
111 + .write = wdt_write,
112 + .open = wdt_open,
113 + .release = wdt_release,
114 +};
115 +
116 +static struct miscdevice wdt_miscdev = {
117 + .minor = WATCHDOG_MINOR,
118 + .name = "watchdog",
119 + .fops = &wdt_fops,
120 +};
121 +
122 +static void __exit wdt_exit(void)
123 +{
124 + misc_deregister(&wdt_miscdev);
125 +}
126 +
127 +static int __init wdt_init(void)
128 +{
129 + int ret;
130 + ret = misc_register(&wdt_miscdev);
131 + if (ret) {
132 + printk(KERN_ERR "wdt: cannot register miscdev on minor=%d (err=%d)\n",
133 + WATCHDOG_MINOR, ret);
134 + misc_deregister(&wdt_miscdev);
135 + goto out;
136 + }
137 + printk("wdt: registered with refresh\n");
138 + wdt_merlot_refresh();
139 + wdt_merlot_setup_timer();
140 +out:
141 + return ret;
142 +}
143 +
144 +module_init(wdt_init);
145 +module_exit(wdt_exit);
146 diff -Nur linux-2.6.15.3/drivers/char/watchdog/Makefile linux-2.6.15.3-openwrt/drivers/char/watchdog/Makefile
147 --- linux-2.6.15.3/drivers/char/watchdog/Makefile 2006-02-22 10:04:18.596278000 -0800
148 +++ linux-2.6.15.3-openwrt/drivers/char/watchdog/Makefile 2006-02-22 10:06:21.400960000 -0800
149 @@ -71,5 +71,8 @@
150
151 # SPARC64 Architecture
152
153 +# Aruba Architecture
154 +obj-$(CONFIG_MACH_ARUBA) += wdt_merlot.o
155 +
156 # Architecture Independant
157 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
This page took 0.067469 seconds and 5 git commands to generate.