aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/plat-orion/common.c7
-rw-r--r--drivers/watchdog/orion_wdt.c24
2 files changed, 21 insertions, 10 deletions
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
index 089899a7db72..74daf5ed1432 100644
--- a/arch/arm/plat-orion/common.c
+++ b/arch/arm/plat-orion/common.c
@@ -21,6 +21,7 @@
21#include <plat/orion_wdt.h> 21#include <plat/orion_wdt.h>
22#include <plat/mv_xor.h> 22#include <plat/mv_xor.h>
23#include <plat/ehci-orion.h> 23#include <plat/ehci-orion.h>
24#include <mach/bridge-regs.h>
24 25
25/* Fill in the resources structure and link it into the platform 26/* Fill in the resources structure and link it into the platform
26 device structure. There is always a memory region, and nearly 27 device structure. There is always a memory region, and nearly
@@ -568,13 +569,17 @@ void __init orion_spi_1_init(unsigned long mapbase,
568 ****************************************************************************/ 569 ****************************************************************************/
569static struct orion_wdt_platform_data orion_wdt_data; 570static struct orion_wdt_platform_data orion_wdt_data;
570 571
572static struct resource orion_wdt_resource =
573 DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28);
574
571static struct platform_device orion_wdt_device = { 575static struct platform_device orion_wdt_device = {
572 .name = "orion_wdt", 576 .name = "orion_wdt",
573 .id = -1, 577 .id = -1,
574 .dev = { 578 .dev = {
575 .platform_data = &orion_wdt_data, 579 .platform_data = &orion_wdt_data,
576 }, 580 },
577 .num_resources = 0, 581 .resource = &orion_wdt_resource,
582 .num_resources = 1,
578}; 583};
579 584
580void __init orion_wdt_init(unsigned long tclk) 585void __init orion_wdt_init(unsigned long tclk)
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;