[brcm63xx] remove mail headers from patches
[openwrt.git] / target / linux / atheros / patches-2.6.32 / 130-watchdog.patch
1 Index: linux-2.6.32.7/drivers/watchdog/ar2315-wtd.c
2 ===================================================================
3 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4 +++ linux-2.6.32.7/drivers/watchdog/ar2315-wtd.c 2010-02-03 17:01:46.074429108 +0100
5 @@ -0,0 +1,200 @@
6 +/*
7 + * This program is free software; you can redistribute it and/or modify
8 + * it under the terms of the GNU General Public License as published by
9 + * the Free Software Foundation; either version 2 of the License, or
10 + * (at your option) any later version.
11 + *
12 + * This program is distributed in the hope that it will be useful,
13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 + * GNU General Public License for more details.
16 + *
17 + * You should have received a copy of the GNU General Public License
18 + * along with this program; if not, write to the Free Software
19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 + *
21 + * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
22 + * Based on EP93xx and ifxmips wdt driver
23 + */
24 +
25 +#include <linux/interrupt.h>
26 +#include <linux/module.h>
27 +#include <linux/moduleparam.h>
28 +#include <linux/types.h>
29 +#include <linux/miscdevice.h>
30 +#include <linux/watchdog.h>
31 +#include <linux/fs.h>
32 +#include <linux/ioport.h>
33 +#include <linux/notifier.h>
34 +#include <linux/reboot.h>
35 +#include <linux/init.h>
36 +#include <linux/platform_device.h>
37 +
38 +#include <asm/io.h>
39 +#include <asm/uaccess.h>
40 +#include <asm/system.h>
41 +#include <asm/addrspace.h>
42 +#include <ar231x_platform.h>
43 +#include <ar2315_regs.h>
44 +#include <ar231x.h>
45 +
46 +#define CLOCK_RATE 40000000
47 +#define HEARTBEAT(x) (x < 1 || x > 90)?(20):(x)
48 +
49 +static int wdt_timeout = 20;
50 +static int started = 0;
51 +static int in_use = 0;
52 +
53 +static void
54 +ar2315_wdt_enable(void)
55 +{
56 + ar231x_write_reg(AR2315_WD, wdt_timeout * CLOCK_RATE);
57 + ar231x_write_reg(AR2315_ISR, 0x80);
58 +}
59 +
60 +static ssize_t
61 +ar2315_wdt_write(struct file *file, const char __user *data, size_t len, loff_t *ppos)
62 +{
63 + if(len)
64 + ar2315_wdt_enable();
65 + return len;
66 +}
67 +
68 +static int
69 +ar2315_wdt_open(struct inode *inode, struct file *file)
70 +{
71 + if(in_use)
72 + return -EBUSY;
73 + ar2315_wdt_enable();
74 + in_use = started = 1;
75 + return nonseekable_open(inode, file);
76 +}
77 +
78 +static int
79 +ar2315_wdt_release(struct inode *inode, struct file *file)
80 +{
81 + in_use = 0;
82 + return 0;
83 +}
84 +
85 +static irqreturn_t
86 +ar2315_wdt_interrupt(int irq, void *dev_id)
87 +{
88 + if(started)
89 + {
90 + printk(KERN_CRIT "watchdog expired, rebooting system\n");
91 + emergency_restart();
92 + } else {
93 + ar231x_write_reg(AR2315_WDC, 0);
94 + ar231x_write_reg(AR2315_WD, 0);
95 + ar231x_write_reg(AR2315_ISR, 0x80);
96 + }
97 + return IRQ_HANDLED;
98 +}
99 +
100 +static struct watchdog_info ident = {
101 + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
102 + .identity = "ar2315 Watchdog",
103 +};
104 +
105 +static int
106 +ar2315_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
107 +{
108 + int new_wdt_timeout;
109 + int ret = -ENOIOCTLCMD;
110 +
111 + switch(cmd)
112 + {
113 + case WDIOC_GETSUPPORT:
114 + ret = copy_to_user((struct watchdog_info __user *)arg, &ident, sizeof(ident)) ? -EFAULT : 0;
115 + break;
116 +
117 + case WDIOC_KEEPALIVE:
118 + ar2315_wdt_enable();
119 + ret = 0;
120 + break;
121 +
122 + case WDIOC_SETTIMEOUT:
123 + if((ret = get_user(new_wdt_timeout, (int __user *)arg)))
124 + break;
125 + wdt_timeout = HEARTBEAT(new_wdt_timeout);
126 + ar2315_wdt_enable();
127 + break;
128 +
129 + case WDIOC_GETTIMEOUT:
130 + ret = put_user(wdt_timeout, (int __user *)arg);
131 + break;
132 + }
133 + return ret;
134 +}
135 +
136 +static struct file_operations ar2315_wdt_fops = {
137 + .owner = THIS_MODULE,
138 + .llseek = no_llseek,
139 + .write = ar2315_wdt_write,
140 + .ioctl = ar2315_wdt_ioctl,
141 + .open = ar2315_wdt_open,
142 + .release = ar2315_wdt_release,
143 +};
144 +
145 +static struct miscdevice ar2315_wdt_miscdev = {
146 + .minor = WATCHDOG_MINOR,
147 + .name = "watchdog",
148 + .fops = &ar2315_wdt_fops,
149 +};
150 +
151 +static int
152 +ar2315_wdt_probe(struct platform_device *dev)
153 +{
154 + int ret = 0;
155 +
156 + ar2315_wdt_enable();
157 + ret = request_irq(AR531X_MISC_IRQ_WATCHDOG, ar2315_wdt_interrupt, IRQF_DISABLED, "ar2315_wdt", NULL);
158 + if(ret)
159 + {
160 + printk(KERN_ERR "ar2315wdt: failed to register inetrrupt\n");
161 + goto out;
162 + }
163 +
164 + ret = misc_register(&ar2315_wdt_miscdev);
165 + if(ret)
166 + printk(KERN_ERR "ar2315wdt: failed to register miscdev\n");
167 +
168 +out:
169 + return ret;
170 +}
171 +
172 +static int
173 +ar2315_wdt_remove(struct platform_device *dev)
174 +{
175 + misc_deregister(&ar2315_wdt_miscdev);
176 + free_irq(AR531X_MISC_IRQ_WATCHDOG, NULL);
177 + return 0;
178 +}
179 +
180 +static struct platform_driver ar2315_wdt_driver = {
181 + .probe = ar2315_wdt_probe,
182 + .remove = ar2315_wdt_remove,
183 + .driver = {
184 + .name = "ar2315_wdt",
185 + .owner = THIS_MODULE,
186 + },
187 +};
188 +
189 +static int __init
190 +init_ar2315_wdt(void)
191 +{
192 + int ret = platform_driver_register(&ar2315_wdt_driver);
193 + if(ret)
194 + printk(KERN_INFO "ar2315_wdt: error registering platfom driver!");
195 + return ret;
196 +}
197 +
198 +static void __exit
199 +exit_ar2315_wdt(void)
200 +{
201 + platform_driver_unregister(&ar2315_wdt_driver);
202 +}
203 +
204 +module_init(init_ar2315_wdt);
205 +module_exit(exit_ar2315_wdt);
206 Index: linux-2.6.32.7/drivers/watchdog/Kconfig
207 ===================================================================
208 --- linux-2.6.32.7.orig/drivers/watchdog/Kconfig 2010-01-29 00:06:20.000000000 +0100
209 +++ linux-2.6.32.7/drivers/watchdog/Kconfig 2010-02-03 17:01:46.078429135 +0100
210 @@ -850,6 +850,12 @@
211 help
212 Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs.
213
214 +config ATHEROS_WDT
215 + tristate "Atheros wisoc Watchdog Timer"
216 + depends on ATHEROS_AR231X
217 + help
218 + Hardware driver for the Atheros wisoc Watchdog Timer.
219 +
220 # PARISC Architecture
221
222 # POWERPC Architecture
223 Index: linux-2.6.32.7/drivers/watchdog/Makefile
224 ===================================================================
225 --- linux-2.6.32.7.orig/drivers/watchdog/Makefile 2010-01-29 00:06:20.000000000 +0100
226 +++ linux-2.6.32.7/drivers/watchdog/Makefile 2010-02-03 17:01:46.078429135 +0100
227 @@ -113,6 +113,7 @@
228 obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
229 obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
230 obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
231 +obj-$(CONFIG_ATHEROS_WDT) += ar2315-wtd.o
232
233 # PARISC Architecture
234
This page took 0.052716 seconds and 5 git commands to generate.