1 diff -Nurb linux/arch/mips/au1000/mtx-1/Makefile linux.wd/arch/mips/au1000/mtx-1/Makefile
2 --- linux/arch/mips/au1000/mtx-1/Makefile 2004-11-24 12:11:54.000000000 +0100
3 +++ linux.wd/arch/mips/au1000/mtx-1/Makefile 2005-03-09 17:58:40.000000000 +0100
8 -obj-y := init.o board_setup.o irqmap.o
9 +obj-y := init.o board_setup.o irqmap.o mtx-1_watchdog.o
11 include $(TOPDIR)/Rules.make
12 diff -Nurb linux/arch/mips/au1000/mtx-1/mtx-1_watchdog.c linux.wd/arch/mips/au1000/mtx-1/mtx-1_watchdog.c
13 --- linux/arch/mips/au1000/mtx-1/mtx-1_watchdog.c 1970-01-01 01:00:00.000000000 +0100
14 +++ linux.wd/arch/mips/au1000/mtx-1/mtx-1_watchdog.c 2005-03-09 18:28:06.000000000 +0100
17 + * Driver for the MTX-1 Watchdog.
19 + * (c) Copyright 2005 4G Systems <info@4g-systems.biz>, All Rights Reserved.
20 + * http://www.4g-systems.biz
22 + * This program is free software; you can redistribute it and/or
23 + * modify it under the terms of the GNU General Public License
24 + * as published by the Free Software Foundation; either version
25 + * 2 of the License, or (at your option) any later version.
27 + * Neither Michael Stickel nor 4G Systems admit liability nor provide
28 + * warranty for any of this software. This material is provided
29 + * "AS-IS" and at no charge.
31 + * (c) Copyright 2005 4G Systems <info@4g-systems.biz>
35 + * Author: Michael Stickel michael.stickel@4g-systems.biz
38 + * The Watchdog is configured to reset the MTX-1
39 + * if it is not triggered for 100 seconds.
40 + * It should not be triggered more often than 1.6 seconds.
42 + * A timer triggers the watchdog every 5 seconds, until
43 + * it is opened for the first time. After the first open
44 + * it MUST be triggered every 2..95 seconds.
46 +#include <linux/config.h>
47 +#include <linux/module.h>
48 +#include <linux/version.h>
49 +#include <linux/types.h>
50 +#include <linux/errno.h>
51 +#include <linux/kernel.h>
52 +#include <linux/sched.h>
53 +#include <linux/miscdevice.h>
54 +#include <linux/watchdog.h>
55 +#include <linux/slab.h>
56 +#include <linux/init.h>
58 +#include <asm/au1000.h>
66 +# define TRUE (!FALSE)
70 +//---------[ Hardware Functions ]-----------------
72 +static void mtx1_trigger_wd (void)
78 + u32 tmp = au_readl(GPIO2_DIR);
79 + tmp = (tmp & ~(1<<15)) | ((~tmp) & (1<<15));
80 + au_writel (tmp, GPIO2_DIR);
83 +static void mtx1_enable_wd (void)
85 + au_writel (au_readl(GPIO2_DIR) | (u32)(1<<15), GPIO2_DIR);
88 +static void mtx1_disable_wd (void)
90 + au_writel (au_readl(GPIO2_DIR) & ~((u32)(1<<15)), GPIO2_DIR);
94 +//---------[ Timer Functions ]-----------------
96 +static struct timer_list wd_trigger_timer;
97 +static char timer_is_running = FALSE;
99 +static void wd_timer_callback (unsigned long data)
101 + if (timer_is_running)
102 + mod_timer (&wd_trigger_timer, jiffies + 5 * HZ);
103 + mtx1_trigger_wd ();
106 +static void start_wd_timer (void)
108 + if (!timer_is_running) {
109 + struct timer_list *t = &wd_trigger_timer;
112 + t->function = wd_timer_callback;
113 + t->data = (unsigned long)0L;
114 + t->expires = jiffies + 5 * HZ; // 5 seconds.
116 + timer_is_running = TRUE;
122 +static void stop_wd_timer (void)
124 + if (timer_is_running) {
125 + del_timer(&wd_trigger_timer);
126 + timer_is_running = FALSE;
131 +//---------[ File Functions ]-----------------
133 +static int mtx1wd_open (struct inode *inode, struct file *file)
135 + if (MINOR(inode->i_rdev)!=WATCHDOG_MINOR) return -ENODEV;
138 + // stop the timer, if it is running. It will not be
139 + // started again, until the module is loaded again.
142 + // sleep for 2 seconds, to ensure, that the wd is
143 + // not triggered more often than every 2 seconds.
144 + schedule_timeout (2 * HZ);
150 +static int mtx1wd_release (struct inode *inode, struct file *file) {
151 + if (MINOR(inode->i_rdev)==WATCHDOG_MINOR) {
158 +static ssize_t mtx1wd_write (struct file *file, const char *buf, size_t count, loff_t *ppos) {
159 + if (ppos!=&file->f_pos)
163 + mtx1_trigger_wd ();
171 +static struct file_operations mtx1wd_fops = {
172 + .owner = THIS_MODULE,
175 + .write = mtx1wd_write,
180 + .open = mtx1wd_open,
182 + .release = mtx1wd_release
186 +static struct miscdevice mtx1wd_miscdev = {
194 +//---------[ Module Functions ]-----------------
197 +void cleanup_module (void)
199 + // stop the timer, if it is running.
202 + misc_deregister(&mtx1wd_miscdev);
204 + mtx1_disable_wd ();
208 +int __init init_mtx1_watchdog (void)
210 + printk("MTX-1 watchdog driver\n");
214 + //-- trigger it for the first time.
215 + //-- We do not exactly know how long it has not been triggered.
216 + mtx1_trigger_wd ();
218 + misc_register (&mtx1wd_miscdev);
220 + // start a timer, that calls mtx1_trigger_wd every 5 seconds.
226 +__initcall(init_mtx1_watchdog);
228 +MODULE_AUTHOR("Michael Stickel");
229 +MODULE_DESCRIPTION("Driver for the MTX-1 watchdog");
230 +MODULE_LICENSE("GPL");