aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/mtx-1_wdt.c
diff options
context:
space:
mode:
authorFlorian Fainelli <florian.fainelli@telecomint.eu>2008-01-07 13:08:49 -0500
committerWim Van Sebroeck <wim@iguana.be>2008-02-18 11:54:02 -0500
commit6ea8115bb6f359df4f45152f2b40e1d4d1891392 (patch)
tree26316a283358636eab4d769cf30738655a527658 /drivers/watchdog/mtx-1_wdt.c
parent75c752e6c3147f596c13365b200b91d754b66f59 (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/mtx-1_wdt.c')
-rw-r--r--drivers/watchdog/mtx-1_wdt.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 98451747d3c..789831b3fa0 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
66static void mtx1_wdt_trigger(unsigned long unused) 70static 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
200static int __init mtx1_wdt_init(void) 205static 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
225static void __exit mtx1_wdt_exit(void) 232static 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
242static struct platform_driver mtx1_wdt = {
243 .probe = mtx1_wdt_probe,
244 .remove = mtx1_wdt_remove,
245 .driver.name = "mtx1-wdt",
246};
247
248static int __init mtx1_wdt_init(void)
249{
250 return platform_driver_register(&mtx1_wdt);
251}
252
253static void __exit mtx1_wdt_exit(void)
254{
255 platform_driver_unregister(&mtx1_wdt);
232} 256}
233 257
234module_init(mtx1_wdt_init); 258module_init(mtx1_wdt_init);
@@ -237,3 +261,4 @@ module_exit(mtx1_wdt_exit);
237MODULE_AUTHOR("Michael Stickel, Florian Fainelli"); 261MODULE_AUTHOR("Michael Stickel, Florian Fainelli");
238MODULE_DESCRIPTION("Driver for the MTX-1 watchdog"); 262MODULE_DESCRIPTION("Driver for the MTX-1 watchdog");
239MODULE_LICENSE("GPL"); 263MODULE_LICENSE("GPL");
264MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);