diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-03 13:23:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-03 13:23:29 -0500 |
commit | 68b86a25225d03f134f306caffc46df80906c3f8 (patch) | |
tree | d5f6556e07e3fb376199c2ba70153c17d47b7607 /drivers/watchdog/stmp3xxx_rtc_wdt.c | |
parent | 527c680f7c36ff17d49efc99632232dba3549c51 (diff) | |
parent | 41e9f3f71bc7a5d41a2b925cfdc0dc22a77f7d8c (diff) |
Merge git://www.linux-watchdog.org/linux-watchdog
Pull watchdog updates from Wim Van Sebroeck:
"This contains:
- fixes and improvements
- devicetree bindings
- conversion to watchdog generic framework of the following drivers:
- booke_wdt
- bcm47xx_wdt.c
- at91sam9_wdt
- Removal of old STMP3xxx driver
- Addition of following new drivers:
- new driver for STMP3xxx and i.MX23/28
- Retu watchdog driver"
* git://www.linux-watchdog.org/linux-watchdog: (30 commits)
watchdog: sp805_wdt depends on ARM
watchdog: davinci_wdt: update to devm_* API
watchdog: davinci_wdt: use devm managed clk get
watchdog: at91rm9200: add DT support
watchdog: add timeout-sec property binding
watchdog: at91sam9_wdt: Convert to use the watchdog framework
watchdog: omap_wdt: Add option nowayout
watchdog: core: dt: add support for the timeout-sec dt property
watchdog: bcm47xx_wdt.c: add hard timer
watchdog: bcm47xx_wdt.c: rename wdt_time to timeout
watchdog: bcm47xx_wdt.c: rename ops methods
watchdog: bcm47xx_wdt.c: use platform device
watchdog: bcm47xx_wdt.c: convert to watchdog core api
watchdog: Convert BookE watchdog driver to watchdog infrastructure
watchdog: s3c2410_wdt: Use devm_* functions
watchdog: remove old STMP3xxx driver
watchdog: add new driver for STMP3xxx and i.MX23/28
rtc: stmp3xxx: add wdt-accessor function
watchdog: introduce retu_wdt driver
watchdog: intel_scu_watchdog: fix Kconfig dependency
...
Diffstat (limited to 'drivers/watchdog/stmp3xxx_rtc_wdt.c')
-rw-r--r-- | drivers/watchdog/stmp3xxx_rtc_wdt.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3xxx_rtc_wdt.c new file mode 100644 index 000000000000..c97e98dcde62 --- /dev/null +++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * Watchdog driver for the RTC based watchdog in STMP3xxx and i.MX23/28 | ||
3 | * | ||
4 | * Author: Wolfram Sang <w.sang@pengutronix.de> | ||
5 | * | ||
6 | * Copyright (C) 2011-12 Wolfram Sang, Pengutronix | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License version 2 as published by | ||
10 | * the Free Software Foundation. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/miscdevice.h> | ||
16 | #include <linux/watchdog.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/stmp3xxx_rtc_wdt.h> | ||
19 | |||
20 | #define WDOG_TICK_RATE 1000 /* 1 kHz clock */ | ||
21 | #define STMP3XXX_DEFAULT_TIMEOUT 19 | ||
22 | #define STMP3XXX_MAX_TIMEOUT (UINT_MAX / WDOG_TICK_RATE) | ||
23 | |||
24 | static int heartbeat = STMP3XXX_DEFAULT_TIMEOUT; | ||
25 | module_param(heartbeat, uint, 0); | ||
26 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat period in seconds from 1 to " | ||
27 | __MODULE_STRING(STMP3XXX_MAX_TIMEOUT) ", default " | ||
28 | __MODULE_STRING(STMP3XXX_DEFAULT_TIMEOUT)); | ||
29 | |||
30 | static int wdt_start(struct watchdog_device *wdd) | ||
31 | { | ||
32 | struct device *dev = watchdog_get_drvdata(wdd); | ||
33 | struct stmp3xxx_wdt_pdata *pdata = dev->platform_data; | ||
34 | |||
35 | pdata->wdt_set_timeout(dev->parent, wdd->timeout * WDOG_TICK_RATE); | ||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | static int wdt_stop(struct watchdog_device *wdd) | ||
40 | { | ||
41 | struct device *dev = watchdog_get_drvdata(wdd); | ||
42 | struct stmp3xxx_wdt_pdata *pdata = dev->platform_data; | ||
43 | |||
44 | pdata->wdt_set_timeout(dev->parent, 0); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static int wdt_set_timeout(struct watchdog_device *wdd, unsigned new_timeout) | ||
49 | { | ||
50 | wdd->timeout = new_timeout; | ||
51 | return wdt_start(wdd); | ||
52 | } | ||
53 | |||
54 | static const struct watchdog_info stmp3xxx_wdt_ident = { | ||
55 | .options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | ||
56 | .identity = "STMP3XXX RTC Watchdog", | ||
57 | }; | ||
58 | |||
59 | static const struct watchdog_ops stmp3xxx_wdt_ops = { | ||
60 | .owner = THIS_MODULE, | ||
61 | .start = wdt_start, | ||
62 | .stop = wdt_stop, | ||
63 | .set_timeout = wdt_set_timeout, | ||
64 | }; | ||
65 | |||
66 | static struct watchdog_device stmp3xxx_wdd = { | ||
67 | .info = &stmp3xxx_wdt_ident, | ||
68 | .ops = &stmp3xxx_wdt_ops, | ||
69 | .min_timeout = 1, | ||
70 | .max_timeout = STMP3XXX_MAX_TIMEOUT, | ||
71 | .status = WATCHDOG_NOWAYOUT_INIT_STATUS, | ||
72 | }; | ||
73 | |||
74 | static int stmp3xxx_wdt_probe(struct platform_device *pdev) | ||
75 | { | ||
76 | int ret; | ||
77 | |||
78 | watchdog_set_drvdata(&stmp3xxx_wdd, &pdev->dev); | ||
79 | |||
80 | stmp3xxx_wdd.timeout = clamp_t(unsigned, heartbeat, 1, STMP3XXX_MAX_TIMEOUT); | ||
81 | |||
82 | ret = watchdog_register_device(&stmp3xxx_wdd); | ||
83 | if (ret < 0) { | ||
84 | dev_err(&pdev->dev, "cannot register watchdog device\n"); | ||
85 | return ret; | ||
86 | } | ||
87 | |||
88 | dev_info(&pdev->dev, "initialized watchdog with heartbeat %ds\n", | ||
89 | stmp3xxx_wdd.timeout); | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static int stmp3xxx_wdt_remove(struct platform_device *pdev) | ||
94 | { | ||
95 | watchdog_unregister_device(&stmp3xxx_wdd); | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static struct platform_driver stmp3xxx_wdt_driver = { | ||
100 | .driver = { | ||
101 | .name = "stmp3xxx_rtc_wdt", | ||
102 | }, | ||
103 | .probe = stmp3xxx_wdt_probe, | ||
104 | .remove = stmp3xxx_wdt_remove, | ||
105 | }; | ||
106 | module_platform_driver(stmp3xxx_wdt_driver); | ||
107 | |||
108 | MODULE_DESCRIPTION("STMP3XXX RTC Watchdog Driver"); | ||
109 | MODULE_LICENSE("GPL v2"); | ||
110 | MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>"); | ||
111 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||