openwrtv3/openwrt/target/linux/aruba-2.6/patches/004-wdt.patch

127 lines
3.1 KiB
Diff
Raw Normal View History

2006-04-14 22:11:32 +00:00
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
--- linux-2.6.15.1/drivers/char/watchdog/wdt_merlot.c 2006-01-26 21:14:02.204626250 -0800
+++ linux-2.6.15.1-openwrt/drivers/char/watchdog/wdt_merlot.c 2006-02-02 20:31:43.000000000 -0800
2006-04-17 18:39:32 +00:00
@@ -0,0 +1,110 @@
2006-04-14 22:11:32 +00:00
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/fs.h>
+
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <asm/bootinfo.h>
+
+extern unsigned long mips_machtype;
+
+static unsigned long wdt_is_open;
+static struct timer_list wdt_timer;
+
2006-04-17 18:39:32 +00:00
+static void wdt_merlot_refresh(void)
2006-04-14 22:11:32 +00:00
+{
2006-04-17 18:39:32 +00:00
+ volatile __u32 *wdt;
+ switch (mips_machtype) {
+ case MACH_ARUBA_AP70:
+ wdt = (__u32 *) 0xb8030034;
+ *wdt = 0x10000000;
+ break;
+ default:
+ wdt = (__u32 *) 0xbc00300c;
+ *wdt = 0x40000000;
+ break;
+ }
2006-04-14 22:11:32 +00:00
+}
+
2006-04-17 18:39:32 +00:00
+static void wdt_merlot_timer_fn(unsigned long data)
+{
+ wdt_merlot_refresh();
+ if (!test_bit(1, &wdt_is_open))
+ mod_timer(&wdt_timer, jiffies + HZ);
2006-04-14 22:11:32 +00:00
+}
+
2006-04-17 18:39:32 +00:00
+static int wdt_merlot_setup_timer(void)
+{
2006-04-14 22:11:32 +00:00
+
2006-04-17 18:39:32 +00:00
+ init_timer(&wdt_timer);
+ wdt_timer.function = wdt_merlot_timer_fn;
+ wdt_timer.data = 0;
+ wdt_timer.expires = jiffies + HZ;
+ add_timer(&wdt_timer);
+ return 0;
2006-04-14 22:11:32 +00:00
+}
+
+static int wdt_open(struct inode *inode, struct file *file)
+{
2006-04-17 18:39:32 +00:00
+ if (test_and_set_bit(0, &wdt_is_open))
+ return -EBUSY;
+ set_bit(1, &wdt_is_open);
+ return nonseekable_open(inode, file);
2006-04-14 22:11:32 +00:00
+}
+
2006-04-17 18:39:32 +00:00
+static ssize_t wdt_write(struct file *file, const char __user * buf, size_t count, loff_t * ppos)
2006-04-14 22:11:32 +00:00
+{
2006-04-17 18:39:32 +00:00
+ if (count) /* something was written */
+ wdt_merlot_refresh();
+ return count;
2006-04-14 22:11:32 +00:00
+}
+
+static int wdt_release(struct inode *inode, struct file *file)
+{
2006-04-17 18:39:32 +00:00
+ clear_bit(0, &wdt_is_open);
+ return 0;
2006-04-14 22:11:32 +00:00
+}
+
+static struct file_operations wdt_fops = {
2006-04-17 18:39:32 +00:00
+ .owner = THIS_MODULE,
+ .llseek = no_llseek,
+ .write = wdt_write,
+ .open = wdt_open,
+ .release = wdt_release,
2006-04-14 22:11:32 +00:00
+};
+
+static struct miscdevice wdt_miscdev = {
2006-04-17 18:39:32 +00:00
+ .minor = WATCHDOG_MINOR,
+ .name = "watchdog",
+ .fops = &wdt_fops,
2006-04-14 22:11:32 +00:00
+};
+
+static void __exit wdt_exit(void)
+{
2006-04-17 18:39:32 +00:00
+ misc_deregister(&wdt_miscdev);
2006-04-14 22:11:32 +00:00
+}
+
+static int __init wdt_init(void)
+{
2006-04-17 18:39:32 +00:00
+ int ret;
+ ret = misc_register(&wdt_miscdev);
+ if (ret) {
+ printk(KERN_ERR
+ "wdt: cannot register miscdev on minor=%d (err=%d)\n",
+ WATCHDOG_MINOR, ret);
+ misc_deregister(&wdt_miscdev);
+ goto out;
+ }
+ printk("wdt: registered with refresh\n");
+ wdt_merlot_refresh();
+ wdt_merlot_setup_timer();
+ out:
+ return ret;
2006-04-14 22:11:32 +00:00
+}
+
+module_init(wdt_init);
+module_exit(wdt_exit);
diff -Nur linux-2.6.15.3/drivers/char/watchdog/Makefile linux-2.6.15.3-openwrt/drivers/char/watchdog/Makefile
--- linux-2.6.15.3/drivers/char/watchdog/Makefile 2006-02-22 10:04:18.596278000 -0800
+++ linux-2.6.15.3-openwrt/drivers/char/watchdog/Makefile 2006-02-22 10:06:21.400960000 -0800
@@ -71,5 +71,8 @@
# SPARC64 Architecture
+# Aruba Architecture
+obj-$(CONFIG_MACH_ARUBA) += wdt_merlot.o
+
# Architecture Independant
obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o