aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/at91sam9_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/at91sam9_wdt.c')
-rw-r--r--drivers/watchdog/at91sam9_wdt.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c
index 87445b2d72a7..00562566ef5f 100644
--- a/drivers/watchdog/at91sam9_wdt.c
+++ b/drivers/watchdog/at91sam9_wdt.c
@@ -35,6 +35,11 @@
35 35
36#define DRV_NAME "AT91SAM9 Watchdog" 36#define DRV_NAME "AT91SAM9 Watchdog"
37 37
38#define wdt_read(field) \
39 __raw_readl(at91wdt_private.base + field)
40#define wdt_write(field, val) \
41 __raw_writel((val), at91wdt_private.base + field)
42
38/* AT91SAM9 watchdog runs a 12bit counter @ 256Hz, 43/* AT91SAM9 watchdog runs a 12bit counter @ 256Hz,
39 * use this to convert a watchdog 44 * use this to convert a watchdog
40 * value from/to milliseconds. 45 * value from/to milliseconds.
@@ -63,6 +68,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
63static void at91_ping(unsigned long data); 68static void at91_ping(unsigned long data);
64 69
65static struct { 70static struct {
71 void __iomem *base;
66 unsigned long next_heartbeat; /* the next_heartbeat for the timer */ 72 unsigned long next_heartbeat; /* the next_heartbeat for the timer */
67 unsigned long open; 73 unsigned long open;
68 char expect_close; 74 char expect_close;
@@ -77,7 +83,7 @@ static struct {
77 */ 83 */
78static inline void at91_wdt_reset(void) 84static inline void at91_wdt_reset(void)
79{ 85{
80 at91_sys_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT); 86 wdt_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
81} 87}
82 88
83/* 89/*
@@ -132,7 +138,7 @@ static int at91_wdt_settimeout(unsigned int timeout)
132 unsigned int mr; 138 unsigned int mr;
133 139
134 /* Check if disabled */ 140 /* Check if disabled */
135 mr = at91_sys_read(AT91_WDT_MR); 141 mr = wdt_read(AT91_WDT_MR);
136 if (mr & AT91_WDT_WDDIS) { 142 if (mr & AT91_WDT_WDDIS) {
137 printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n"); 143 printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n");
138 return -EIO; 144 return -EIO;
@@ -149,7 +155,7 @@ static int at91_wdt_settimeout(unsigned int timeout)
149 | AT91_WDT_WDDBGHLT /* disabled in debug mode */ 155 | AT91_WDT_WDDBGHLT /* disabled in debug mode */
150 | AT91_WDT_WDD /* restart at any time */ 156 | AT91_WDT_WDD /* restart at any time */
151 | (timeout & AT91_WDT_WDV); /* timer value */ 157 | (timeout & AT91_WDT_WDV); /* timer value */
152 at91_sys_write(AT91_WDT_MR, reg); 158 wdt_write(AT91_WDT_MR, reg);
153 159
154 return 0; 160 return 0;
155} 161}
@@ -248,12 +254,22 @@ static struct miscdevice at91wdt_miscdev = {
248 254
249static int __init at91wdt_probe(struct platform_device *pdev) 255static int __init at91wdt_probe(struct platform_device *pdev)
250{ 256{
257 struct resource *r;
251 int res; 258 int res;
252 259
253 if (at91wdt_miscdev.parent) 260 if (at91wdt_miscdev.parent)
254 return -EBUSY; 261 return -EBUSY;
255 at91wdt_miscdev.parent = &pdev->dev; 262 at91wdt_miscdev.parent = &pdev->dev;
256 263
264 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
265 if (!r)
266 return -ENODEV;
267 at91wdt_private.base = ioremap(r->start, resource_size(r));
268 if (!at91wdt_private.base) {
269 dev_err(&pdev->dev, "failed to map registers, aborting.\n");
270 return -ENOMEM;
271 }
272
257 /* Set watchdog */ 273 /* Set watchdog */
258 res = at91_wdt_settimeout(ms_to_ticks(WDT_HW_TIMEOUT * 1000)); 274 res = at91_wdt_settimeout(ms_to_ticks(WDT_HW_TIMEOUT * 1000));
259 if (res) 275 if (res)