diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-11-01 13:43:31 -0400 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-11-28 09:50:39 -0500 |
commit | c1c30a29df7e47310caa979dc48f715ae478de5f (patch) | |
tree | bea09972cee59473033064e55a649105e86525a7 /drivers | |
parent | f22deee523e0ff49c3be01dd6f979d374230725a (diff) |
ARM: at91: make watchdog drivers soc independent
switch the watchdog drivers to resource and pass it via platform_device
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/at91sam9_wdt.c | 22 | ||||
-rw-r--r-- | drivers/watchdog/at91sam9_wdt.h | 6 |
2 files changed, 22 insertions, 6 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 " | |||
63 | static void at91_ping(unsigned long data); | 68 | static void at91_ping(unsigned long data); |
64 | 69 | ||
65 | static struct { | 70 | static 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 | */ |
78 | static inline void at91_wdt_reset(void) | 84 | static 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 | ||
249 | static int __init at91wdt_probe(struct platform_device *pdev) | 255 | static 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) |
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h index 757f9cab5c82..c6fbb2e6c41b 100644 --- a/drivers/watchdog/at91sam9_wdt.h +++ b/drivers/watchdog/at91sam9_wdt.h | |||
@@ -16,11 +16,11 @@ | |||
16 | #ifndef AT91_WDT_H | 16 | #ifndef AT91_WDT_H |
17 | #define AT91_WDT_H | 17 | #define AT91_WDT_H |
18 | 18 | ||
19 | #define AT91_WDT_CR (AT91_WDT + 0x00) /* Watchdog Control Register */ | 19 | #define AT91_WDT_CR 0x00 /* Watchdog Control Register */ |
20 | #define AT91_WDT_WDRSTT (1 << 0) /* Restart */ | 20 | #define AT91_WDT_WDRSTT (1 << 0) /* Restart */ |
21 | #define AT91_WDT_KEY (0xa5 << 24) /* KEY Password */ | 21 | #define AT91_WDT_KEY (0xa5 << 24) /* KEY Password */ |
22 | 22 | ||
23 | #define AT91_WDT_MR (AT91_WDT + 0x04) /* Watchdog Mode Register */ | 23 | #define AT91_WDT_MR 0x04 /* Watchdog Mode Register */ |
24 | #define AT91_WDT_WDV (0xfff << 0) /* Counter Value */ | 24 | #define AT91_WDT_WDV (0xfff << 0) /* Counter Value */ |
25 | #define AT91_WDT_WDFIEN (1 << 12) /* Fault Interrupt Enable */ | 25 | #define AT91_WDT_WDFIEN (1 << 12) /* Fault Interrupt Enable */ |
26 | #define AT91_WDT_WDRSTEN (1 << 13) /* Reset Processor */ | 26 | #define AT91_WDT_WDRSTEN (1 << 13) /* Reset Processor */ |
@@ -30,7 +30,7 @@ | |||
30 | #define AT91_WDT_WDDBGHLT (1 << 28) /* Debug Halt */ | 30 | #define AT91_WDT_WDDBGHLT (1 << 28) /* Debug Halt */ |
31 | #define AT91_WDT_WDIDLEHLT (1 << 29) /* Idle Halt */ | 31 | #define AT91_WDT_WDIDLEHLT (1 << 29) /* Idle Halt */ |
32 | 32 | ||
33 | #define AT91_WDT_SR (AT91_WDT + 0x08) /* Watchdog Status Register */ | 33 | #define AT91_WDT_SR 0x08 /* Watchdog Status Register */ |
34 | #define AT91_WDT_WDUNF (1 << 0) /* Watchdog Underflow */ | 34 | #define AT91_WDT_WDUNF (1 << 0) /* Watchdog Underflow */ |
35 | #define AT91_WDT_WDERR (1 << 1) /* Watchdog Error */ | 35 | #define AT91_WDT_WDERR (1 << 1) /* Watchdog Error */ |
36 | 36 | ||