blob: d57f19b5077f00b86c8e70cd4e6399e6d6ff96d6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 Cox29fa0582008-10-27 15:17:56 +00009 * (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
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 Torvalds1da177e2005-04-16 15:20:36 -070024*/
25
Joe Perches27c766a2012-02-15 15:06:19 -080026#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/module.h>
29#include <linux/moduleparam.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/types.h>
31#include <linux/timer.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/watchdog.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010033#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/interrupt.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000035#include <linux/clk.h>
Alan Cox41dc8b72008-08-04 17:54:46 +010036#include <linux/uaccess.h>
37#include <linux/io.h>
Ben Dookse02f8382009-10-30 00:30:25 +000038#include <linux/cpufreq.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090039#include <linux/slab.h>
Wolfram Sang25dc46e2011-09-26 15:40:14 +020040#include <linux/err.h>
Wim Van Sebroeck3016a552012-05-03 05:24:17 +000041#include <linux/of.h>
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +053042#include <linux/mfd/syscon.h>
43#include <linux/regmap.h>
Heiko Stuebnerf286e132014-08-19 17:45:36 -070044#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Tomasz Figaa8f54012013-06-17 23:45:24 +090046#define S3C2410_WTCON 0x00
47#define S3C2410_WTDAT 0x04
48#define S3C2410_WTCNT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Tomasz Figaa8f54012013-06-17 23:45:24 +090050#define S3C2410_WTCON_RSTEN (1 << 0)
51#define S3C2410_WTCON_INTEN (1 << 2)
52#define S3C2410_WTCON_ENABLE (1 << 5)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Tomasz Figaa8f54012013-06-17 23:45:24 +090054#define S3C2410_WTCON_DIV16 (0 << 3)
55#define S3C2410_WTCON_DIV32 (1 << 3)
56#define S3C2410_WTCON_DIV64 (2 << 3)
57#define S3C2410_WTCON_DIV128 (3 << 3)
58
59#define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
60#define S3C2410_WTCON_PRESCALE_MASK (0xff << 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#define CONFIG_S3C2410_WATCHDOG_ATBOOT (0)
63#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15)
64
Doug Andersoncffc9a62013-12-06 13:08:07 -080065#define EXYNOS5_RST_STAT_REG_OFFSET 0x0404
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +053066#define EXYNOS5_WDT_DISABLE_REG_OFFSET 0x0408
67#define EXYNOS5_WDT_MASK_RESET_REG_OFFSET 0x040c
68#define QUIRK_HAS_PMU_CONFIG (1 << 0)
Doug Andersoncffc9a62013-12-06 13:08:07 -080069#define QUIRK_HAS_RST_STAT (1 << 1)
70
71/* These quirks require that we have a PMU register map */
72#define QUIRKS_HAVE_PMUREG (QUIRK_HAS_PMU_CONFIG | \
73 QUIRK_HAS_RST_STAT)
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +053074
Wim Van Sebroeck86a1e182012-03-05 16:51:11 +010075static bool nowayout = WATCHDOG_NOWAYOUT;
Fabio Porceddac1fd5f62013-02-14 09:14:25 +010076static int tmr_margin;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077static int tmr_atboot = CONFIG_S3C2410_WATCHDOG_ATBOOT;
Alan Cox41dc8b72008-08-04 17:54:46 +010078static int soft_noboot;
79static int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81module_param(tmr_margin, int, 0);
82module_param(tmr_atboot, int, 0);
Wim Van Sebroeck86a1e182012-03-05 16:51:11 +010083module_param(nowayout, bool, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084module_param(soft_noboot, int, 0);
85module_param(debug, int, 0);
86
Randy Dunlap76550d32010-05-01 09:46:15 -070087MODULE_PARM_DESC(tmr_margin, "Watchdog tmr_margin in seconds. (default="
Alan Cox41dc8b72008-08-04 17:54:46 +010088 __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME) ")");
89MODULE_PARM_DESC(tmr_atboot,
90 "Watchdog is started at boot time if set to 1, default="
91 __MODULE_STRING(CONFIG_S3C2410_WATCHDOG_ATBOOT));
92MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
93 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
Wim Van Sebroecka77dba72009-04-14 20:20:07 +000094MODULE_PARM_DESC(soft_noboot, "Watchdog action, set to 1 to ignore reboots, "
Randy Dunlap76550d32010-05-01 09:46:15 -070095 "0 to reboot (default 0)");
96MODULE_PARM_DESC(debug, "Watchdog debug, set to >1 for debug (default 0)");
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +053098/**
99 * struct s3c2410_wdt_variant - Per-variant config data
100 *
101 * @disable_reg: Offset in pmureg for the register that disables the watchdog
102 * timer reset functionality.
103 * @mask_reset_reg: Offset in pmureg for the register that masks the watchdog
104 * timer reset functionality.
105 * @mask_bit: Bit number for the watchdog timer in the disable register and the
106 * mask reset register.
Doug Andersoncffc9a62013-12-06 13:08:07 -0800107 * @rst_stat_reg: Offset in pmureg for the register that has the reset status.
108 * @rst_stat_bit: Bit number in the rst_stat register indicating a watchdog
109 * reset.
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530110 * @quirks: A bitfield of quirks.
111 */
112
113struct s3c2410_wdt_variant {
114 int disable_reg;
115 int mask_reset_reg;
116 int mask_bit;
Doug Andersoncffc9a62013-12-06 13:08:07 -0800117 int rst_stat_reg;
118 int rst_stat_bit;
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530119 u32 quirks;
120};
121
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530122struct s3c2410_wdt {
123 struct device *dev;
124 struct clk *clock;
125 void __iomem *reg_base;
126 unsigned int count;
127 spinlock_t lock;
128 unsigned long wtcon_save;
129 unsigned long wtdat_save;
130 struct watchdog_device wdt_device;
131 struct notifier_block freq_transition;
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530132 struct s3c2410_wdt_variant *drv_data;
133 struct regmap *pmureg;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530134};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530136static const struct s3c2410_wdt_variant drv_data_s3c2410 = {
137 .quirks = 0
138};
139
140#ifdef CONFIG_OF
141static const struct s3c2410_wdt_variant drv_data_exynos5250 = {
142 .disable_reg = EXYNOS5_WDT_DISABLE_REG_OFFSET,
143 .mask_reset_reg = EXYNOS5_WDT_MASK_RESET_REG_OFFSET,
144 .mask_bit = 20,
Doug Andersoncffc9a62013-12-06 13:08:07 -0800145 .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
146 .rst_stat_bit = 20,
147 .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT,
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530148};
149
150static const struct s3c2410_wdt_variant drv_data_exynos5420 = {
151 .disable_reg = EXYNOS5_WDT_DISABLE_REG_OFFSET,
152 .mask_reset_reg = EXYNOS5_WDT_MASK_RESET_REG_OFFSET,
153 .mask_bit = 0,
Doug Andersoncffc9a62013-12-06 13:08:07 -0800154 .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
155 .rst_stat_bit = 9,
156 .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT,
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530157};
158
Naveen Krishna Chatradhi2b9366b2014-08-27 15:17:11 +0530159static const struct s3c2410_wdt_variant drv_data_exynos7 = {
160 .disable_reg = EXYNOS5_WDT_DISABLE_REG_OFFSET,
161 .mask_reset_reg = EXYNOS5_WDT_MASK_RESET_REG_OFFSET,
Abhilash Kesavan5476b2b2014-10-17 21:42:53 +0530162 .mask_bit = 23,
Naveen Krishna Chatradhi2b9366b2014-08-27 15:17:11 +0530163 .rst_stat_reg = EXYNOS5_RST_STAT_REG_OFFSET,
164 .rst_stat_bit = 23, /* A57 WDTRESET */
165 .quirks = QUIRK_HAS_PMU_CONFIG | QUIRK_HAS_RST_STAT,
166};
167
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530168static const struct of_device_id s3c2410_wdt_match[] = {
169 { .compatible = "samsung,s3c2410-wdt",
170 .data = &drv_data_s3c2410 },
171 { .compatible = "samsung,exynos5250-wdt",
172 .data = &drv_data_exynos5250 },
173 { .compatible = "samsung,exynos5420-wdt",
174 .data = &drv_data_exynos5420 },
Naveen Krishna Chatradhi2b9366b2014-08-27 15:17:11 +0530175 { .compatible = "samsung,exynos7-wdt",
176 .data = &drv_data_exynos7 },
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530177 {},
178};
179MODULE_DEVICE_TABLE(of, s3c2410_wdt_match);
180#endif
181
182static const struct platform_device_id s3c2410_wdt_ids[] = {
183 {
184 .name = "s3c2410-wdt",
185 .driver_data = (unsigned long)&drv_data_s3c2410,
186 },
187 {}
188};
189MODULE_DEVICE_TABLE(platform, s3c2410_wdt_ids);
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191/* watchdog control routines */
192
Joe Perches27c766a2012-02-15 15:06:19 -0800193#define DBG(fmt, ...) \
194do { \
195 if (debug) \
196 pr_info(fmt, ##__VA_ARGS__); \
197} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199/* functions */
200
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530201static inline struct s3c2410_wdt *freq_to_wdt(struct notifier_block *nb)
202{
203 return container_of(nb, struct s3c2410_wdt, freq_transition);
204}
205
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530206static int s3c2410wdt_mask_and_disable_reset(struct s3c2410_wdt *wdt, bool mask)
207{
208 int ret;
209 u32 mask_val = 1 << wdt->drv_data->mask_bit;
210 u32 val = 0;
211
212 /* No need to do anything if no PMU CONFIG needed */
213 if (!(wdt->drv_data->quirks & QUIRK_HAS_PMU_CONFIG))
214 return 0;
215
216 if (mask)
217 val = mask_val;
218
219 ret = regmap_update_bits(wdt->pmureg,
220 wdt->drv_data->disable_reg,
221 mask_val, val);
222 if (ret < 0)
223 goto error;
224
225 ret = regmap_update_bits(wdt->pmureg,
226 wdt->drv_data->mask_reset_reg,
227 mask_val, val);
228 error:
229 if (ret < 0)
230 dev_err(wdt->dev, "failed to update reg(%d)\n", ret);
231
232 return ret;
233}
234
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200235static int s3c2410wdt_keepalive(struct watchdog_device *wdd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530237 struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
238
239 spin_lock(&wdt->lock);
240 writel(wdt->count, wdt->reg_base + S3C2410_WTCNT);
241 spin_unlock(&wdt->lock);
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200242
243 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244}
245
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530246static void __s3c2410wdt_stop(struct s3c2410_wdt *wdt)
Alan Cox41dc8b72008-08-04 17:54:46 +0100247{
248 unsigned long wtcon;
249
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530250 wtcon = readl(wdt->reg_base + S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 wtcon &= ~(S3C2410_WTCON_ENABLE | S3C2410_WTCON_RSTEN);
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530252 writel(wtcon, wdt->reg_base + S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253}
254
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200255static int s3c2410wdt_stop(struct watchdog_device *wdd)
Alan Cox41dc8b72008-08-04 17:54:46 +0100256{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530257 struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
258
259 spin_lock(&wdt->lock);
260 __s3c2410wdt_stop(wdt);
261 spin_unlock(&wdt->lock);
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200262
263 return 0;
Alan Cox41dc8b72008-08-04 17:54:46 +0100264}
265
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200266static int s3c2410wdt_start(struct watchdog_device *wdd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267{
268 unsigned long wtcon;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530269 struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530271 spin_lock(&wdt->lock);
Alan Cox41dc8b72008-08-04 17:54:46 +0100272
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530273 __s3c2410wdt_stop(wdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530275 wtcon = readl(wdt->reg_base + S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 wtcon |= S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128;
277
278 if (soft_noboot) {
279 wtcon |= S3C2410_WTCON_INTEN;
280 wtcon &= ~S3C2410_WTCON_RSTEN;
281 } else {
282 wtcon &= ~S3C2410_WTCON_INTEN;
283 wtcon |= S3C2410_WTCON_RSTEN;
284 }
285
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530286 DBG("%s: count=0x%08x, wtcon=%08lx\n",
287 __func__, wdt->count, wtcon);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530289 writel(wdt->count, wdt->reg_base + S3C2410_WTDAT);
290 writel(wdt->count, wdt->reg_base + S3C2410_WTCNT);
291 writel(wtcon, wdt->reg_base + S3C2410_WTCON);
292 spin_unlock(&wdt->lock);
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200293
294 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295}
296
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530297static inline int s3c2410wdt_is_running(struct s3c2410_wdt *wdt)
Ben Dookse02f8382009-10-30 00:30:25 +0000298{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530299 return readl(wdt->reg_base + S3C2410_WTCON) & S3C2410_WTCON_ENABLE;
Ben Dookse02f8382009-10-30 00:30:25 +0000300}
301
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200302static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, unsigned timeout)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530304 struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
305 unsigned long freq = clk_get_rate(wdt->clock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 unsigned int count;
307 unsigned int divisor = 1;
308 unsigned long wtcon;
309
310 if (timeout < 1)
311 return -EINVAL;
312
Doug Anderson17862442013-11-26 16:57:19 -0800313 freq = DIV_ROUND_UP(freq, 128);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 count = timeout * freq;
315
Ben Dookse02f8382009-10-30 00:30:25 +0000316 DBG("%s: count=%d, timeout=%d, freq=%lu\n",
Harvey Harrisonfa9363c2008-03-05 18:24:58 -0800317 __func__, count, timeout, freq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319 /* if the count is bigger than the watchdog register,
320 then work out what we need to do (and if) we can
321 actually make this value
322 */
323
324 if (count >= 0x10000) {
Doug Anderson17862442013-11-26 16:57:19 -0800325 divisor = DIV_ROUND_UP(count, 0xffff);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326
Doug Anderson17862442013-11-26 16:57:19 -0800327 if (divisor > 0x100) {
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530328 dev_err(wdt->dev, "timeout %d too big\n", timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 return -EINVAL;
330 }
331 }
332
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 DBG("%s: timeout=%d, divisor=%d, count=%d (%08x)\n",
Doug Anderson17862442013-11-26 16:57:19 -0800334 __func__, timeout, divisor, count, DIV_ROUND_UP(count, divisor));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Doug Anderson17862442013-11-26 16:57:19 -0800336 count = DIV_ROUND_UP(count, divisor);
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530337 wdt->count = count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 /* update the pre-scaler */
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530340 wtcon = readl(wdt->reg_base + S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 wtcon &= ~S3C2410_WTCON_PRESCALE_MASK;
342 wtcon |= S3C2410_WTCON_PRESCALE(divisor-1);
343
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530344 writel(count, wdt->reg_base + S3C2410_WTDAT);
345 writel(wtcon, wdt->reg_base + S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
Hans de Goede5f2430f2012-05-11 12:00:27 +0200347 wdd->timeout = (count * divisor) / freq;
Wim Van Sebroeck0197c1c2012-02-29 20:20:58 +0100348
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 return 0;
350}
351
Guenter Roeck4d8b2292016-02-26 17:32:49 -0800352static int s3c2410wdt_restart(struct watchdog_device *wdd, unsigned long action,
353 void *data)
Damien Riegelc71f5cd2015-11-16 12:28:10 -0500354{
355 struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
356 void __iomem *wdt_base = wdt->reg_base;
357
358 /* disable watchdog, to be safe */
359 writel(0, wdt_base + S3C2410_WTCON);
360
361 /* put initial values into count and data */
362 writel(0x80, wdt_base + S3C2410_WTCNT);
363 writel(0x80, wdt_base + S3C2410_WTDAT);
364
365 /* set the watchdog to go and reset... */
366 writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
367 S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
368 wdt_base + S3C2410_WTCON);
369
370 /* wait for reset to assert... */
371 mdelay(500);
372
373 return 0;
374}
375
Wim Van Sebroecka77dba72009-04-14 20:20:07 +0000376#define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
Alan Cox41dc8b72008-08-04 17:54:46 +0100378static const struct watchdog_info s3c2410_wdt_ident = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 .options = OPTIONS,
380 .firmware_version = 0,
381 .identity = "S3C2410 Watchdog",
382};
383
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200384static struct watchdog_ops s3c2410wdt_ops = {
385 .owner = THIS_MODULE,
386 .start = s3c2410wdt_start,
387 .stop = s3c2410wdt_stop,
388 .ping = s3c2410wdt_keepalive,
389 .set_timeout = s3c2410wdt_set_heartbeat,
Damien Riegelc71f5cd2015-11-16 12:28:10 -0500390 .restart = s3c2410wdt_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391};
392
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200393static struct watchdog_device s3c2410_wdd = {
394 .info = &s3c2410_wdt_ident,
395 .ops = &s3c2410wdt_ops,
Fabio Porceddac1fd5f62013-02-14 09:14:25 +0100396 .timeout = CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397};
398
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399/* interrupt handler code */
400
David Howells7d12e782006-10-05 14:55:46 +0100401static irqreturn_t s3c2410wdt_irq(int irqno, void *param)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530403 struct s3c2410_wdt *wdt = platform_get_drvdata(param);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530405 dev_info(wdt->dev, "watchdog timer expired (irq)\n");
406
407 s3c2410wdt_keepalive(&wdt->wdt_device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 return IRQ_HANDLED;
409}
Ben Dookse02f8382009-10-30 00:30:25 +0000410
Doug Anderson0f1dd982013-11-25 15:36:43 -0800411#ifdef CONFIG_ARM_S3C24XX_CPUFREQ
Ben Dookse02f8382009-10-30 00:30:25 +0000412
413static int s3c2410wdt_cpufreq_transition(struct notifier_block *nb,
414 unsigned long val, void *data)
415{
416 int ret;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530417 struct s3c2410_wdt *wdt = freq_to_wdt(nb);
Ben Dookse02f8382009-10-30 00:30:25 +0000418
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530419 if (!s3c2410wdt_is_running(wdt))
Ben Dookse02f8382009-10-30 00:30:25 +0000420 goto done;
421
422 if (val == CPUFREQ_PRECHANGE) {
423 /* To ensure that over the change we don't cause the
424 * watchdog to trigger, we perform an keep-alive if
425 * the watchdog is running.
426 */
427
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530428 s3c2410wdt_keepalive(&wdt->wdt_device);
Ben Dookse02f8382009-10-30 00:30:25 +0000429 } else if (val == CPUFREQ_POSTCHANGE) {
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530430 s3c2410wdt_stop(&wdt->wdt_device);
Ben Dookse02f8382009-10-30 00:30:25 +0000431
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530432 ret = s3c2410wdt_set_heartbeat(&wdt->wdt_device,
433 wdt->wdt_device.timeout);
Ben Dookse02f8382009-10-30 00:30:25 +0000434
435 if (ret >= 0)
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530436 s3c2410wdt_start(&wdt->wdt_device);
Ben Dookse02f8382009-10-30 00:30:25 +0000437 else
438 goto err;
439 }
440
441done:
442 return 0;
443
444 err:
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530445 dev_err(wdt->dev, "cannot set new value for timeout %d\n",
446 wdt->wdt_device.timeout);
Ben Dookse02f8382009-10-30 00:30:25 +0000447 return ret;
448}
449
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530450static inline int s3c2410wdt_cpufreq_register(struct s3c2410_wdt *wdt)
Ben Dookse02f8382009-10-30 00:30:25 +0000451{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530452 wdt->freq_transition.notifier_call = s3c2410wdt_cpufreq_transition;
453
454 return cpufreq_register_notifier(&wdt->freq_transition,
Ben Dookse02f8382009-10-30 00:30:25 +0000455 CPUFREQ_TRANSITION_NOTIFIER);
456}
457
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530458static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
Ben Dookse02f8382009-10-30 00:30:25 +0000459{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530460 wdt->freq_transition.notifier_call = s3c2410wdt_cpufreq_transition;
461
462 cpufreq_unregister_notifier(&wdt->freq_transition,
Ben Dookse02f8382009-10-30 00:30:25 +0000463 CPUFREQ_TRANSITION_NOTIFIER);
464}
465
466#else
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530467
468static inline int s3c2410wdt_cpufreq_register(struct s3c2410_wdt *wdt)
Ben Dookse02f8382009-10-30 00:30:25 +0000469{
470 return 0;
471}
472
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530473static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
Ben Dookse02f8382009-10-30 00:30:25 +0000474{
475}
476#endif
477
Doug Andersoncffc9a62013-12-06 13:08:07 -0800478static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
479{
480 unsigned int rst_stat;
481 int ret;
482
483 if (!(wdt->drv_data->quirks & QUIRK_HAS_RST_STAT))
484 return 0;
485
486 ret = regmap_read(wdt->pmureg, wdt->drv_data->rst_stat_reg, &rst_stat);
487 if (ret)
488 dev_warn(wdt->dev, "Couldn't get RST_STAT register\n");
489 else if (rst_stat & BIT(wdt->drv_data->rst_stat_bit))
490 return WDIOF_CARDRESET;
491
492 return 0;
493}
494
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530495/* s3c2410_get_wdt_driver_data */
496static inline struct s3c2410_wdt_variant *
497get_wdt_drv_data(struct platform_device *pdev)
498{
499 if (pdev->dev.of_node) {
500 const struct of_device_id *match;
501 match = of_match_node(s3c2410_wdt_match, pdev->dev.of_node);
502 return (struct s3c2410_wdt_variant *)match->data;
503 } else {
504 return (struct s3c2410_wdt_variant *)
505 platform_get_device_id(pdev)->driver_data;
506 }
507}
508
Bill Pemberton2d991a12012-11-19 13:21:41 -0500509static int s3c2410wdt_probe(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510{
Ben Dookse8ef92b2007-06-14 12:08:55 +0100511 struct device *dev;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530512 struct s3c2410_wdt *wdt;
513 struct resource *wdt_mem;
514 struct resource *wdt_irq;
Ben Dooks46b814d2007-06-14 12:08:54 +0100515 unsigned int wtcon;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 int started = 0;
517 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
Harvey Harrisonfa9363c2008-03-05 18:24:58 -0800519 DBG("%s: probe=%p\n", __func__, pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520
Ben Dookse8ef92b2007-06-14 12:08:55 +0100521 dev = &pdev->dev;
Ben Dookse8ef92b2007-06-14 12:08:55 +0100522
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530523 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
524 if (!wdt)
525 return -ENOMEM;
526
527 wdt->dev = &pdev->dev;
528 spin_lock_init(&wdt->lock);
529 wdt->wdt_device = s3c2410_wdd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530531 wdt->drv_data = get_wdt_drv_data(pdev);
Doug Andersoncffc9a62013-12-06 13:08:07 -0800532 if (wdt->drv_data->quirks & QUIRKS_HAVE_PMUREG) {
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530533 wdt->pmureg = syscon_regmap_lookup_by_phandle(dev->of_node,
534 "samsung,syscon-phandle");
535 if (IS_ERR(wdt->pmureg)) {
536 dev_err(dev, "syscon regmap lookup failed.\n");
537 return PTR_ERR(wdt->pmureg);
538 }
539 }
540
MyungJoo Ham78d3e002012-01-13 14:14:23 +0900541 wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
542 if (wdt_irq == NULL) {
543 dev_err(dev, "no irq resource specified\n");
544 ret = -ENOENT;
545 goto err;
546 }
547
548 /* get the memory region for the watchdog timer */
Julia Lawallbd5cc112013-08-14 11:11:24 +0200549 wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530550 wdt->reg_base = devm_ioremap_resource(dev, wdt_mem);
551 if (IS_ERR(wdt->reg_base)) {
552 ret = PTR_ERR(wdt->reg_base);
Jingoo Han04ecc7d2013-01-10 11:06:33 +0900553 goto err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 }
555
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530556 DBG("probe: mapped reg_base=%p\n", wdt->reg_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530558 wdt->clock = devm_clk_get(dev, "watchdog");
559 if (IS_ERR(wdt->clock)) {
Ben Dookse8ef92b2007-06-14 12:08:55 +0100560 dev_err(dev, "failed to find watchdog clock source\n");
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530561 ret = PTR_ERR(wdt->clock);
Jingoo Han04ecc7d2013-01-10 11:06:33 +0900562 goto err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 }
564
Sachin Kamat01b6af92014-03-04 15:04:35 +0530565 ret = clk_prepare_enable(wdt->clock);
566 if (ret < 0) {
567 dev_err(dev, "failed to enable clock\n");
568 return ret;
569 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530571 ret = s3c2410wdt_cpufreq_register(wdt);
MyungJoo Ham78d3e002012-01-13 14:14:23 +0900572 if (ret < 0) {
Jingoo Han38289242013-03-14 10:30:21 +0900573 dev_err(dev, "failed to register cpufreq\n");
Ben Dookse02f8382009-10-30 00:30:25 +0000574 goto err_clk;
575 }
576
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530577 watchdog_set_drvdata(&wdt->wdt_device, wdt);
578
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 /* see if we can actually set the requested timer margin, and if
580 * not, try the default value */
581
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530582 watchdog_init_timeout(&wdt->wdt_device, tmr_margin, &pdev->dev);
583 ret = s3c2410wdt_set_heartbeat(&wdt->wdt_device,
584 wdt->wdt_device.timeout);
585 if (ret) {
586 started = s3c2410wdt_set_heartbeat(&wdt->wdt_device,
Alan Cox41dc8b72008-08-04 17:54:46 +0100587 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588
Alan Cox41dc8b72008-08-04 17:54:46 +0100589 if (started == 0)
590 dev_info(dev,
591 "tmr_margin value out of range, default %d used\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME);
Alan Cox41dc8b72008-08-04 17:54:46 +0100593 else
Wim Van Sebroecka77dba72009-04-14 20:20:07 +0000594 dev_info(dev, "default timer value is out of range, "
595 "cannot start\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 }
597
Jingoo Han04ecc7d2013-01-10 11:06:33 +0900598 ret = devm_request_irq(dev, wdt_irq->start, s3c2410wdt_irq, 0,
599 pdev->name, pdev);
MyungJoo Ham78d3e002012-01-13 14:14:23 +0900600 if (ret != 0) {
601 dev_err(dev, "failed to install irq (%d)\n", ret);
602 goto err_cpufreq;
603 }
604
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530605 watchdog_set_nowayout(&wdt->wdt_device, nowayout);
Damien Riegelc71f5cd2015-11-16 12:28:10 -0500606 watchdog_set_restart_priority(&wdt->wdt_device, 128);
Wim Van Sebroeckff0b3cd2011-11-29 16:24:16 +0100607
Doug Andersoncffc9a62013-12-06 13:08:07 -0800608 wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt);
Pratyush Anand65518812015-08-20 14:05:01 +0530609 wdt->wdt_device.parent = &pdev->dev;
Doug Andersoncffc9a62013-12-06 13:08:07 -0800610
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530611 ret = watchdog_register_device(&wdt->wdt_device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 if (ret) {
Wolfram Sang25dc46e2011-09-26 15:40:14 +0200613 dev_err(dev, "cannot register watchdog (%d)\n", ret);
Jingoo Han04ecc7d2013-01-10 11:06:33 +0900614 goto err_cpufreq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 }
616
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530617 ret = s3c2410wdt_mask_and_disable_reset(wdt, false);
618 if (ret < 0)
619 goto err_unregister;
620
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 if (tmr_atboot && started == 0) {
Ben Dookse8ef92b2007-06-14 12:08:55 +0100622 dev_info(dev, "starting watchdog timer\n");
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530623 s3c2410wdt_start(&wdt->wdt_device);
Ben Dooks655516c2006-04-19 23:02:56 +0100624 } else if (!tmr_atboot) {
625 /* if we're not enabling the watchdog, then ensure it is
626 * disabled if it has been left running from the bootloader
627 * or other source */
628
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530629 s3c2410wdt_stop(&wdt->wdt_device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 }
631
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530632 platform_set_drvdata(pdev, wdt);
633
Ben Dooks46b814d2007-06-14 12:08:54 +0100634 /* print out a statement of readiness */
635
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530636 wtcon = readl(wdt->reg_base + S3C2410_WTCON);
Ben Dooks46b814d2007-06-14 12:08:54 +0100637
Ben Dookse8ef92b2007-06-14 12:08:55 +0100638 dev_info(dev, "watchdog %sactive, reset %sabled, irq %sabled\n",
Ben Dooks46b814d2007-06-14 12:08:54 +0100639 (wtcon & S3C2410_WTCON_ENABLE) ? "" : "in",
Dmitry Artamonow20403e82011-11-16 12:46:13 +0400640 (wtcon & S3C2410_WTCON_RSTEN) ? "en" : "dis",
641 (wtcon & S3C2410_WTCON_INTEN) ? "en" : "dis");
Alan Cox41dc8b72008-08-04 17:54:46 +0100642
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 return 0;
Ben Dooks0b6dd8a2006-12-18 10:31:32 +0000644
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530645 err_unregister:
646 watchdog_unregister_device(&wdt->wdt_device);
647
Ben Dookse02f8382009-10-30 00:30:25 +0000648 err_cpufreq:
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530649 s3c2410wdt_cpufreq_deregister(wdt);
Ben Dookse02f8382009-10-30 00:30:25 +0000650
Ben Dooks0b6dd8a2006-12-18 10:31:32 +0000651 err_clk:
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530652 clk_disable_unprepare(wdt->clock);
Ben Dooks0b6dd8a2006-12-18 10:31:32 +0000653
MyungJoo Ham78d3e002012-01-13 14:14:23 +0900654 err:
Ben Dooks0b6dd8a2006-12-18 10:31:32 +0000655 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656}
657
Bill Pemberton4b12b892012-11-19 13:26:24 -0500658static int s3c2410wdt_remove(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659{
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530660 int ret;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530661 struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
Wim Van Sebroeck9a372562010-05-21 08:11:42 +0000662
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530663 ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
664 if (ret < 0)
665 return ret;
666
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530667 watchdog_unregister_device(&wdt->wdt_device);
Ben Dookse02f8382009-10-30 00:30:25 +0000668
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530669 s3c2410wdt_cpufreq_deregister(wdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530671 clk_disable_unprepare(wdt->clock);
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530672
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 return 0;
674}
675
Russell King3ae5eae2005-11-09 22:32:44 +0000676static void s3c2410wdt_shutdown(struct platform_device *dev)
Ben Dooks94f1e9f2005-08-17 09:04:52 +0200677{
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530678 struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
679
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530680 s3c2410wdt_mask_and_disable_reset(wdt, true);
681
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530682 s3c2410wdt_stop(&wdt->wdt_device);
Ben Dooks94f1e9f2005-08-17 09:04:52 +0200683}
684
Jingoo Han0183984c2013-03-14 10:31:21 +0900685#ifdef CONFIG_PM_SLEEP
Ben Dooksaf4bb822005-08-17 09:03:23 +0200686
Jingoo Han0183984c2013-03-14 10:31:21 +0900687static int s3c2410wdt_suspend(struct device *dev)
Ben Dooksaf4bb822005-08-17 09:03:23 +0200688{
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530689 int ret;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530690 struct s3c2410_wdt *wdt = dev_get_drvdata(dev);
691
Russell King9480e302005-10-28 09:52:56 -0700692 /* Save watchdog state, and turn it off. */
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530693 wdt->wtcon_save = readl(wdt->reg_base + S3C2410_WTCON);
694 wdt->wtdat_save = readl(wdt->reg_base + S3C2410_WTDAT);
Ben Dooksaf4bb822005-08-17 09:03:23 +0200695
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530696 ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
697 if (ret < 0)
698 return ret;
699
Russell King9480e302005-10-28 09:52:56 -0700700 /* Note that WTCNT doesn't need to be saved. */
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530701 s3c2410wdt_stop(&wdt->wdt_device);
Ben Dooksaf4bb822005-08-17 09:03:23 +0200702
703 return 0;
704}
705
Jingoo Han0183984c2013-03-14 10:31:21 +0900706static int s3c2410wdt_resume(struct device *dev)
Ben Dooksaf4bb822005-08-17 09:03:23 +0200707{
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530708 int ret;
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530709 struct s3c2410_wdt *wdt = dev_get_drvdata(dev);
Ben Dooksaf4bb822005-08-17 09:03:23 +0200710
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530711 /* Restore watchdog state. */
712 writel(wdt->wtdat_save, wdt->reg_base + S3C2410_WTDAT);
713 writel(wdt->wtdat_save, wdt->reg_base + S3C2410_WTCNT);/* Reset count */
714 writel(wdt->wtcon_save, wdt->reg_base + S3C2410_WTCON);
Ben Dooksaf4bb822005-08-17 09:03:23 +0200715
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530716 ret = s3c2410wdt_mask_and_disable_reset(wdt, false);
717 if (ret < 0)
718 return ret;
719
Jingoo Han0183984c2013-03-14 10:31:21 +0900720 dev_info(dev, "watchdog %sabled\n",
Leela Krishna Amudalaaf4ea632013-08-27 15:36:03 +0530721 (wdt->wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis");
Ben Dooksaf4bb822005-08-17 09:03:23 +0200722
723 return 0;
724}
Jingoo Han0183984c2013-03-14 10:31:21 +0900725#endif
Ben Dooksaf4bb822005-08-17 09:03:23 +0200726
Jingoo Han0183984c2013-03-14 10:31:21 +0900727static SIMPLE_DEV_PM_OPS(s3c2410wdt_pm_ops, s3c2410wdt_suspend,
728 s3c2410wdt_resume);
Ben Dooksaf4bb822005-08-17 09:03:23 +0200729
Russell King3ae5eae2005-11-09 22:32:44 +0000730static struct platform_driver s3c2410wdt_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 .probe = s3c2410wdt_probe,
Bill Pemberton82268712012-11-19 13:21:12 -0500732 .remove = s3c2410wdt_remove,
Ben Dooks94f1e9f2005-08-17 09:04:52 +0200733 .shutdown = s3c2410wdt_shutdown,
Leela Krishna Amudala4f1f6532013-12-06 11:17:47 +0530734 .id_table = s3c2410_wdt_ids,
Russell King3ae5eae2005-11-09 22:32:44 +0000735 .driver = {
Russell King3ae5eae2005-11-09 22:32:44 +0000736 .name = "s3c2410-wdt",
Jingoo Han0183984c2013-03-14 10:31:21 +0900737 .pm = &s3c2410wdt_pm_ops,
Wim Van Sebroeck3016a552012-05-03 05:24:17 +0000738 .of_match_table = of_match_ptr(s3c2410_wdt_match),
Russell King3ae5eae2005-11-09 22:32:44 +0000739 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740};
741
Sachin Kamat6b761b22012-07-12 17:17:40 +0530742module_platform_driver(s3c2410wdt_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743
Ben Dooksaf4bb822005-08-17 09:03:23 +0200744MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>, "
745 "Dimitry Andric <dimitry.andric@tomtom.com>");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver");
747MODULE_LICENSE("GPL");