diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-03-12 08:07:27 -0400 |
---|---|---|
committer | Nicolas Ferre <nicolas.ferre@atmel.com> | 2015-03-16 12:03:01 -0400 |
commit | 8432f9e5e82a13b82a76171c89b0858e855c9da5 (patch) | |
tree | 1bbae26117476b5f464e6d79c6b1c740d7b7a0cc /drivers/watchdog | |
parent | 1aa15f4e00c9be2c7e4c3bd36886ed65d25cc075 (diff) |
watchdog: at91rm9200: use the system timer syscon
Use a syscon regmap to access the system timer registers.
Also, rename the driver atmel_st_watchdog to stop conflicting with
at91sam9_wdt.c
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/Kconfig | 2 | ||||
-rw-r--r-- | drivers/watchdog/at91rm9200_wdt.c | 29 |
2 files changed, 23 insertions, 8 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 16f202350997..ce4f3a7f95fd 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -154,7 +154,7 @@ config ARM_SP805_WATCHDOG | |||
154 | 154 | ||
155 | config AT91RM9200_WATCHDOG | 155 | config AT91RM9200_WATCHDOG |
156 | tristate "AT91RM9200 watchdog" | 156 | tristate "AT91RM9200 watchdog" |
157 | depends on SOC_AT91RM9200 | 157 | depends on SOC_AT91RM9200 && MFD_SYSCON |
158 | help | 158 | help |
159 | Watchdog timer embedded into AT91RM9200 chips. This will reboot your | 159 | Watchdog timer embedded into AT91RM9200 chips. This will reboot your |
160 | system when the timeout is reached. | 160 | system when the timeout is reached. |
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index d244112d5b6f..e6fa87d85de3 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
@@ -17,22 +17,25 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/io.h> | 18 | #include <linux/io.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/mfd/syscon.h> | ||
21 | #include <linux/mfd/syscon/atmel-st.h> | ||
20 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
21 | #include <linux/module.h> | 23 | #include <linux/module.h> |
22 | #include <linux/moduleparam.h> | 24 | #include <linux/moduleparam.h> |
23 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/regmap.h> | ||
24 | #include <linux/types.h> | 27 | #include <linux/types.h> |
25 | #include <linux/watchdog.h> | 28 | #include <linux/watchdog.h> |
26 | #include <linux/uaccess.h> | 29 | #include <linux/uaccess.h> |
27 | #include <linux/of.h> | 30 | #include <linux/of.h> |
28 | #include <linux/of_device.h> | 31 | #include <linux/of_device.h> |
29 | #include <mach/at91_st.h> | ||
30 | 32 | ||
31 | #define WDT_DEFAULT_TIME 5 /* seconds */ | 33 | #define WDT_DEFAULT_TIME 5 /* seconds */ |
32 | #define WDT_MAX_TIME 256 /* seconds */ | 34 | #define WDT_MAX_TIME 256 /* seconds */ |
33 | 35 | ||
34 | static int wdt_time = WDT_DEFAULT_TIME; | 36 | static int wdt_time = WDT_DEFAULT_TIME; |
35 | static bool nowayout = WATCHDOG_NOWAYOUT; | 37 | static bool nowayout = WATCHDOG_NOWAYOUT; |
38 | static struct regmap *regmap_st; | ||
36 | 39 | ||
37 | module_param(wdt_time, int, 0); | 40 | module_param(wdt_time, int, 0); |
38 | MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" | 41 | MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" |
@@ -55,7 +58,7 @@ static unsigned long at91wdt_busy; | |||
55 | */ | 58 | */ |
56 | static inline void at91_wdt_stop(void) | 59 | static inline void at91_wdt_stop(void) |
57 | { | 60 | { |
58 | at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN); | 61 | regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN); |
59 | } | 62 | } |
60 | 63 | ||
61 | /* | 64 | /* |
@@ -63,9 +66,9 @@ static inline void at91_wdt_stop(void) | |||
63 | */ | 66 | */ |
64 | static inline void at91_wdt_start(void) | 67 | static inline void at91_wdt_start(void) |
65 | { | 68 | { |
66 | at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN | | 69 | regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN | |
67 | (((65536 * wdt_time) >> 8) & AT91_ST_WDV)); | 70 | (((65536 * wdt_time) >> 8) & AT91_ST_WDV)); |
68 | at91_st_write(AT91_ST_CR, AT91_ST_WDRST); | 71 | regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST); |
69 | } | 72 | } |
70 | 73 | ||
71 | /* | 74 | /* |
@@ -73,7 +76,7 @@ static inline void at91_wdt_start(void) | |||
73 | */ | 76 | */ |
74 | static inline void at91_wdt_reload(void) | 77 | static inline void at91_wdt_reload(void) |
75 | { | 78 | { |
76 | at91_st_write(AT91_ST_CR, AT91_ST_WDRST); | 79 | regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST); |
77 | } | 80 | } |
78 | 81 | ||
79 | /* ......................................................................... */ | 82 | /* ......................................................................... */ |
@@ -203,12 +206,24 @@ static struct miscdevice at91wdt_miscdev = { | |||
203 | 206 | ||
204 | static int at91wdt_probe(struct platform_device *pdev) | 207 | static int at91wdt_probe(struct platform_device *pdev) |
205 | { | 208 | { |
209 | struct device *dev = &pdev->dev; | ||
210 | struct device *parent; | ||
206 | int res; | 211 | int res; |
207 | 212 | ||
208 | if (at91wdt_miscdev.parent) | 213 | if (at91wdt_miscdev.parent) |
209 | return -EBUSY; | 214 | return -EBUSY; |
210 | at91wdt_miscdev.parent = &pdev->dev; | 215 | at91wdt_miscdev.parent = &pdev->dev; |
211 | 216 | ||
217 | parent = dev->parent; | ||
218 | if (!parent) { | ||
219 | dev_err(dev, "no parent\n"); | ||
220 | return -ENODEV; | ||
221 | } | ||
222 | |||
223 | regmap_st = syscon_node_to_regmap(parent->of_node); | ||
224 | if (!regmap_st) | ||
225 | return -ENODEV; | ||
226 | |||
212 | res = misc_register(&at91wdt_miscdev); | 227 | res = misc_register(&at91wdt_miscdev); |
213 | if (res) | 228 | if (res) |
214 | return res; | 229 | return res; |
@@ -267,7 +282,7 @@ static struct platform_driver at91wdt_driver = { | |||
267 | .suspend = at91wdt_suspend, | 282 | .suspend = at91wdt_suspend, |
268 | .resume = at91wdt_resume, | 283 | .resume = at91wdt_resume, |
269 | .driver = { | 284 | .driver = { |
270 | .name = "at91_wdt", | 285 | .name = "atmel_st_watchdog", |
271 | .of_match_table = at91_wdt_dt_ids, | 286 | .of_match_table = at91_wdt_dt_ids, |
272 | }, | 287 | }, |
273 | }; | 288 | }; |
@@ -296,4 +311,4 @@ module_exit(at91_wdt_exit); | |||
296 | MODULE_AUTHOR("Andrew Victor"); | 311 | MODULE_AUTHOR("Andrew Victor"); |
297 | MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200"); | 312 | MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200"); |
298 | MODULE_LICENSE("GPL"); | 313 | MODULE_LICENSE("GPL"); |
299 | MODULE_ALIAS("platform:at91_wdt"); | 314 | MODULE_ALIAS("platform:atmel_st_watchdog"); |