diff options
author | Florian Fainelli <florian.fainelli@telecomint.eu> | 2008-01-07 13:08:49 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2008-02-18 11:54:02 -0500 |
commit | 6ea8115bb6f359df4f45152f2b40e1d4d1891392 (patch) | |
tree | 26316a283358636eab4d769cf30738655a527658 /drivers/watchdog | |
parent | 75c752e6c3147f596c13365b200b91d754b66f59 (diff) |
[WATCHDOG] Convert mtx1 wdt to be a platform device and use generic GPIO API
This patch converts the MTX-1 to be a platform device, use the available
generic GPIO API for the MTX-1 board and register the miscdev alias.
Signed-off-by: Florian Fainelli <florian.fainelli@telecomint.eu>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/mtx-1_wdt.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 98451747d3cd..789831b3fa00 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c | |||
@@ -45,10 +45,13 @@ | |||
45 | #include <linux/completion.h> | 45 | #include <linux/completion.h> |
46 | #include <linux/jiffies.h> | 46 | #include <linux/jiffies.h> |
47 | #include <linux/watchdog.h> | 47 | #include <linux/watchdog.h> |
48 | #include <linux/platform_device.h> | ||
49 | |||
48 | #include <asm/io.h> | 50 | #include <asm/io.h> |
49 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
50 | 52 | ||
51 | #include <asm/mach-au1x00/au1000.h> | 53 | #include <asm/mach-au1x00/au1000.h> |
54 | #include <asm/gpio.h> | ||
52 | 55 | ||
53 | #define MTX1_WDT_INTERVAL (5 * HZ) | 56 | #define MTX1_WDT_INTERVAL (5 * HZ) |
54 | 57 | ||
@@ -61,6 +64,7 @@ static struct { | |||
61 | volatile int queue; | 64 | volatile int queue; |
62 | int default_ticks; | 65 | int default_ticks; |
63 | unsigned long inuse; | 66 | unsigned long inuse; |
67 | unsigned gpio; | ||
64 | } mtx1_wdt_device; | 68 | } mtx1_wdt_device; |
65 | 69 | ||
66 | static void mtx1_wdt_trigger(unsigned long unused) | 70 | static void mtx1_wdt_trigger(unsigned long unused) |
@@ -73,7 +77,8 @@ static void mtx1_wdt_trigger(unsigned long unused) | |||
73 | * toggle GPIO2_15 | 77 | * toggle GPIO2_15 |
74 | */ | 78 | */ |
75 | tmp = au_readl(GPIO2_DIR); | 79 | tmp = au_readl(GPIO2_DIR); |
76 | tmp = (tmp & ~(1<<15)) | ((~tmp) & (1<<15)); | 80 | tmp = (tmp & ~(1 << mtx1_wdt_device.gpio)) | |
81 | ((~tmp) & (1 << mtx1_wdt_device.gpio)); | ||
77 | au_writel (tmp, GPIO2_DIR); | 82 | au_writel (tmp, GPIO2_DIR); |
78 | 83 | ||
79 | if (mtx1_wdt_device.queue && ticks) | 84 | if (mtx1_wdt_device.queue && ticks) |
@@ -93,7 +98,7 @@ static void mtx1_wdt_start(void) | |||
93 | { | 98 | { |
94 | if (!mtx1_wdt_device.queue) { | 99 | if (!mtx1_wdt_device.queue) { |
95 | mtx1_wdt_device.queue = 1; | 100 | mtx1_wdt_device.queue = 1; |
96 | au_writel (au_readl(GPIO2_DIR) | (u32)(1<<15), GPIO2_DIR); | 101 | gpio_set_value(mtx1_wdt_device.gpio, 1); |
97 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); | 102 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); |
98 | } | 103 | } |
99 | mtx1_wdt_device.running++; | 104 | mtx1_wdt_device.running++; |
@@ -103,7 +108,7 @@ static int mtx1_wdt_stop(void) | |||
103 | { | 108 | { |
104 | if (mtx1_wdt_device.queue) { | 109 | if (mtx1_wdt_device.queue) { |
105 | mtx1_wdt_device.queue = 0; | 110 | mtx1_wdt_device.queue = 0; |
106 | au_writel (au_readl(GPIO2_DIR) & ~((u32)(1<<15)), GPIO2_DIR); | 111 | gpio_set_value(mtx1_wdt_device.gpio, 0); |
107 | } | 112 | } |
108 | 113 | ||
109 | ticks = mtx1_wdt_device.default_ticks; | 114 | ticks = mtx1_wdt_device.default_ticks; |
@@ -197,10 +202,12 @@ static struct miscdevice mtx1_wdt_misc = { | |||
197 | }; | 202 | }; |
198 | 203 | ||
199 | 204 | ||
200 | static int __init mtx1_wdt_init(void) | 205 | static int mtx1_wdt_probe(struct platform_device *pdev) |
201 | { | 206 | { |
202 | int ret; | 207 | int ret; |
203 | 208 | ||
209 | mtx1_wdt_device.gpio = pdev->resource[0].start; | ||
210 | |||
204 | if ((ret = misc_register(&mtx1_wdt_misc)) < 0) { | 211 | if ((ret = misc_register(&mtx1_wdt_misc)) < 0) { |
205 | printk(KERN_ERR " mtx-1_wdt : failed to register\n"); | 212 | printk(KERN_ERR " mtx-1_wdt : failed to register\n"); |
206 | return ret; | 213 | return ret; |
@@ -222,13 +229,30 @@ static int __init mtx1_wdt_init(void) | |||
222 | return 0; | 229 | return 0; |
223 | } | 230 | } |
224 | 231 | ||
225 | static void __exit mtx1_wdt_exit(void) | 232 | static int mtx1_wdt_remove(struct platform_device *pdev) |
226 | { | 233 | { |
227 | if (mtx1_wdt_device.queue) { | 234 | if (mtx1_wdt_device.queue) { |
228 | mtx1_wdt_device.queue = 0; | 235 | mtx1_wdt_device.queue = 0; |
229 | wait_for_completion(&mtx1_wdt_device.stop); | 236 | wait_for_completion(&mtx1_wdt_device.stop); |
230 | } | 237 | } |
231 | misc_deregister(&mtx1_wdt_misc); | 238 | misc_deregister(&mtx1_wdt_misc); |
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static struct platform_driver mtx1_wdt = { | ||
243 | .probe = mtx1_wdt_probe, | ||
244 | .remove = mtx1_wdt_remove, | ||
245 | .driver.name = "mtx1-wdt", | ||
246 | }; | ||
247 | |||
248 | static int __init mtx1_wdt_init(void) | ||
249 | { | ||
250 | return platform_driver_register(&mtx1_wdt); | ||
251 | } | ||
252 | |||
253 | static void __exit mtx1_wdt_exit(void) | ||
254 | { | ||
255 | platform_driver_unregister(&mtx1_wdt); | ||
232 | } | 256 | } |
233 | 257 | ||
234 | module_init(mtx1_wdt_init); | 258 | module_init(mtx1_wdt_init); |
@@ -237,3 +261,4 @@ module_exit(mtx1_wdt_exit); | |||
237 | MODULE_AUTHOR("Michael Stickel, Florian Fainelli"); | 261 | MODULE_AUTHOR("Michael Stickel, Florian Fainelli"); |
238 | MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); | 262 | MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); |
239 | MODULE_LICENSE("GPL"); | 263 | MODULE_LICENSE("GPL"); |
264 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||