aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/mtx-1_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/mtx-1_wdt.c')
-rw-r--r--drivers/watchdog/mtx-1_wdt.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 1479dc4d6129..0430e093b1a0 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -66,23 +66,18 @@ static struct {
66 int default_ticks; 66 int default_ticks;
67 unsigned long inuse; 67 unsigned long inuse;
68 unsigned gpio; 68 unsigned gpio;
69 int gstate; 69 unsigned int gstate;
70} mtx1_wdt_device; 70} mtx1_wdt_device;
71 71
72static void mtx1_wdt_trigger(unsigned long unused) 72static void mtx1_wdt_trigger(unsigned long unused)
73{ 73{
74 u32 tmp;
75
76 spin_lock(&mtx1_wdt_device.lock); 74 spin_lock(&mtx1_wdt_device.lock);
77 if (mtx1_wdt_device.running) 75 if (mtx1_wdt_device.running)
78 ticks--; 76 ticks--;
79 77
80 /* toggle wdt gpio */ 78 /* toggle wdt gpio */
81 mtx1_wdt_device.gstate = ~mtx1_wdt_device.gstate; 79 mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate;
82 if (mtx1_wdt_device.gstate) 80 gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate);
83 gpio_direction_output(mtx1_wdt_device.gpio, 1);
84 else
85 gpio_direction_input(mtx1_wdt_device.gpio);
86 81
87 if (mtx1_wdt_device.queue && ticks) 82 if (mtx1_wdt_device.queue && ticks)
88 mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); 83 mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
@@ -105,7 +100,7 @@ static void mtx1_wdt_start(void)
105 if (!mtx1_wdt_device.queue) { 100 if (!mtx1_wdt_device.queue) {
106 mtx1_wdt_device.queue = 1; 101 mtx1_wdt_device.queue = 1;
107 mtx1_wdt_device.gstate = 1; 102 mtx1_wdt_device.gstate = 1;
108 gpio_direction_output(mtx1_wdt_device.gpio, 1); 103 gpio_set_value(mtx1_wdt_device.gpio, 1);
109 mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); 104 mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
110 } 105 }
111 mtx1_wdt_device.running++; 106 mtx1_wdt_device.running++;
@@ -120,7 +115,7 @@ static int mtx1_wdt_stop(void)
120 if (mtx1_wdt_device.queue) { 115 if (mtx1_wdt_device.queue) {
121 mtx1_wdt_device.queue = 0; 116 mtx1_wdt_device.queue = 0;
122 mtx1_wdt_device.gstate = 0; 117 mtx1_wdt_device.gstate = 0;
123 gpio_direction_output(mtx1_wdt_device.gpio, 0); 118 gpio_set_value(mtx1_wdt_device.gpio, 0);
124 } 119 }
125 ticks = mtx1_wdt_device.default_ticks; 120 ticks = mtx1_wdt_device.default_ticks;
126 spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags); 121 spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
@@ -214,6 +209,12 @@ static int __devinit mtx1_wdt_probe(struct platform_device *pdev)
214 int ret; 209 int ret;
215 210
216 mtx1_wdt_device.gpio = pdev->resource[0].start; 211 mtx1_wdt_device.gpio = pdev->resource[0].start;
212 ret = gpio_request_one(mtx1_wdt_device.gpio,
213 GPIOF_OUT_INIT_HIGH, "mtx1-wdt");
214 if (ret < 0) {
215 dev_err(&pdev->dev, "failed to request gpio");
216 return ret;
217 }
217 218
218 spin_lock_init(&mtx1_wdt_device.lock); 219 spin_lock_init(&mtx1_wdt_device.lock);
219 init_completion(&mtx1_wdt_device.stop); 220 init_completion(&mtx1_wdt_device.stop);
@@ -239,11 +240,13 @@ static int __devexit mtx1_wdt_remove(struct platform_device *pdev)
239 mtx1_wdt_device.queue = 0; 240 mtx1_wdt_device.queue = 0;
240 wait_for_completion(&mtx1_wdt_device.stop); 241 wait_for_completion(&mtx1_wdt_device.stop);
241 } 242 }
243
244 gpio_free(mtx1_wdt_device.gpio);
242 misc_deregister(&mtx1_wdt_misc); 245 misc_deregister(&mtx1_wdt_misc);
243 return 0; 246 return 0;
244} 247}
245 248
246static struct platform_driver mtx1_wdt = { 249static struct platform_driver mtx1_wdt_driver = {
247 .probe = mtx1_wdt_probe, 250 .probe = mtx1_wdt_probe,
248 .remove = __devexit_p(mtx1_wdt_remove), 251 .remove = __devexit_p(mtx1_wdt_remove),
249 .driver.name = "mtx1-wdt", 252 .driver.name = "mtx1-wdt",
@@ -252,12 +255,12 @@ static struct platform_driver mtx1_wdt = {
252 255
253static int __init mtx1_wdt_init(void) 256static int __init mtx1_wdt_init(void)
254{ 257{
255 return platform_driver_register(&mtx1_wdt); 258 return platform_driver_register(&mtx1_wdt_driver);
256} 259}
257 260
258static void __exit mtx1_wdt_exit(void) 261static void __exit mtx1_wdt_exit(void)
259{ 262{
260 platform_driver_unregister(&mtx1_wdt); 263 platform_driver_unregister(&mtx1_wdt_driver);
261} 264}
262 265
263module_init(mtx1_wdt_init); 266module_init(mtx1_wdt_init);