~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/watchdog/mtx-1_wdt.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        int default_ticks;
67
67
        unsigned long inuse;
68
68
        unsigned gpio;
 
69
        unsigned int gstate;
69
70
} mtx1_wdt_device;
70
71
 
71
72
static void mtx1_wdt_trigger(unsigned long unused)
72
73
{
73
 
        u32 tmp;
74
 
 
75
74
        spin_lock(&mtx1_wdt_device.lock);
76
75
        if (mtx1_wdt_device.running)
77
76
                ticks--;
78
 
        /*
79
 
         * toggle GPIO2_15
80
 
         */
81
 
        tmp = au_readl(GPIO2_DIR);
82
 
        tmp = (tmp & ~(1 << mtx1_wdt_device.gpio)) |
83
 
              ((~tmp) & (1 << mtx1_wdt_device.gpio));
84
 
        au_writel(tmp, GPIO2_DIR);
 
77
 
 
78
        /* toggle wdt gpio */
 
79
        mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate;
 
80
        gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate);
85
81
 
86
82
        if (mtx1_wdt_device.queue && ticks)
87
83
                mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
103
99
        spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
104
100
        if (!mtx1_wdt_device.queue) {
105
101
                mtx1_wdt_device.queue = 1;
 
102
                mtx1_wdt_device.gstate = 1;
106
103
                gpio_set_value(mtx1_wdt_device.gpio, 1);
107
104
                mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
108
105
        }
117
114
        spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
118
115
        if (mtx1_wdt_device.queue) {
119
116
                mtx1_wdt_device.queue = 0;
 
117
                mtx1_wdt_device.gstate = 0;
120
118
                gpio_set_value(mtx1_wdt_device.gpio, 0);
121
119
        }
122
120
        ticks = mtx1_wdt_device.default_ticks;
190
188
}
191
189
 
192
190
static const struct file_operations mtx1_wdt_fops = {
193
 
        .owner          = THIS_MODULE,
 
191
        .owner          = THIS_MODULE,
194
192
        .llseek         = no_llseek,
195
193
        .unlocked_ioctl = mtx1_wdt_ioctl,
196
 
        .open           = mtx1_wdt_open,
197
 
        .write          = mtx1_wdt_write,
198
 
        .release        = mtx1_wdt_release,
 
194
        .open           = mtx1_wdt_open,
 
195
        .write          = mtx1_wdt_write,
 
196
        .release        = mtx1_wdt_release,
199
197
};
200
198
 
201
199
 
202
200
static struct miscdevice mtx1_wdt_misc = {
203
 
        .minor  = WATCHDOG_MINOR,
204
 
        .name   = "watchdog",
205
 
        .fops   = &mtx1_wdt_fops,
 
201
        .minor  = WATCHDOG_MINOR,
 
202
        .name   = "watchdog",
 
203
        .fops   = &mtx1_wdt_fops,
206
204
};
207
205
 
208
206
 
211
209
        int ret;
212
210
 
213
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
        }
214
218
 
215
219
        spin_lock_init(&mtx1_wdt_device.lock);
216
220
        init_completion(&mtx1_wdt_device.stop);
236
240
                mtx1_wdt_device.queue = 0;
237
241
                wait_for_completion(&mtx1_wdt_device.stop);
238
242
        }
 
243
 
 
244
        gpio_free(mtx1_wdt_device.gpio);
239
245
        misc_deregister(&mtx1_wdt_misc);
240
246
        return 0;
241
247
}
242
248
 
243
 
static struct platform_driver mtx1_wdt = {
 
249
static struct platform_driver mtx1_wdt_driver = {
244
250
        .probe = mtx1_wdt_probe,
245
251
        .remove = __devexit_p(mtx1_wdt_remove),
246
252
        .driver.name = "mtx1-wdt",
249
255
 
250
256
static int __init mtx1_wdt_init(void)
251
257
{
252
 
        return platform_driver_register(&mtx1_wdt);
 
258
        return platform_driver_register(&mtx1_wdt_driver);
253
259
}
254
260
 
255
261
static void __exit mtx1_wdt_exit(void)
256
262
{
257
 
        platform_driver_unregister(&mtx1_wdt);
 
263
        platform_driver_unregister(&mtx1_wdt_driver);
258
264
}
259
265
 
260
266
module_init(mtx1_wdt_init);