aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-03-24 15:15:55 -0400
committerArnd Bergmann <arnd@arndb.de>2012-03-24 15:16:04 -0400
commit7d1206bc2859c6e9f46e35ae697c138e7d7858a7 (patch)
tree14af84e9a635e59293edf81aa562b6740c57d310 /drivers/watchdog
parentf4eb28340771c12cdbf8b5ec149dbd3b0eef1687 (diff)
parentc899445f9783309ac73073282d4c0ae27f51fa9a (diff)
Merge branch 'kirkwood/dt' into next/dt2
This was part of the for-next branch earlier but for some reasons a rebuild of the tree missed it, so I'm putting it back in now. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/orion_wdt.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c
index 4ad78f868515..1368e4ca3100 100644
--- a/drivers/watchdog/orion_wdt.c
+++ b/drivers/watchdog/orion_wdt.c
@@ -28,9 +28,9 @@
28/* 28/*
29 * Watchdog timer block registers. 29 * Watchdog timer block registers.
30 */ 30 */
31#define TIMER_CTRL (TIMER_VIRT_BASE + 0x0000) 31#define TIMER_CTRL 0x0000
32#define WDT_EN 0x0010 32#define WDT_EN 0x0010
33#define WDT_VAL (TIMER_VIRT_BASE + 0x0024) 33#define WDT_VAL 0x0024
34 34
35#define WDT_MAX_CYCLE_COUNT 0xffffffff 35#define WDT_MAX_CYCLE_COUNT 0xffffffff
36#define WDT_IN_USE 0 36#define WDT_IN_USE 0
@@ -40,6 +40,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
40static int heartbeat = -1; /* module parameter (seconds) */ 40static int heartbeat = -1; /* module parameter (seconds) */
41static unsigned int wdt_max_duration; /* (seconds) */ 41static unsigned int wdt_max_duration; /* (seconds) */
42static unsigned int wdt_tclk; 42static unsigned int wdt_tclk;
43static void __iomem *wdt_reg;
43static unsigned long wdt_status; 44static unsigned long wdt_status;
44static DEFINE_SPINLOCK(wdt_lock); 45static DEFINE_SPINLOCK(wdt_lock);
45 46
@@ -48,7 +49,7 @@ static void orion_wdt_ping(void)
48 spin_lock(&wdt_lock); 49 spin_lock(&wdt_lock);
49 50
50 /* Reload watchdog duration */ 51 /* Reload watchdog duration */
51 writel(wdt_tclk * heartbeat, WDT_VAL); 52 writel(wdt_tclk * heartbeat, wdt_reg + WDT_VAL);
52 53
53 spin_unlock(&wdt_lock); 54 spin_unlock(&wdt_lock);
54} 55}
@@ -60,7 +61,7 @@ static void orion_wdt_enable(void)
60 spin_lock(&wdt_lock); 61 spin_lock(&wdt_lock);
61 62
62 /* Set watchdog duration */ 63 /* Set watchdog duration */
63 writel(wdt_tclk * heartbeat, WDT_VAL); 64 writel(wdt_tclk * heartbeat, wdt_reg + WDT_VAL);
64 65
65 /* Clear watchdog timer interrupt */ 66 /* Clear watchdog timer interrupt */
66 reg = readl(BRIDGE_CAUSE); 67 reg = readl(BRIDGE_CAUSE);
@@ -68,9 +69,9 @@ static void orion_wdt_enable(void)
68 writel(reg, BRIDGE_CAUSE); 69 writel(reg, BRIDGE_CAUSE);
69 70
70 /* Enable watchdog timer */ 71 /* Enable watchdog timer */
71 reg = readl(TIMER_CTRL); 72 reg = readl(wdt_reg + TIMER_CTRL);
72 reg |= WDT_EN; 73 reg |= WDT_EN;
73 writel(reg, TIMER_CTRL); 74 writel(reg, wdt_reg + TIMER_CTRL);
74 75
75 /* Enable reset on watchdog */ 76 /* Enable reset on watchdog */
76 reg = readl(RSTOUTn_MASK); 77 reg = readl(RSTOUTn_MASK);
@@ -92,9 +93,9 @@ static void orion_wdt_disable(void)
92 writel(reg, RSTOUTn_MASK); 93 writel(reg, RSTOUTn_MASK);
93 94
94 /* Disable watchdog timer */ 95 /* Disable watchdog timer */
95 reg = readl(TIMER_CTRL); 96 reg = readl(wdt_reg + TIMER_CTRL);
96 reg &= ~WDT_EN; 97 reg &= ~WDT_EN;
97 writel(reg, TIMER_CTRL); 98 writel(reg, wdt_reg + TIMER_CTRL);
98 99
99 spin_unlock(&wdt_lock); 100 spin_unlock(&wdt_lock);
100} 101}
@@ -102,7 +103,7 @@ static void orion_wdt_disable(void)
102static int orion_wdt_get_timeleft(int *time_left) 103static int orion_wdt_get_timeleft(int *time_left)
103{ 104{
104 spin_lock(&wdt_lock); 105 spin_lock(&wdt_lock);
105 *time_left = readl(WDT_VAL) / wdt_tclk; 106 *time_left = readl(wdt_reg + WDT_VAL) / wdt_tclk;
106 spin_unlock(&wdt_lock); 107 spin_unlock(&wdt_lock);
107 return 0; 108 return 0;
108} 109}
@@ -236,6 +237,7 @@ static struct miscdevice orion_wdt_miscdev = {
236static int __devinit orion_wdt_probe(struct platform_device *pdev) 237static int __devinit orion_wdt_probe(struct platform_device *pdev)
237{ 238{
238 struct orion_wdt_platform_data *pdata = pdev->dev.platform_data; 239 struct orion_wdt_platform_data *pdata = pdev->dev.platform_data;
240 struct resource *res;
239 int ret; 241 int ret;
240 242
241 if (pdata) { 243 if (pdata) {
@@ -245,6 +247,10 @@ static int __devinit orion_wdt_probe(struct platform_device *pdev)
245 return -ENODEV; 247 return -ENODEV;
246 } 248 }
247 249
250 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
251
252 wdt_reg = ioremap(res->start, resource_size(res));
253
248 if (orion_wdt_miscdev.parent) 254 if (orion_wdt_miscdev.parent)
249 return -EBUSY; 255 return -EBUSY;
250 orion_wdt_miscdev.parent = &pdev->dev; 256 orion_wdt_miscdev.parent = &pdev->dev;