diff options
Diffstat (limited to 'drivers/watchdog/orion_wdt.c')
-rw-r--r-- | drivers/watchdog/orion_wdt.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index 4ad78f868515..788aa158e78c 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * warranty of any kind, whether express or implied. | 10 | * warranty of any kind, whether express or implied. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/module.h> | 15 | #include <linux/module.h> |
14 | #include <linux/moduleparam.h> | 16 | #include <linux/moduleparam.h> |
15 | #include <linux/types.h> | 17 | #include <linux/types.h> |
@@ -28,18 +30,19 @@ | |||
28 | /* | 30 | /* |
29 | * Watchdog timer block registers. | 31 | * Watchdog timer block registers. |
30 | */ | 32 | */ |
31 | #define TIMER_CTRL (TIMER_VIRT_BASE + 0x0000) | 33 | #define TIMER_CTRL 0x0000 |
32 | #define WDT_EN 0x0010 | 34 | #define WDT_EN 0x0010 |
33 | #define WDT_VAL (TIMER_VIRT_BASE + 0x0024) | 35 | #define WDT_VAL 0x0024 |
34 | 36 | ||
35 | #define WDT_MAX_CYCLE_COUNT 0xffffffff | 37 | #define WDT_MAX_CYCLE_COUNT 0xffffffff |
36 | #define WDT_IN_USE 0 | 38 | #define WDT_IN_USE 0 |
37 | #define WDT_OK_TO_CLOSE 1 | 39 | #define WDT_OK_TO_CLOSE 1 |
38 | 40 | ||
39 | static int nowayout = WATCHDOG_NOWAYOUT; | 41 | static bool nowayout = WATCHDOG_NOWAYOUT; |
40 | static int heartbeat = -1; /* module parameter (seconds) */ | 42 | static int heartbeat = -1; /* module parameter (seconds) */ |
41 | static unsigned int wdt_max_duration; /* (seconds) */ | 43 | static unsigned int wdt_max_duration; /* (seconds) */ |
42 | static unsigned int wdt_tclk; | 44 | static unsigned int wdt_tclk; |
45 | static void __iomem *wdt_reg; | ||
43 | static unsigned long wdt_status; | 46 | static unsigned long wdt_status; |
44 | static DEFINE_SPINLOCK(wdt_lock); | 47 | static DEFINE_SPINLOCK(wdt_lock); |
45 | 48 | ||
@@ -48,7 +51,7 @@ static void orion_wdt_ping(void) | |||
48 | spin_lock(&wdt_lock); | 51 | spin_lock(&wdt_lock); |
49 | 52 | ||
50 | /* Reload watchdog duration */ | 53 | /* Reload watchdog duration */ |
51 | writel(wdt_tclk * heartbeat, WDT_VAL); | 54 | writel(wdt_tclk * heartbeat, wdt_reg + WDT_VAL); |
52 | 55 | ||
53 | spin_unlock(&wdt_lock); | 56 | spin_unlock(&wdt_lock); |
54 | } | 57 | } |
@@ -60,7 +63,7 @@ static void orion_wdt_enable(void) | |||
60 | spin_lock(&wdt_lock); | 63 | spin_lock(&wdt_lock); |
61 | 64 | ||
62 | /* Set watchdog duration */ | 65 | /* Set watchdog duration */ |
63 | writel(wdt_tclk * heartbeat, WDT_VAL); | 66 | writel(wdt_tclk * heartbeat, wdt_reg + WDT_VAL); |
64 | 67 | ||
65 | /* Clear watchdog timer interrupt */ | 68 | /* Clear watchdog timer interrupt */ |
66 | reg = readl(BRIDGE_CAUSE); | 69 | reg = readl(BRIDGE_CAUSE); |
@@ -68,9 +71,9 @@ static void orion_wdt_enable(void) | |||
68 | writel(reg, BRIDGE_CAUSE); | 71 | writel(reg, BRIDGE_CAUSE); |
69 | 72 | ||
70 | /* Enable watchdog timer */ | 73 | /* Enable watchdog timer */ |
71 | reg = readl(TIMER_CTRL); | 74 | reg = readl(wdt_reg + TIMER_CTRL); |
72 | reg |= WDT_EN; | 75 | reg |= WDT_EN; |
73 | writel(reg, TIMER_CTRL); | 76 | writel(reg, wdt_reg + TIMER_CTRL); |
74 | 77 | ||
75 | /* Enable reset on watchdog */ | 78 | /* Enable reset on watchdog */ |
76 | reg = readl(RSTOUTn_MASK); | 79 | reg = readl(RSTOUTn_MASK); |
@@ -92,9 +95,9 @@ static void orion_wdt_disable(void) | |||
92 | writel(reg, RSTOUTn_MASK); | 95 | writel(reg, RSTOUTn_MASK); |
93 | 96 | ||
94 | /* Disable watchdog timer */ | 97 | /* Disable watchdog timer */ |
95 | reg = readl(TIMER_CTRL); | 98 | reg = readl(wdt_reg + TIMER_CTRL); |
96 | reg &= ~WDT_EN; | 99 | reg &= ~WDT_EN; |
97 | writel(reg, TIMER_CTRL); | 100 | writel(reg, wdt_reg + TIMER_CTRL); |
98 | 101 | ||
99 | spin_unlock(&wdt_lock); | 102 | spin_unlock(&wdt_lock); |
100 | } | 103 | } |
@@ -102,7 +105,7 @@ static void orion_wdt_disable(void) | |||
102 | static int orion_wdt_get_timeleft(int *time_left) | 105 | static int orion_wdt_get_timeleft(int *time_left) |
103 | { | 106 | { |
104 | spin_lock(&wdt_lock); | 107 | spin_lock(&wdt_lock); |
105 | *time_left = readl(WDT_VAL) / wdt_tclk; | 108 | *time_left = readl(wdt_reg + WDT_VAL) / wdt_tclk; |
106 | spin_unlock(&wdt_lock); | 109 | spin_unlock(&wdt_lock); |
107 | return 0; | 110 | return 0; |
108 | } | 111 | } |
@@ -209,8 +212,7 @@ static int orion_wdt_release(struct inode *inode, struct file *file) | |||
209 | if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) | 212 | if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) |
210 | orion_wdt_disable(); | 213 | orion_wdt_disable(); |
211 | else | 214 | else |
212 | printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " | 215 | pr_crit("Device closed unexpectedly - timer will not stop\n"); |
213 | "timer will not stop\n"); | ||
214 | clear_bit(WDT_IN_USE, &wdt_status); | 216 | clear_bit(WDT_IN_USE, &wdt_status); |
215 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | 217 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); |
216 | 218 | ||
@@ -236,15 +238,20 @@ static struct miscdevice orion_wdt_miscdev = { | |||
236 | static int __devinit orion_wdt_probe(struct platform_device *pdev) | 238 | static int __devinit orion_wdt_probe(struct platform_device *pdev) |
237 | { | 239 | { |
238 | struct orion_wdt_platform_data *pdata = pdev->dev.platform_data; | 240 | struct orion_wdt_platform_data *pdata = pdev->dev.platform_data; |
241 | struct resource *res; | ||
239 | int ret; | 242 | int ret; |
240 | 243 | ||
241 | if (pdata) { | 244 | if (pdata) { |
242 | wdt_tclk = pdata->tclk; | 245 | wdt_tclk = pdata->tclk; |
243 | } else { | 246 | } else { |
244 | printk(KERN_ERR "Orion Watchdog misses platform data\n"); | 247 | pr_err("misses platform data\n"); |
245 | return -ENODEV; | 248 | return -ENODEV; |
246 | } | 249 | } |
247 | 250 | ||
251 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
252 | |||
253 | wdt_reg = ioremap(res->start, resource_size(res)); | ||
254 | |||
248 | if (orion_wdt_miscdev.parent) | 255 | if (orion_wdt_miscdev.parent) |
249 | return -EBUSY; | 256 | return -EBUSY; |
250 | orion_wdt_miscdev.parent = &pdev->dev; | 257 | orion_wdt_miscdev.parent = &pdev->dev; |
@@ -257,8 +264,8 @@ static int __devinit orion_wdt_probe(struct platform_device *pdev) | |||
257 | if (ret) | 264 | if (ret) |
258 | return ret; | 265 | return ret; |
259 | 266 | ||
260 | printk(KERN_INFO "Orion Watchdog Timer: Initial timeout %d sec%s\n", | 267 | pr_info("Initial timeout %d sec%s\n", |
261 | heartbeat, nowayout ? ", nowayout" : ""); | 268 | heartbeat, nowayout ? ", nowayout" : ""); |
262 | return 0; | 269 | return 0; |
263 | } | 270 | } |
264 | 271 | ||
@@ -302,7 +309,7 @@ MODULE_DESCRIPTION("Orion Processor Watchdog"); | |||
302 | module_param(heartbeat, int, 0); | 309 | module_param(heartbeat, int, 0); |
303 | MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); | 310 | MODULE_PARM_DESC(heartbeat, "Initial watchdog heartbeat in seconds"); |
304 | 311 | ||
305 | module_param(nowayout, int, 0); | 312 | module_param(nowayout, bool, 0); |
306 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 313 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
307 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 314 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
308 | 315 | ||