1 Index: linux-2.6.30.8/drivers/watchdog/Makefile
2 ===================================================================
3 --- linux-2.6.30.8.orig/drivers/watchdog/Makefile 2009-09-24 17:28:02.000000000 +0200
4 +++ linux-2.6.30.8/drivers/watchdog/Makefile 2009-10-19 21:31:32.000000000 +0200
6 obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
7 obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
8 obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
9 +obj-$(CONFIG_IFXMIPS_WDT) += ifxmips_wdt.o
13 Index: linux-2.6.30.8/drivers/watchdog/Kconfig
14 ===================================================================
15 --- linux-2.6.30.8.orig/drivers/watchdog/Kconfig 2009-09-24 17:28:02.000000000 +0200
16 +++ linux-2.6.30.8/drivers/watchdog/Kconfig 2009-10-19 21:31:32.000000000 +0200
19 Hardware driver for the built-in watchdog timer on TXx9 MIPS SoCs.
22 + bool "IFXMips watchdog"
25 + Hardware driver for the IFXMIPS Watchdog Timer.
29 # POWERPC Architecture
30 Index: linux-2.6.30.8/drivers/watchdog/ifxmips_wdt.c
31 ===================================================================
32 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
33 +++ linux-2.6.30.8/drivers/watchdog/ifxmips_wdt.c 2009-10-19 21:40:17.000000000 +0200
36 + * This program is free software; you can redistribute it and/or modify
37 + * it under the terms of the GNU General Public License as published by
38 + * the Free Software Foundation; either version 2 of the License, or
39 + * (at your option) any later version.
41 + * This program is distributed in the hope that it will be useful,
42 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 + * GNU General Public License for more details.
46 + * You should have received a copy of the GNU General Public License
47 + * along with this program; if not, write to the Free Software
48 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 + * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
51 + * Based on EP93xx wdt driver
54 +#include <linux/module.h>
55 +#include <linux/fs.h>
56 +#include <linux/miscdevice.h>
57 +#include <linux/miscdevice.h>
58 +#include <linux/watchdog.h>
59 +#include <linux/platform_device.h>
60 +#include <linux/uaccess.h>
63 +#include <ifxmips_cgu.h>
65 +#define IFXMIPS_WDT_PW1 0x00BE0000
66 +#define IFXMIPS_WDT_PW2 0x00DC0000
68 +#ifndef CONFIG_WATCHDOG_NOWAYOUT
69 +static int wdt_ok_to_close;
72 +static int wdt_timeout = 30;
74 +int ifxmips_wdt_enable(unsigned int timeout)
77 + fpi = cgu_get_io_region_clock();
78 + ifxmips_w32(IFXMIPS_WDT_PW1, IFXMIPS_BIU_WDT_CR);
79 + ifxmips_w32(IFXMIPS_WDT_PW2 |
80 + (0x3 << 26) | /* PWL */
81 + (0x3 << 24) | /* CLKDIV */
82 + (0x1 << 31) | /* enable */
83 + ((timeout * (fpi / 0x40000)) + 0x1000), /* reload */
84 + IFXMIPS_BIU_WDT_CR);
88 +void ifxmips_wdt_disable(void)
90 +#ifndef CONFIG_WATCHDOG_NOWAYOUT
91 + wdt_ok_to_close = 0;
93 + ifxmips_w32(IFXMIPS_WDT_PW1, IFXMIPS_BIU_WDT_CR);
94 + ifxmips_w32(IFXMIPS_WDT_PW2, IFXMIPS_BIU_WDT_CR);
97 +static ssize_t ifxmips_wdt_write(struct file *file, const char __user *data,
98 + size_t len, loff_t *ppos)
105 +#ifndef CONFIG_WATCHDOG_NOWAYOUT
106 + for (i = 0; i != len; i++) {
108 + if (get_user(c, data + i))
111 + wdt_ok_to_close = 1;
114 + ifxmips_wdt_enable(wdt_timeout);
118 +static struct watchdog_info ident = {
119 + .options = WDIOF_MAGICCLOSE,
120 + .identity = "ifxmips Watchdog",
123 +static int ifxmips_wdt_ioctl(struct inode *inode, struct file *file,
124 + unsigned int cmd, unsigned long arg)
129 + case WDIOC_GETSUPPORT:
130 + ret = copy_to_user((struct watchdog_info __user *)arg, &ident,
131 + sizeof(ident)) ? -EFAULT : 0;
134 + case WDIOC_GETTIMEOUT:
135 + ret = put_user(wdt_timeout, (int __user *)arg);
138 + case WDIOC_SETTIMEOUT:
139 + ret = get_user(wdt_timeout, (int __user *)arg);
142 + case WDIOC_KEEPALIVE:
143 + ifxmips_wdt_enable(wdt_timeout);
150 +static int ifxmips_wdt_open(struct inode *inode, struct file *file)
152 + ifxmips_wdt_enable(wdt_timeout);
153 + return nonseekable_open(inode, file);
156 +static int ifxmips_wdt_release(struct inode *inode, struct file *file)
158 +#ifndef CONFIG_WATCHDOG_NOWAYOUT
159 + if (wdt_ok_to_close)
160 + ifxmips_wdt_disable();
163 + printk(KERN_ERR "ifxmips_wdt: watchdog closed without warning,"
164 + " rebooting system\n");
168 +static const struct file_operations ifxmips_wdt_fops = {
169 + .owner = THIS_MODULE,
170 + .write = ifxmips_wdt_write,
171 + .ioctl = ifxmips_wdt_ioctl,
172 + .open = ifxmips_wdt_open,
173 + .release = ifxmips_wdt_release,
176 +static struct miscdevice ifxmips_wdt_miscdev = {
177 + .minor = WATCHDOG_MINOR,
178 + .name = "watchdog",
179 + .fops = &ifxmips_wdt_fops,
182 +static int ifxmips_wdt_probe(struct platform_device *dev)
185 + err = misc_register(&ifxmips_wdt_miscdev);
187 + printk(KERN_INFO "ifxmips_wdt: error creating device\n");
189 + printk(KERN_INFO "ifxmips_wdt: loaded\n");
193 +static int ifxmips_wdt_remove(struct platform_device *dev)
195 + ifxmips_wdt_disable();
196 + misc_deregister(&ifxmips_wdt_miscdev);
201 +static struct platform_driver ifxmips_wdt_driver = {
202 + .probe = ifxmips_wdt_probe,
203 + .remove = ifxmips_wdt_remove,
205 + .name = "ifxmips_wdt",
206 + .owner = THIS_MODULE,
210 +static int __init init_ifxmips_wdt(void)
212 + int ret = platform_driver_register(&ifxmips_wdt_driver);
214 + printk(KERN_INFO "ifxmips_wdt: error registering platfom driver!");
218 +static void __exit exit_ifxmips_wdt(void)
220 + platform_driver_unregister(&ifxmips_wdt_driver);
223 +module_init(init_ifxmips_wdt);
224 +module_exit(exit_ifxmips_wdt);
226 +MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
227 +MODULE_DESCRIPTION("ifxmips Watchdog");
228 +MODULE_LICENSE("GPL");
229 +MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);