| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* linux/drivers/char/watchdog/s3c2410_wdt.c | 
 | 2 |  * | 
 | 3 |  * Copyright (c) 2004 Simtec Electronics | 
 | 4 |  *	Ben Dooks <ben@simtec.co.uk> | 
 | 5 |  * | 
 | 6 |  * S3C2410 Watchdog Timer Support | 
 | 7 |  * | 
 | 8 |  * Based on, softdog.c by Alan Cox, | 
| Alan Cox | 29fa058 | 2008-10-27 15:17:56 +0000 | [diff] [blame] | 9 |  *     (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 |  * | 
 | 11 |  * This program is free software; you can redistribute it and/or modify | 
 | 12 |  * it under the terms of the GNU General Public License as published by | 
 | 13 |  * the Free Software Foundation; either version 2 of the License, or | 
 | 14 |  * (at your option) any later version. | 
 | 15 |  * | 
 | 16 |  * This program is distributed in the hope that it will be useful, | 
 | 17 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 18 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 19 |  * GNU General Public License for more details. | 
 | 20 |  * | 
 | 21 |  * You should have received a copy of the GNU General Public License | 
 | 22 |  * along with this program; if not, write to the Free Software | 
 | 23 |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | */ | 
 | 25 |  | 
| Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 26 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 
 | 27 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/module.h> | 
 | 29 | #include <linux/moduleparam.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/types.h> | 
 | 31 | #include <linux/timer.h> | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 32 | #include <linux/miscdevice.h> /* for MODULE_ALIAS_MISCDEV */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/watchdog.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/init.h> | 
| Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 35 | #include <linux/platform_device.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/interrupt.h> | 
| Russell King | f8ce254 | 2006-01-07 16:15:52 +0000 | [diff] [blame] | 37 | #include <linux/clk.h> | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 38 | #include <linux/uaccess.h> | 
 | 39 | #include <linux/io.h> | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 40 | #include <linux/cpufreq.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 41 | #include <linux/slab.h> | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 42 | #include <linux/err.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 |  | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 44 | #include <mach/map.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 |  | 
| Ben Dooks | b430708 | 2007-07-24 13:28:01 +0100 | [diff] [blame] | 46 | #undef S3C_VA_WATCHDOG | 
 | 47 | #define S3C_VA_WATCHDOG (0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 |  | 
| Ben Dooks | 180ee70 | 2008-10-30 10:14:32 +0000 | [diff] [blame] | 49 | #include <plat/regs-watchdog.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define CONFIG_S3C2410_WATCHDOG_ATBOOT		(0) | 
 | 52 | #define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME	(15) | 
 | 53 |  | 
| Wim Van Sebroeck | 86a1e18 | 2012-03-05 16:51:11 +0100 | [diff] [blame] | 54 | static bool nowayout	= WATCHDOG_NOWAYOUT; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | static int tmr_margin	= CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME; | 
 | 56 | static int tmr_atboot	= CONFIG_S3C2410_WATCHDOG_ATBOOT; | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 57 | static int soft_noboot; | 
 | 58 | static int debug; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 |  | 
 | 60 | module_param(tmr_margin,  int, 0); | 
 | 61 | module_param(tmr_atboot,  int, 0); | 
| Wim Van Sebroeck | 86a1e18 | 2012-03-05 16:51:11 +0100 | [diff] [blame] | 62 | module_param(nowayout,   bool, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | module_param(soft_noboot, int, 0); | 
 | 64 | module_param(debug,	  int, 0); | 
 | 65 |  | 
| Randy Dunlap | 76550d3 | 2010-05-01 09:46:15 -0700 | [diff] [blame] | 66 | MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. (default=" | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 67 | 		__MODULE_STRING(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME) ")"); | 
 | 68 | MODULE_PARM_DESC(tmr_atboot, | 
 | 69 | 		"Watchdog is started at boot time if set to 1, default=" | 
 | 70 | 			__MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT)); | 
 | 71 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 
 | 72 | 			__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 
| Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 73 | MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, " | 
| Randy Dunlap | 76550d3 | 2010-05-01 09:46:15 -0700 | [diff] [blame] | 74 | 			"0 to reboot (default 0)"); | 
 | 75 | MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug (default 0)"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 |  | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 77 | static struct device    *wdt_dev;	/* platform device attached to */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | static struct resource	*wdt_mem; | 
 | 79 | static struct resource	*wdt_irq; | 
 | 80 | static struct clk	*wdt_clock; | 
 | 81 | static void __iomem	*wdt_base; | 
 | 82 | static unsigned int	 wdt_count; | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 83 | static DEFINE_SPINLOCK(wdt_lock); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 |  | 
 | 85 | /* watchdog control routines */ | 
 | 86 |  | 
| Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 87 | #define DBG(fmt, ...)					\ | 
 | 88 | do {							\ | 
 | 89 | 	if (debug)					\ | 
 | 90 | 		pr_info(fmt, ##__VA_ARGS__);		\ | 
 | 91 | } while (0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 |  | 
 | 93 | /* functions */ | 
 | 94 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 95 | static int s3c2410wdt_keepalive(struct watchdog_device *wdd) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | { | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 97 | 	spin_lock(&wdt_lock); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | 	writel(wdt_count, wdt_base + S3C2410_WTCNT); | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 99 | 	spin_unlock(&wdt_lock); | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 100 |  | 
 | 101 | 	return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } | 
 | 103 |  | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 104 | static void __s3c2410wdt_stop(void) | 
 | 105 | { | 
 | 106 | 	unsigned long wtcon; | 
 | 107 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | 	wtcon = readl(wdt_base + S3C2410_WTCON); | 
 | 109 | 	wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN); | 
 | 110 | 	writel(wtcon, wdt_base + S3C2410_WTCON); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | } | 
 | 112 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 113 | static int s3c2410wdt_stop(struct watchdog_device *wdd) | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 114 | { | 
 | 115 | 	spin_lock(&wdt_lock); | 
 | 116 | 	__s3c2410wdt_stop(); | 
 | 117 | 	spin_unlock(&wdt_lock); | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 118 |  | 
 | 119 | 	return 0; | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 120 | } | 
 | 121 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 122 | static int s3c2410wdt_start(struct watchdog_device *wdd) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { | 
 | 124 | 	unsigned long wtcon; | 
 | 125 |  | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 126 | 	spin_lock(&wdt_lock); | 
 | 127 |  | 
 | 128 | 	__s3c2410wdt_stop(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 |  | 
 | 130 | 	wtcon = readl(wdt_base + S3C2410_WTCON); | 
 | 131 | 	wtcon |= S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128; | 
 | 132 |  | 
 | 133 | 	if (soft_noboot) { | 
 | 134 | 		wtcon |= S3C2410_WTCON_INTEN; | 
 | 135 | 		wtcon &= ~S3C2410_WTCON_RSTEN; | 
 | 136 | 	} else { | 
 | 137 | 		wtcon &= ~S3C2410_WTCON_INTEN; | 
 | 138 | 		wtcon |= S3C2410_WTCON_RSTEN; | 
 | 139 | 	} | 
 | 140 |  | 
 | 141 | 	DBG("%s: wdt_count=0x%08x, wtcon=%08lx\n", | 
| Harvey Harrison | fa9363c | 2008-03-05 18:24:58 -0800 | [diff] [blame] | 142 | 	    __func__, wdt_count, wtcon); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 |  | 
 | 144 | 	writel(wdt_count, wdt_base + S3C2410_WTDAT); | 
 | 145 | 	writel(wdt_count, wdt_base + S3C2410_WTCNT); | 
 | 146 | 	writel(wtcon, wdt_base + S3C2410_WTCON); | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 147 | 	spin_unlock(&wdt_lock); | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 148 |  | 
 | 149 | 	return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | } | 
 | 151 |  | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 152 | static inline int s3c2410wdt_is_running(void) | 
 | 153 | { | 
 | 154 | 	return readl(wdt_base + S3C2410_WTCON) & S3C2410_WTCON_ENABLE; | 
 | 155 | } | 
 | 156 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 157 | static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, unsigned timeout) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | { | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 159 | 	unsigned long freq = clk_get_rate(wdt_clock); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | 	unsigned int count; | 
 | 161 | 	unsigned int divisor = 1; | 
 | 162 | 	unsigned long wtcon; | 
 | 163 |  | 
 | 164 | 	if (timeout < 1) | 
 | 165 | 		return -EINVAL; | 
 | 166 |  | 
 | 167 | 	freq /= 128; | 
 | 168 | 	count = timeout * freq; | 
 | 169 |  | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 170 | 	DBG("%s: count=%d, timeout=%d, freq=%lu\n", | 
| Harvey Harrison | fa9363c | 2008-03-05 18:24:58 -0800 | [diff] [blame] | 171 | 	    __func__, count, timeout, freq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 |  | 
 | 173 | 	/* if the count is bigger than the watchdog register, | 
 | 174 | 	   then work out what we need to do (and if) we can | 
 | 175 | 	   actually make this value | 
 | 176 | 	*/ | 
 | 177 |  | 
 | 178 | 	if (count >= 0x10000) { | 
 | 179 | 		for (divisor = 1; divisor <= 0x100; divisor++) { | 
 | 180 | 			if ((count / divisor) < 0x10000) | 
 | 181 | 				break; | 
 | 182 | 		} | 
 | 183 |  | 
 | 184 | 		if ((count / divisor) >= 0x10000) { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 185 | 			dev_err(wdt_dev, "timeout %d too big\n", timeout); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | 			return -EINVAL; | 
 | 187 | 		} | 
 | 188 | 	} | 
 | 189 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | 	DBG("%s: timeout=%d, divisor=%d, count=%d (%08x)\n", | 
| Harvey Harrison | fa9363c | 2008-03-05 18:24:58 -0800 | [diff] [blame] | 191 | 	    __func__, timeout, divisor, count, count/divisor); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 |  | 
 | 193 | 	count /= divisor; | 
 | 194 | 	wdt_count = count; | 
 | 195 |  | 
 | 196 | 	/* update the pre-scaler */ | 
 | 197 | 	wtcon = readl(wdt_base + S3C2410_WTCON); | 
 | 198 | 	wtcon &= ~S3C2410_WTCON_PRESCALE_MASK; | 
 | 199 | 	wtcon |= S3C2410_WTCON_PRESCALE(divisor-1); | 
 | 200 |  | 
 | 201 | 	writel(count, wdt_base + S3C2410_WTDAT); | 
 | 202 | 	writel(wtcon, wdt_base + S3C2410_WTCON); | 
 | 203 |  | 
| Wim Van Sebroeck | 0197c1c | 2012-02-29 20:20:58 +0100 | [diff] [blame] | 204 | 	wdd->timeout = timeout; | 
 | 205 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | 	return 0; | 
 | 207 | } | 
 | 208 |  | 
| Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 209 | #define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 |  | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 211 | static const struct watchdog_info s3c2410_wdt_ident = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | 	.options          =     OPTIONS, | 
 | 213 | 	.firmware_version =	0, | 
 | 214 | 	.identity         =	"S3C2410 Watchdog", | 
 | 215 | }; | 
 | 216 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 217 | static struct watchdog_ops s3c2410wdt_ops = { | 
 | 218 | 	.owner = THIS_MODULE, | 
 | 219 | 	.start = s3c2410wdt_start, | 
 | 220 | 	.stop = s3c2410wdt_stop, | 
 | 221 | 	.ping = s3c2410wdt_keepalive, | 
 | 222 | 	.set_timeout = s3c2410wdt_set_heartbeat, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | }; | 
 | 224 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 225 | static struct watchdog_device s3c2410_wdd = { | 
 | 226 | 	.info = &s3c2410_wdt_ident, | 
 | 227 | 	.ops = &s3c2410wdt_ops, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | }; | 
 | 229 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | /* interrupt handler code */ | 
 | 231 |  | 
| David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 232 | static irqreturn_t s3c2410wdt_irq(int irqno, void *param) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 234 | 	dev_info(wdt_dev, "watchdog timer expired (irq)\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 236 | 	s3c2410wdt_keepalive(&s3c2410_wdd); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | 	return IRQ_HANDLED; | 
 | 238 | } | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 239 |  | 
 | 240 |  | 
 | 241 | #ifdef CONFIG_CPU_FREQ | 
 | 242 |  | 
 | 243 | static int s3c2410wdt_cpufreq_transition(struct notifier_block *nb, | 
 | 244 | 					  unsigned long val, void *data) | 
 | 245 | { | 
 | 246 | 	int ret; | 
 | 247 |  | 
 | 248 | 	if (!s3c2410wdt_is_running()) | 
 | 249 | 		goto done; | 
 | 250 |  | 
 | 251 | 	if (val == CPUFREQ_PRECHANGE) { | 
 | 252 | 		/* To ensure that over the change we don't cause the | 
 | 253 | 		 * watchdog to trigger, we perform an keep-alive if | 
 | 254 | 		 * the watchdog is running. | 
 | 255 | 		 */ | 
 | 256 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 257 | 		s3c2410wdt_keepalive(&s3c2410_wdd); | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 258 | 	} else if (val == CPUFREQ_POSTCHANGE) { | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 259 | 		s3c2410wdt_stop(&s3c2410_wdd); | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 260 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 261 | 		ret = s3c2410wdt_set_heartbeat(&s3c2410_wdd, s3c2410_wdd.timeout); | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 262 |  | 
 | 263 | 		if (ret >= 0) | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 264 | 			s3c2410wdt_start(&s3c2410_wdd); | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 265 | 		else | 
 | 266 | 			goto err; | 
 | 267 | 	} | 
 | 268 |  | 
 | 269 | done: | 
 | 270 | 	return 0; | 
 | 271 |  | 
 | 272 |  err: | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 273 | 	dev_err(wdt_dev, "cannot set new value for timeout %d\n", | 
 | 274 | 				s3c2410_wdd.timeout); | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 275 | 	return ret; | 
 | 276 | } | 
 | 277 |  | 
 | 278 | static struct notifier_block s3c2410wdt_cpufreq_transition_nb = { | 
 | 279 | 	.notifier_call	= s3c2410wdt_cpufreq_transition, | 
 | 280 | }; | 
 | 281 |  | 
 | 282 | static inline int s3c2410wdt_cpufreq_register(void) | 
 | 283 | { | 
 | 284 | 	return cpufreq_register_notifier(&s3c2410wdt_cpufreq_transition_nb, | 
 | 285 | 					 CPUFREQ_TRANSITION_NOTIFIER); | 
 | 286 | } | 
 | 287 |  | 
 | 288 | static inline void s3c2410wdt_cpufreq_deregister(void) | 
 | 289 | { | 
 | 290 | 	cpufreq_unregister_notifier(&s3c2410wdt_cpufreq_transition_nb, | 
 | 291 | 				    CPUFREQ_TRANSITION_NOTIFIER); | 
 | 292 | } | 
 | 293 |  | 
 | 294 | #else | 
 | 295 | static inline int s3c2410wdt_cpufreq_register(void) | 
 | 296 | { | 
 | 297 | 	return 0; | 
 | 298 | } | 
 | 299 |  | 
 | 300 | static inline void s3c2410wdt_cpufreq_deregister(void) | 
 | 301 | { | 
 | 302 | } | 
 | 303 | #endif | 
 | 304 |  | 
| Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 305 | static int __devinit s3c2410wdt_probe(struct platform_device *pdev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 307 | 	struct device *dev; | 
| Ben Dooks | 46b814d | 2007-06-14 12:08:54 +0100 | [diff] [blame] | 308 | 	unsigned int wtcon; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | 	int started = 0; | 
 | 310 | 	int ret; | 
 | 311 | 	int size; | 
 | 312 |  | 
| Harvey Harrison | fa9363c | 2008-03-05 18:24:58 -0800 | [diff] [blame] | 313 | 	DBG("%s: probe=%p\n", __func__, pdev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 |  | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 315 | 	dev = &pdev->dev; | 
 | 316 | 	wdt_dev = &pdev->dev; | 
 | 317 |  | 
| Julia Lawall | f72401e | 2011-02-26 17:34:38 +0100 | [diff] [blame] | 318 | 	wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 
 | 319 | 	if (wdt_mem == NULL) { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 320 | 		dev_err(dev, "no memory resource specified\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | 		return -ENOENT; | 
 | 322 | 	} | 
 | 323 |  | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 324 | 	wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 
 | 325 | 	if (wdt_irq == NULL) { | 
 | 326 | 		dev_err(dev, "no irq resource specified\n"); | 
 | 327 | 		ret = -ENOENT; | 
 | 328 | 		goto err; | 
 | 329 | 	} | 
 | 330 |  | 
 | 331 | 	/* get the memory region for the watchdog timer */ | 
 | 332 |  | 
| Julia Lawall | f72401e | 2011-02-26 17:34:38 +0100 | [diff] [blame] | 333 | 	size = resource_size(wdt_mem); | 
 | 334 | 	if (!request_mem_region(wdt_mem->start, size, pdev->name)) { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 335 | 		dev_err(dev, "failed to get memory region\n"); | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 336 | 		ret = -EBUSY; | 
 | 337 | 		goto err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | 	} | 
 | 339 |  | 
| Julia Lawall | f72401e | 2011-02-26 17:34:38 +0100 | [diff] [blame] | 340 | 	wdt_base = ioremap(wdt_mem->start, size); | 
| Ben Dooks | b4253f8 | 2008-06-22 22:36:49 +0100 | [diff] [blame] | 341 | 	if (wdt_base == NULL) { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 342 | 		dev_err(dev, "failed to ioremap() region\n"); | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 343 | 		ret = -EINVAL; | 
 | 344 | 		goto err_req; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | 	} | 
 | 346 |  | 
 | 347 | 	DBG("probe: mapped wdt_base=%p\n", wdt_base); | 
 | 348 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 349 | 	wdt_clock = clk_get(&pdev->dev, "watchdog"); | 
| Akinobu Mita | 9cd4461 | 2006-12-19 17:51:44 +0900 | [diff] [blame] | 350 | 	if (IS_ERR(wdt_clock)) { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 351 | 		dev_err(dev, "failed to find watchdog clock source\n"); | 
| Akinobu Mita | 9cd4461 | 2006-12-19 17:51:44 +0900 | [diff] [blame] | 352 | 		ret = PTR_ERR(wdt_clock); | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 353 | 		goto err_map; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | 	} | 
 | 355 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | 	clk_enable(wdt_clock); | 
 | 357 |  | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 358 | 	ret = s3c2410wdt_cpufreq_register(); | 
 | 359 | 	if (ret < 0) { | 
| Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 360 | 		pr_err("failed to register cpufreq\n"); | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 361 | 		goto err_clk; | 
 | 362 | 	} | 
 | 363 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | 	/* see if we can actually set the requested timer margin, and if | 
 | 365 | 	 * not, try the default value */ | 
 | 366 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 367 | 	if (s3c2410wdt_set_heartbeat(&s3c2410_wdd, tmr_margin)) { | 
 | 368 | 		started = s3c2410wdt_set_heartbeat(&s3c2410_wdd, | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 369 | 					CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 |  | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 371 | 		if (started == 0) | 
 | 372 | 			dev_info(dev, | 
 | 373 | 			   "tmr_margin value out of range, default %d used\n", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | 			       CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME); | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 375 | 		else | 
| Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 376 | 			dev_info(dev, "default timer value is out of range, " | 
 | 377 | 							"cannot start\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | 	} | 
 | 379 |  | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 380 | 	ret = request_irq(wdt_irq->start, s3c2410wdt_irq, 0, pdev->name, pdev); | 
 | 381 | 	if (ret != 0) { | 
 | 382 | 		dev_err(dev, "failed to install irq (%d)\n", ret); | 
 | 383 | 		goto err_cpufreq; | 
 | 384 | 	} | 
 | 385 |  | 
| Wim Van Sebroeck | ff0b3cd | 2011-11-29 16:24:16 +0100 | [diff] [blame] | 386 | 	watchdog_set_nowayout(&s3c2410_wdd, nowayout); | 
 | 387 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 388 | 	ret = watchdog_register_device(&s3c2410_wdd); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | 	if (ret) { | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 390 | 		dev_err(dev, "cannot register watchdog (%d)\n", ret); | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 391 | 		goto err_irq; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | 	} | 
 | 393 |  | 
 | 394 | 	if (tmr_atboot && started == 0) { | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 395 | 		dev_info(dev, "starting watchdog timer\n"); | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 396 | 		s3c2410wdt_start(&s3c2410_wdd); | 
| Ben Dooks | 655516c | 2006-04-19 23:02:56 +0100 | [diff] [blame] | 397 | 	} else if (!tmr_atboot) { | 
 | 398 | 		/* if we're not enabling the watchdog, then ensure it is | 
 | 399 | 		 * disabled if it has been left running from the bootloader | 
 | 400 | 		 * or other source */ | 
 | 401 |  | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 402 | 		s3c2410wdt_stop(&s3c2410_wdd); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | 	} | 
 | 404 |  | 
| Ben Dooks | 46b814d | 2007-06-14 12:08:54 +0100 | [diff] [blame] | 405 | 	/* print out a statement of readiness */ | 
 | 406 |  | 
 | 407 | 	wtcon = readl(wdt_base + S3C2410_WTCON); | 
 | 408 |  | 
| Ben Dooks | e8ef92b | 2007-06-14 12:08:55 +0100 | [diff] [blame] | 409 | 	dev_info(dev, "watchdog %sactive, reset %sabled, irq %sabled\n", | 
| Ben Dooks | 46b814d | 2007-06-14 12:08:54 +0100 | [diff] [blame] | 410 | 		 (wtcon & S3C2410_WTCON_ENABLE) ?  "" : "in", | 
| Dmitry Artamonow | 20403e8 | 2011-11-16 12:46:13 +0400 | [diff] [blame] | 411 | 		 (wtcon & S3C2410_WTCON_RSTEN) ? "en" : "dis", | 
 | 412 | 		 (wtcon & S3C2410_WTCON_INTEN) ? "en" : "dis"); | 
| Alan Cox | 41dc8b7 | 2008-08-04 17:54:46 +0100 | [diff] [blame] | 413 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | 	return 0; | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 415 |  | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 416 |  err_irq: | 
 | 417 | 	free_irq(wdt_irq->start, pdev); | 
 | 418 |  | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 419 |  err_cpufreq: | 
 | 420 | 	s3c2410wdt_cpufreq_deregister(); | 
 | 421 |  | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 422 |  err_clk: | 
 | 423 | 	clk_disable(wdt_clock); | 
 | 424 | 	clk_put(wdt_clock); | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 425 | 	wdt_clock = NULL; | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 426 |  | 
 | 427 |  err_map: | 
 | 428 | 	iounmap(wdt_base); | 
 | 429 |  | 
 | 430 |  err_req: | 
| Julia Lawall | f72401e | 2011-02-26 17:34:38 +0100 | [diff] [blame] | 431 | 	release_mem_region(wdt_mem->start, size); | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 432 |  | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 433 |  err: | 
 | 434 | 	wdt_irq = NULL; | 
 | 435 | 	wdt_mem = NULL; | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 436 | 	return ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | } | 
 | 438 |  | 
| Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 439 | static int __devexit s3c2410wdt_remove(struct platform_device *dev) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | { | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 441 | 	watchdog_unregister_device(&s3c2410_wdd); | 
| Wim Van Sebroeck | 9a37256 | 2010-05-21 08:11:42 +0000 | [diff] [blame] | 442 |  | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 443 | 	free_irq(wdt_irq->start, dev); | 
 | 444 |  | 
| Ben Dooks | e02f838 | 2009-10-30 00:30:25 +0000 | [diff] [blame] | 445 | 	s3c2410wdt_cpufreq_deregister(); | 
 | 446 |  | 
| Ben Dooks | 0b6dd8a | 2006-12-18 10:31:32 +0000 | [diff] [blame] | 447 | 	clk_disable(wdt_clock); | 
 | 448 | 	clk_put(wdt_clock); | 
 | 449 | 	wdt_clock = NULL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 |  | 
| Amol Lad | e34477e | 2006-10-06 13:41:12 -0700 | [diff] [blame] | 451 | 	iounmap(wdt_base); | 
| Wim Van Sebroeck | 9a37256 | 2010-05-21 08:11:42 +0000 | [diff] [blame] | 452 |  | 
| Julia Lawall | f72401e | 2011-02-26 17:34:38 +0100 | [diff] [blame] | 453 | 	release_mem_region(wdt_mem->start, resource_size(wdt_mem)); | 
| MyungJoo Ham | 78d3e00 | 2012-01-13 14:14:23 +0900 | [diff] [blame] | 454 | 	wdt_irq = NULL; | 
| Wim Van Sebroeck | 9a37256 | 2010-05-21 08:11:42 +0000 | [diff] [blame] | 455 | 	wdt_mem = NULL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | 	return 0; | 
 | 457 | } | 
 | 458 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 459 | static void s3c2410wdt_shutdown(struct platform_device *dev) | 
| Ben Dooks | 94f1e9f | 2005-08-17 09:04:52 +0200 | [diff] [blame] | 460 | { | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 461 | 	s3c2410wdt_stop(&s3c2410_wdd); | 
| Ben Dooks | 94f1e9f | 2005-08-17 09:04:52 +0200 | [diff] [blame] | 462 | } | 
 | 463 |  | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 464 | #ifdef CONFIG_PM | 
 | 465 |  | 
 | 466 | static unsigned long wtcon_save; | 
 | 467 | static unsigned long wtdat_save; | 
 | 468 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 469 | static int s3c2410wdt_suspend(struct platform_device *dev, pm_message_t state) | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 470 | { | 
| Russell King | 9480e30 | 2005-10-28 09:52:56 -0700 | [diff] [blame] | 471 | 	/* Save watchdog state, and turn it off. */ | 
 | 472 | 	wtcon_save = readl(wdt_base + S3C2410_WTCON); | 
 | 473 | 	wtdat_save = readl(wdt_base + S3C2410_WTDAT); | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 474 |  | 
| Russell King | 9480e30 | 2005-10-28 09:52:56 -0700 | [diff] [blame] | 475 | 	/* Note that WTCNT doesn't need to be saved. */ | 
| Wolfram Sang | 25dc46e | 2011-09-26 15:40:14 +0200 | [diff] [blame] | 476 | 	s3c2410wdt_stop(&s3c2410_wdd); | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 477 |  | 
 | 478 | 	return 0; | 
 | 479 | } | 
 | 480 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 481 | static int s3c2410wdt_resume(struct platform_device *dev) | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 482 | { | 
| Russell King | 9480e30 | 2005-10-28 09:52:56 -0700 | [diff] [blame] | 483 | 	/* Restore watchdog state. */ | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 484 |  | 
| Russell King | 9480e30 | 2005-10-28 09:52:56 -0700 | [diff] [blame] | 485 | 	writel(wtdat_save, wdt_base + S3C2410_WTDAT); | 
 | 486 | 	writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ | 
 | 487 | 	writel(wtcon_save, wdt_base + S3C2410_WTCON); | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 488 |  | 
| Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 489 | 	pr_info("watchdog %sabled\n", | 
 | 490 | 		(wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 491 |  | 
 | 492 | 	return 0; | 
 | 493 | } | 
 | 494 |  | 
 | 495 | #else | 
 | 496 | #define s3c2410wdt_suspend NULL | 
 | 497 | #define s3c2410wdt_resume  NULL | 
 | 498 | #endif /* CONFIG_PM */ | 
 | 499 |  | 
| Thomas Abraham | 9487a9c | 2011-06-22 15:24:32 +0530 | [diff] [blame] | 500 | #ifdef CONFIG_OF | 
 | 501 | static const struct of_device_id s3c2410_wdt_match[] = { | 
 | 502 | 	{ .compatible = "samsung,s3c2410-wdt" }, | 
 | 503 | 	{}, | 
 | 504 | }; | 
 | 505 | MODULE_DEVICE_TABLE(of, s3c2410_wdt_match); | 
 | 506 | #else | 
 | 507 | #define s3c2410_wdt_match NULL | 
 | 508 | #endif | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 509 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 510 | static struct platform_driver s3c2410wdt_driver = { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | 	.probe		= s3c2410wdt_probe, | 
| Wim Van Sebroeck | a77dba7 | 2009-04-14 20:20:07 +0000 | [diff] [blame] | 512 | 	.remove		= __devexit_p(s3c2410wdt_remove), | 
| Ben Dooks | 94f1e9f | 2005-08-17 09:04:52 +0200 | [diff] [blame] | 513 | 	.shutdown	= s3c2410wdt_shutdown, | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 514 | 	.suspend	= s3c2410wdt_suspend, | 
 | 515 | 	.resume		= s3c2410wdt_resume, | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 516 | 	.driver		= { | 
 | 517 | 		.owner	= THIS_MODULE, | 
 | 518 | 		.name	= "s3c2410-wdt", | 
| Thomas Abraham | 9487a9c | 2011-06-22 15:24:32 +0530 | [diff] [blame] | 519 | 		.of_match_table	= s3c2410_wdt_match, | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 520 | 	}, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | }; | 
 | 522 |  | 
 | 523 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | static int __init watchdog_init(void) | 
 | 525 | { | 
| Jaehoon Chung | ccd4144 | 2012-03-16 15:27:21 +0900 | [diff] [blame] | 526 | 	pr_info("S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n"); | 
| Joe Perches | 27c766a | 2012-02-15 15:06:19 -0800 | [diff] [blame] | 527 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 528 | 	return platform_driver_register(&s3c2410wdt_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | } | 
 | 530 |  | 
 | 531 | static void __exit watchdog_exit(void) | 
 | 532 | { | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 533 | 	platform_driver_unregister(&s3c2410wdt_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | } | 
 | 535 |  | 
 | 536 | module_init(watchdog_init); | 
 | 537 | module_exit(watchdog_exit); | 
 | 538 |  | 
| Ben Dooks | af4bb82 | 2005-08-17 09:03:23 +0200 | [diff] [blame] | 539 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>, " | 
 | 540 | 	      "Dimitry Andric <dimitry.andric@tomtom.com>"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver"); | 
 | 542 | MODULE_LICENSE("GPL"); | 
 | 543 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 
| Kay Sievers | f37d193 | 2008-04-10 21:29:23 -0700 | [diff] [blame] | 544 | MODULE_ALIAS("platform:s3c2410-wdt"); |