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
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.
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.
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
21 + * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
22 + * Based on EP93xx and ifxmips wdt driver
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>
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>
46 +#define CLOCK_RATE 40000000
47 +#define HEARTBEAT(x) (x < 1 || x > 90)?(20):(x)
49 +static int wdt_timeout = 20;
50 +static int started = 0;
51 +static int in_use = 0;
54 +ar2315_wdt_enable(void)
56 + ar231x_write_reg(AR2315_WD, wdt_timeout * CLOCK_RATE);
57 + ar231x_write_reg(AR2315_ISR, 0x80);
61 +ar2315_wdt_write(struct file *file, const char __user *data, size_t len, loff_t *ppos)
64 + ar2315_wdt_enable();
69 +ar2315_wdt_open(struct inode *inode, struct file *file)
73 + ar2315_wdt_enable();
74 + in_use = started = 1;
75 + return nonseekable_open(inode, file);
79 +ar2315_wdt_release(struct inode *inode, struct file *file)
86 +ar2315_wdt_interrupt(int irq, void *dev_id)
90 + printk(KERN_CRIT "watchdog expired, rebooting system\n");
91 + emergency_restart();
93 + ar231x_write_reg(AR2315_WDC, 0);
94 + ar231x_write_reg(AR2315_WD, 0);
95 + ar231x_write_reg(AR2315_ISR, 0x80);
100 +static struct watchdog_info ident = {
101 + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
102 + .identity = "ar2315 Watchdog",
106 +ar2315_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
108 + int new_wdt_timeout;
109 + int ret = -ENOIOCTLCMD;
113 + case WDIOC_GETSUPPORT:
114 + ret = copy_to_user((struct watchdog_info __user *)arg, &ident, sizeof(ident)) ? -EFAULT : 0;
117 + case WDIOC_KEEPALIVE:
118 + ar2315_wdt_enable();
122 + case WDIOC_SETTIMEOUT:
123 + if((ret = get_user(new_wdt_timeout, (int __user *)arg)))
125 + wdt_timeout = HEARTBEAT(new_wdt_timeout);
126 + ar2315_wdt_enable();
129 + case WDIOC_GETTIMEOUT:
130 + ret = put_user(wdt_timeout, (int __user *)arg);
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,
145 +static struct miscdevice ar2315_wdt_miscdev = {
146 + .minor = WATCHDOG_MINOR,
147 + .name = "watchdog",
148 + .fops = &ar2315_wdt_fops,
152 +ar2315_wdt_probe(struct platform_device *dev)
156 + ar2315_wdt_enable();
157 + ret = request_irq(AR531X_MISC_IRQ_WATCHDOG, ar2315_wdt_interrupt, IRQF_DISABLED, "ar2315_wdt", NULL);
160 + printk(KERN_ERR "ar2315wdt: failed to register inetrrupt\n");
164 + ret = misc_register(&ar2315_wdt_miscdev);
166 + printk(KERN_ERR "ar2315wdt: failed to register miscdev\n");
173 +ar2315_wdt_remove(struct platform_device *dev)
175 + misc_deregister(&ar2315_wdt_miscdev);
176 + free_irq(AR531X_MISC_IRQ_WATCHDOG, NULL);
180 +static struct platform_driver ar2315_wdt_driver = {
181 + .probe = ar2315_wdt_probe,
182 + .remove = ar2315_wdt_remove,
184 + .name = "ar2315_wdt",
185 + .owner = THIS_MODULE,
190 +init_ar2315_wdt(void)
192 + int ret = platform_driver_register(&ar2315_wdt_driver);
194 + printk(KERN_INFO "ar2315_wdt: error registering platfom driver!");
199 +exit_ar2315_wdt(void)
201 + platform_driver_unregister(&ar2315_wdt_driver);
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
212 Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs.
215 + tristate "Atheros wisoc Watchdog Timer"
216 + depends on ATHEROS_AR231X
218 + Hardware driver for the Atheros wisoc Watchdog Timer.
220 # PARISC Architecture
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
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
233 # PARISC Architecture