xref: /OK3568_Linux_fs/kernel/drivers/watchdog/sbc60xxwdt.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *	60xx Single Board Computer Watchdog Timer driver for Linux 2.2.x
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *	Based on acquirewdt.c by Alan Cox.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  *	The author does NOT admit liability nor provide warranty for
8*4882a593Smuzhiyun  *	any of this software. This material is provided "AS-IS" in
9*4882a593Smuzhiyun  *	the hope that it may be useful for others.
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  *	(c) Copyright 2000    Jakob Oestergaard <jakob@unthought.net>
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  *           12/4 - 2000      [Initial revision]
14*4882a593Smuzhiyun  *           25/4 - 2000      Added /dev/watchdog support
15*4882a593Smuzhiyun  *           09/5 - 2001      [smj@oro.net] fixed fop_write to "return 1"
16*4882a593Smuzhiyun  *					on success
17*4882a593Smuzhiyun  *           12/4 - 2002      [rob@osinvestor.com] eliminate fop_read
18*4882a593Smuzhiyun  *                            fix possible wdt_is_open race
19*4882a593Smuzhiyun  *                            add CONFIG_WATCHDOG_NOWAYOUT support
20*4882a593Smuzhiyun  *                            remove lock_kernel/unlock_kernel pairs
21*4882a593Smuzhiyun  *                            added KERN_* to printk's
22*4882a593Smuzhiyun  *                            got rid of extraneous comments
23*4882a593Smuzhiyun  *                            changed watchdog_info to correctly reflect what
24*4882a593Smuzhiyun  *			      the driver offers
25*4882a593Smuzhiyun  *			      added WDIOC_GETSTATUS, WDIOC_GETBOOTSTATUS,
26*4882a593Smuzhiyun  *			      WDIOC_SETTIMEOUT, WDIOC_GETTIMEOUT, and
27*4882a593Smuzhiyun  *			      WDIOC_SETOPTIONS ioctls
28*4882a593Smuzhiyun  *           09/8 - 2003      [wim@iguana.be] cleanup of trailing spaces
29*4882a593Smuzhiyun  *                            use module_param
30*4882a593Smuzhiyun  *                            made timeout (the emulated heartbeat) a
31*4882a593Smuzhiyun  *			      module_param
32*4882a593Smuzhiyun  *                            made the keepalive ping an internal subroutine
33*4882a593Smuzhiyun  *                            made wdt_stop and wdt_start module params
34*4882a593Smuzhiyun  *                            added extra printk's for startup problems
35*4882a593Smuzhiyun  *                            added MODULE_AUTHOR and MODULE_DESCRIPTION info
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  *  This WDT driver is different from the other Linux WDT
38*4882a593Smuzhiyun  *  drivers in the following ways:
39*4882a593Smuzhiyun  *  *)  The driver will ping the watchdog by itself, because this
40*4882a593Smuzhiyun  *      particular WDT has a very short timeout (one second) and it
41*4882a593Smuzhiyun  *      would be insane to count on any userspace daemon always
42*4882a593Smuzhiyun  *      getting scheduled within that time frame.
43*4882a593Smuzhiyun  */
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #include <linux/module.h>
48*4882a593Smuzhiyun #include <linux/moduleparam.h>
49*4882a593Smuzhiyun #include <linux/types.h>
50*4882a593Smuzhiyun #include <linux/timer.h>
51*4882a593Smuzhiyun #include <linux/jiffies.h>
52*4882a593Smuzhiyun #include <linux/miscdevice.h>
53*4882a593Smuzhiyun #include <linux/watchdog.h>
54*4882a593Smuzhiyun #include <linux/fs.h>
55*4882a593Smuzhiyun #include <linux/ioport.h>
56*4882a593Smuzhiyun #include <linux/notifier.h>
57*4882a593Smuzhiyun #include <linux/reboot.h>
58*4882a593Smuzhiyun #include <linux/init.h>
59*4882a593Smuzhiyun #include <linux/io.h>
60*4882a593Smuzhiyun #include <linux/uaccess.h>
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun #define OUR_NAME "sbc60xxwdt"
64*4882a593Smuzhiyun #define PFX OUR_NAME ": "
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /*
67*4882a593Smuzhiyun  * You must set these - The driver cannot probe for the settings
68*4882a593Smuzhiyun  */
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun static int wdt_stop = 0x45;
71*4882a593Smuzhiyun module_param(wdt_stop, int, 0);
72*4882a593Smuzhiyun MODULE_PARM_DESC(wdt_stop, "SBC60xx WDT 'stop' io port (default 0x45)");
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun static int wdt_start = 0x443;
75*4882a593Smuzhiyun module_param(wdt_start, int, 0);
76*4882a593Smuzhiyun MODULE_PARM_DESC(wdt_start, "SBC60xx WDT 'start' io port (default 0x443)");
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /*
79*4882a593Smuzhiyun  * The 60xx board can use watchdog timeout values from one second
80*4882a593Smuzhiyun  * to several minutes.  The default is one second, so if we reset
81*4882a593Smuzhiyun  * the watchdog every ~250ms we should be safe.
82*4882a593Smuzhiyun  */
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #define WDT_INTERVAL (HZ/4+1)
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun /*
87*4882a593Smuzhiyun  * We must not require too good response from the userspace daemon.
88*4882a593Smuzhiyun  * Here we require the userspace daemon to send us a heartbeat
89*4882a593Smuzhiyun  * char to /dev/watchdog every 30 seconds.
90*4882a593Smuzhiyun  * If the daemon pulses us every 25 seconds, we can still afford
91*4882a593Smuzhiyun  * a 5 second scheduling delay on the (high priority) daemon. That
92*4882a593Smuzhiyun  * should be sufficient for a box under any load.
93*4882a593Smuzhiyun  */
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun #define WATCHDOG_TIMEOUT 30		/* 30 sec default timeout */
96*4882a593Smuzhiyun static int timeout = WATCHDOG_TIMEOUT;	/* in seconds, multiplied by HZ to
97*4882a593Smuzhiyun 					   get seconds to wait for a ping */
98*4882a593Smuzhiyun module_param(timeout, int, 0);
99*4882a593Smuzhiyun MODULE_PARM_DESC(timeout,
100*4882a593Smuzhiyun 	"Watchdog timeout in seconds. (1<=timeout<=3600, default="
101*4882a593Smuzhiyun 				__MODULE_STRING(WATCHDOG_TIMEOUT) ")");
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun static bool nowayout = WATCHDOG_NOWAYOUT;
104*4882a593Smuzhiyun module_param(nowayout, bool, 0);
105*4882a593Smuzhiyun MODULE_PARM_DESC(nowayout,
106*4882a593Smuzhiyun 	"Watchdog cannot be stopped once started (default="
107*4882a593Smuzhiyun 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun static void wdt_timer_ping(struct timer_list *);
110*4882a593Smuzhiyun static DEFINE_TIMER(timer, wdt_timer_ping);
111*4882a593Smuzhiyun static unsigned long next_heartbeat;
112*4882a593Smuzhiyun static unsigned long wdt_is_open;
113*4882a593Smuzhiyun static char wdt_expect_close;
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun /*
116*4882a593Smuzhiyun  *	Whack the dog
117*4882a593Smuzhiyun  */
118*4882a593Smuzhiyun 
wdt_timer_ping(struct timer_list * unused)119*4882a593Smuzhiyun static void wdt_timer_ping(struct timer_list *unused)
120*4882a593Smuzhiyun {
121*4882a593Smuzhiyun 	/* If we got a heartbeat pulse within the WDT_US_INTERVAL
122*4882a593Smuzhiyun 	 * we agree to ping the WDT
123*4882a593Smuzhiyun 	 */
124*4882a593Smuzhiyun 	if (time_before(jiffies, next_heartbeat)) {
125*4882a593Smuzhiyun 		/* Ping the WDT by reading from wdt_start */
126*4882a593Smuzhiyun 		inb_p(wdt_start);
127*4882a593Smuzhiyun 		/* Re-set the timer interval */
128*4882a593Smuzhiyun 		mod_timer(&timer, jiffies + WDT_INTERVAL);
129*4882a593Smuzhiyun 	} else
130*4882a593Smuzhiyun 		pr_warn("Heartbeat lost! Will not ping the watchdog\n");
131*4882a593Smuzhiyun }
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun /*
134*4882a593Smuzhiyun  * Utility routines
135*4882a593Smuzhiyun  */
136*4882a593Smuzhiyun 
wdt_startup(void)137*4882a593Smuzhiyun static void wdt_startup(void)
138*4882a593Smuzhiyun {
139*4882a593Smuzhiyun 	next_heartbeat = jiffies + (timeout * HZ);
140*4882a593Smuzhiyun 
141*4882a593Smuzhiyun 	/* Start the timer */
142*4882a593Smuzhiyun 	mod_timer(&timer, jiffies + WDT_INTERVAL);
143*4882a593Smuzhiyun 	pr_info("Watchdog timer is now enabled\n");
144*4882a593Smuzhiyun }
145*4882a593Smuzhiyun 
wdt_turnoff(void)146*4882a593Smuzhiyun static void wdt_turnoff(void)
147*4882a593Smuzhiyun {
148*4882a593Smuzhiyun 	/* Stop the timer */
149*4882a593Smuzhiyun 	del_timer_sync(&timer);
150*4882a593Smuzhiyun 	inb_p(wdt_stop);
151*4882a593Smuzhiyun 	pr_info("Watchdog timer is now disabled...\n");
152*4882a593Smuzhiyun }
153*4882a593Smuzhiyun 
wdt_keepalive(void)154*4882a593Smuzhiyun static void wdt_keepalive(void)
155*4882a593Smuzhiyun {
156*4882a593Smuzhiyun 	/* user land ping */
157*4882a593Smuzhiyun 	next_heartbeat = jiffies + (timeout * HZ);
158*4882a593Smuzhiyun }
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun /*
161*4882a593Smuzhiyun  * /dev/watchdog handling
162*4882a593Smuzhiyun  */
163*4882a593Smuzhiyun 
fop_write(struct file * file,const char __user * buf,size_t count,loff_t * ppos)164*4882a593Smuzhiyun static ssize_t fop_write(struct file *file, const char __user *buf,
165*4882a593Smuzhiyun 						size_t count, loff_t *ppos)
166*4882a593Smuzhiyun {
167*4882a593Smuzhiyun 	/* See if we got the magic character 'V' and reload the timer */
168*4882a593Smuzhiyun 	if (count) {
169*4882a593Smuzhiyun 		if (!nowayout) {
170*4882a593Smuzhiyun 			size_t ofs;
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun 			/* note: just in case someone wrote the
173*4882a593Smuzhiyun 			   magic character five months ago... */
174*4882a593Smuzhiyun 			wdt_expect_close = 0;
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun 			/* scan to see whether or not we got the
177*4882a593Smuzhiyun 			   magic character */
178*4882a593Smuzhiyun 			for (ofs = 0; ofs != count; ofs++) {
179*4882a593Smuzhiyun 				char c;
180*4882a593Smuzhiyun 				if (get_user(c, buf + ofs))
181*4882a593Smuzhiyun 					return -EFAULT;
182*4882a593Smuzhiyun 				if (c == 'V')
183*4882a593Smuzhiyun 					wdt_expect_close = 42;
184*4882a593Smuzhiyun 			}
185*4882a593Smuzhiyun 		}
186*4882a593Smuzhiyun 
187*4882a593Smuzhiyun 		/* Well, anyhow someone wrote to us, we should
188*4882a593Smuzhiyun 		   return that favour */
189*4882a593Smuzhiyun 		wdt_keepalive();
190*4882a593Smuzhiyun 	}
191*4882a593Smuzhiyun 	return count;
192*4882a593Smuzhiyun }
193*4882a593Smuzhiyun 
fop_open(struct inode * inode,struct file * file)194*4882a593Smuzhiyun static int fop_open(struct inode *inode, struct file *file)
195*4882a593Smuzhiyun {
196*4882a593Smuzhiyun 	/* Just in case we're already talking to someone... */
197*4882a593Smuzhiyun 	if (test_and_set_bit(0, &wdt_is_open))
198*4882a593Smuzhiyun 		return -EBUSY;
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun 	if (nowayout)
201*4882a593Smuzhiyun 		__module_get(THIS_MODULE);
202*4882a593Smuzhiyun 
203*4882a593Smuzhiyun 	/* Good, fire up the show */
204*4882a593Smuzhiyun 	wdt_startup();
205*4882a593Smuzhiyun 	return stream_open(inode, file);
206*4882a593Smuzhiyun }
207*4882a593Smuzhiyun 
fop_close(struct inode * inode,struct file * file)208*4882a593Smuzhiyun static int fop_close(struct inode *inode, struct file *file)
209*4882a593Smuzhiyun {
210*4882a593Smuzhiyun 	if (wdt_expect_close == 42)
211*4882a593Smuzhiyun 		wdt_turnoff();
212*4882a593Smuzhiyun 	else {
213*4882a593Smuzhiyun 		del_timer(&timer);
214*4882a593Smuzhiyun 		pr_crit("device file closed unexpectedly. Will not stop the WDT!\n");
215*4882a593Smuzhiyun 	}
216*4882a593Smuzhiyun 	clear_bit(0, &wdt_is_open);
217*4882a593Smuzhiyun 	wdt_expect_close = 0;
218*4882a593Smuzhiyun 	return 0;
219*4882a593Smuzhiyun }
220*4882a593Smuzhiyun 
fop_ioctl(struct file * file,unsigned int cmd,unsigned long arg)221*4882a593Smuzhiyun static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
222*4882a593Smuzhiyun {
223*4882a593Smuzhiyun 	void __user *argp = (void __user *)arg;
224*4882a593Smuzhiyun 	int __user *p = argp;
225*4882a593Smuzhiyun 	static const struct watchdog_info ident = {
226*4882a593Smuzhiyun 		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
227*4882a593Smuzhiyun 							WDIOF_MAGICCLOSE,
228*4882a593Smuzhiyun 		.firmware_version = 1,
229*4882a593Smuzhiyun 		.identity = "SBC60xx",
230*4882a593Smuzhiyun 	};
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun 	switch (cmd) {
233*4882a593Smuzhiyun 	case WDIOC_GETSUPPORT:
234*4882a593Smuzhiyun 		return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
235*4882a593Smuzhiyun 	case WDIOC_GETSTATUS:
236*4882a593Smuzhiyun 	case WDIOC_GETBOOTSTATUS:
237*4882a593Smuzhiyun 		return put_user(0, p);
238*4882a593Smuzhiyun 	case WDIOC_SETOPTIONS:
239*4882a593Smuzhiyun 	{
240*4882a593Smuzhiyun 		int new_options, retval = -EINVAL;
241*4882a593Smuzhiyun 		if (get_user(new_options, p))
242*4882a593Smuzhiyun 			return -EFAULT;
243*4882a593Smuzhiyun 		if (new_options & WDIOS_DISABLECARD) {
244*4882a593Smuzhiyun 			wdt_turnoff();
245*4882a593Smuzhiyun 			retval = 0;
246*4882a593Smuzhiyun 		}
247*4882a593Smuzhiyun 		if (new_options & WDIOS_ENABLECARD) {
248*4882a593Smuzhiyun 			wdt_startup();
249*4882a593Smuzhiyun 			retval = 0;
250*4882a593Smuzhiyun 		}
251*4882a593Smuzhiyun 		return retval;
252*4882a593Smuzhiyun 	}
253*4882a593Smuzhiyun 	case WDIOC_KEEPALIVE:
254*4882a593Smuzhiyun 		wdt_keepalive();
255*4882a593Smuzhiyun 		return 0;
256*4882a593Smuzhiyun 	case WDIOC_SETTIMEOUT:
257*4882a593Smuzhiyun 	{
258*4882a593Smuzhiyun 		int new_timeout;
259*4882a593Smuzhiyun 		if (get_user(new_timeout, p))
260*4882a593Smuzhiyun 			return -EFAULT;
261*4882a593Smuzhiyun 		/* arbitrary upper limit */
262*4882a593Smuzhiyun 		if (new_timeout < 1 || new_timeout > 3600)
263*4882a593Smuzhiyun 			return -EINVAL;
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun 		timeout = new_timeout;
266*4882a593Smuzhiyun 		wdt_keepalive();
267*4882a593Smuzhiyun 	}
268*4882a593Smuzhiyun 		fallthrough;
269*4882a593Smuzhiyun 	case WDIOC_GETTIMEOUT:
270*4882a593Smuzhiyun 		return put_user(timeout, p);
271*4882a593Smuzhiyun 	default:
272*4882a593Smuzhiyun 		return -ENOTTY;
273*4882a593Smuzhiyun 	}
274*4882a593Smuzhiyun }
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun static const struct file_operations wdt_fops = {
277*4882a593Smuzhiyun 	.owner		= THIS_MODULE,
278*4882a593Smuzhiyun 	.llseek		= no_llseek,
279*4882a593Smuzhiyun 	.write		= fop_write,
280*4882a593Smuzhiyun 	.open		= fop_open,
281*4882a593Smuzhiyun 	.release	= fop_close,
282*4882a593Smuzhiyun 	.unlocked_ioctl	= fop_ioctl,
283*4882a593Smuzhiyun 	.compat_ioctl	= compat_ptr_ioctl,
284*4882a593Smuzhiyun };
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun static struct miscdevice wdt_miscdev = {
287*4882a593Smuzhiyun 	.minor = WATCHDOG_MINOR,
288*4882a593Smuzhiyun 	.name = "watchdog",
289*4882a593Smuzhiyun 	.fops = &wdt_fops,
290*4882a593Smuzhiyun };
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun /*
293*4882a593Smuzhiyun  *	Notifier for system down
294*4882a593Smuzhiyun  */
295*4882a593Smuzhiyun 
wdt_notify_sys(struct notifier_block * this,unsigned long code,void * unused)296*4882a593Smuzhiyun static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
297*4882a593Smuzhiyun 	void *unused)
298*4882a593Smuzhiyun {
299*4882a593Smuzhiyun 	if (code == SYS_DOWN || code == SYS_HALT)
300*4882a593Smuzhiyun 		wdt_turnoff();
301*4882a593Smuzhiyun 	return NOTIFY_DONE;
302*4882a593Smuzhiyun }
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun /*
305*4882a593Smuzhiyun  *	The WDT needs to learn about soft shutdowns in order to
306*4882a593Smuzhiyun  *	turn the timebomb registers off.
307*4882a593Smuzhiyun  */
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun static struct notifier_block wdt_notifier = {
310*4882a593Smuzhiyun 	.notifier_call = wdt_notify_sys,
311*4882a593Smuzhiyun };
312*4882a593Smuzhiyun 
sbc60xxwdt_unload(void)313*4882a593Smuzhiyun static void __exit sbc60xxwdt_unload(void)
314*4882a593Smuzhiyun {
315*4882a593Smuzhiyun 	wdt_turnoff();
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun 	/* Deregister */
318*4882a593Smuzhiyun 	misc_deregister(&wdt_miscdev);
319*4882a593Smuzhiyun 
320*4882a593Smuzhiyun 	unregister_reboot_notifier(&wdt_notifier);
321*4882a593Smuzhiyun 	if ((wdt_stop != 0x45) && (wdt_stop != wdt_start))
322*4882a593Smuzhiyun 		release_region(wdt_stop, 1);
323*4882a593Smuzhiyun 	release_region(wdt_start, 1);
324*4882a593Smuzhiyun }
325*4882a593Smuzhiyun 
sbc60xxwdt_init(void)326*4882a593Smuzhiyun static int __init sbc60xxwdt_init(void)
327*4882a593Smuzhiyun {
328*4882a593Smuzhiyun 	int rc = -EBUSY;
329*4882a593Smuzhiyun 
330*4882a593Smuzhiyun 	if (timeout < 1 || timeout > 3600) { /* arbitrary upper limit */
331*4882a593Smuzhiyun 		timeout = WATCHDOG_TIMEOUT;
332*4882a593Smuzhiyun 		pr_info("timeout value must be 1 <= x <= 3600, using %d\n",
333*4882a593Smuzhiyun 			timeout);
334*4882a593Smuzhiyun 	}
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun 	if (!request_region(wdt_start, 1, "SBC 60XX WDT")) {
337*4882a593Smuzhiyun 		pr_err("I/O address 0x%04x already in use\n", wdt_start);
338*4882a593Smuzhiyun 		rc = -EIO;
339*4882a593Smuzhiyun 		goto err_out;
340*4882a593Smuzhiyun 	}
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun 	/* We cannot reserve 0x45 - the kernel already has! */
343*4882a593Smuzhiyun 	if (wdt_stop != 0x45 && wdt_stop != wdt_start) {
344*4882a593Smuzhiyun 		if (!request_region(wdt_stop, 1, "SBC 60XX WDT")) {
345*4882a593Smuzhiyun 			pr_err("I/O address 0x%04x already in use\n", wdt_stop);
346*4882a593Smuzhiyun 			rc = -EIO;
347*4882a593Smuzhiyun 			goto err_out_region1;
348*4882a593Smuzhiyun 		}
349*4882a593Smuzhiyun 	}
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun 	rc = register_reboot_notifier(&wdt_notifier);
352*4882a593Smuzhiyun 	if (rc) {
353*4882a593Smuzhiyun 		pr_err("cannot register reboot notifier (err=%d)\n", rc);
354*4882a593Smuzhiyun 		goto err_out_region2;
355*4882a593Smuzhiyun 	}
356*4882a593Smuzhiyun 
357*4882a593Smuzhiyun 	rc = misc_register(&wdt_miscdev);
358*4882a593Smuzhiyun 	if (rc) {
359*4882a593Smuzhiyun 		pr_err("cannot register miscdev on minor=%d (err=%d)\n",
360*4882a593Smuzhiyun 		       wdt_miscdev.minor, rc);
361*4882a593Smuzhiyun 		goto err_out_reboot;
362*4882a593Smuzhiyun 	}
363*4882a593Smuzhiyun 	pr_info("WDT driver for 60XX single board computer initialised. timeout=%d sec (nowayout=%d)\n",
364*4882a593Smuzhiyun 		timeout, nowayout);
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun 	return 0;
367*4882a593Smuzhiyun 
368*4882a593Smuzhiyun err_out_reboot:
369*4882a593Smuzhiyun 	unregister_reboot_notifier(&wdt_notifier);
370*4882a593Smuzhiyun err_out_region2:
371*4882a593Smuzhiyun 	if (wdt_stop != 0x45 && wdt_stop != wdt_start)
372*4882a593Smuzhiyun 		release_region(wdt_stop, 1);
373*4882a593Smuzhiyun err_out_region1:
374*4882a593Smuzhiyun 	release_region(wdt_start, 1);
375*4882a593Smuzhiyun err_out:
376*4882a593Smuzhiyun 	return rc;
377*4882a593Smuzhiyun }
378*4882a593Smuzhiyun 
379*4882a593Smuzhiyun module_init(sbc60xxwdt_init);
380*4882a593Smuzhiyun module_exit(sbc60xxwdt_unload);
381*4882a593Smuzhiyun 
382*4882a593Smuzhiyun MODULE_AUTHOR("Jakob Oestergaard <jakob@unthought.net>");
383*4882a593Smuzhiyun MODULE_DESCRIPTION("60xx Single Board Computer Watchdog Timer driver");
384*4882a593Smuzhiyun MODULE_LICENSE("GPL");
385