History

ARM: 6126/1: ARM mpcore_wdt: fix build failure and other fixes

This fixes the build failures seen when building mpcore_wdt and it also removes the nonexistent ARM_MPCORE_PLATFORM dependency, instead make it dependent on HAVE_ARM_TWD. Also this fixes spinlock usage appropriately.

Srinidhi Kasagar committed 16 years ago

Commit 98af0571 parent f4a27ae2 files · +12 −11Browse files

Unified · Split

2 files
  1. drivers/watchdog/Kconfig +1 −1
  2. drivers/watchdog/mpcore_wdt.c +11 −10
drivers/watchdog/Kconfig+1−1
@@ -175,7 +175,7 @@ config SA1100_WATCHDOG · 174 unmodified lines
175 175
176config MPCORE_WATCHDOG176config MPCORE_WATCHDOG
177 tristate "MPcore watchdog"177 tristate "MPcore watchdog"
178 depends on ARM_MPCORE_PLATFORM && LOCAL_TIMERS178 depends on HAVE_ARM_TWD
179 help179 help
180 Watchdog timer embedded into the MPcore system.180 Watchdog timer embedded into the MPcore system.
181 181
drivers/watchdog/mpcore_wdt.c+11−10
@@ -31,8 +31,9 @@ · 30 unmodified lines
31#include <linux/platform_device.h>31#include <linux/platform_device.h>
32#include <linux/uaccess.h>32#include <linux/uaccess.h>
33#include <linux/slab.h>33#include <linux/slab.h>
34#include <linux/io.h>
34 35
35#include <asm/hardware/arm_twd.h>36#include <asm/smp_twd.h>
36 37
37struct mpcore_wdt {38struct mpcore_wdt {
38 unsigned long timer_alive;39 unsigned long timer_alive;
@@ -44,7 +45,7 @@ struct mpcore_wdt { · 5 unmodified lines
44};45};
45 46
46static struct platform_device *mpcore_wdt_dev;47static struct platform_device *mpcore_wdt_dev;
47extern unsigned int mpcore_timer_rate;48static DEFINE_SPINLOCK(wdt_lock);
48 49
49#define TIMER_MARGIN 6050#define TIMER_MARGIN 60
50static int mpcore_margin = TIMER_MARGIN;51static int mpcore_margin = TIMER_MARGIN;
@@ -94,13 +95,15 @@ static irqreturn_t mpcore_wdt_fire(int irq, void *arg) · 43 unmodified lines
94 */95 */
95static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt)96static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt)
96{97{
97 unsigned int count;98 unsigned long count;
98 99
100 spin_lock(&wdt_lock);
99 /* Assume prescale is set to 256 */101 /* Assume prescale is set to 256 */
100 count = (mpcore_timer_rate / 256) * mpcore_margin;102 count = __raw_readl(wdt->base + TWD_WDOG_COUNTER);
103 count = (0xFFFFFFFFU - count) * (HZ / 5);
104 count = (count / 256) * mpcore_margin;
101 105
102 /* Reload the counter */106 /* Reload the counter */
103 spin_lock(&wdt_lock);
104 writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);107 writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);
105 wdt->perturb = wdt->perturb ? 0 : 1;108 wdt->perturb = wdt->perturb ? 0 : 1;
106 spin_unlock(&wdt_lock);109 spin_unlock(&wdt_lock);
@@ -119,7 +122,6 @@ static void mpcore_wdt_start(struct mpcore_wdt *wdt) · 12 unmodified lines
119{122{
120 dev_printk(KERN_INFO, wdt->dev, "enabling watchdog.\n");123 dev_printk(KERN_INFO, wdt->dev, "enabling watchdog.\n");
121 124
122 spin_lock(&wdt_lock);
123 /* This loads the count register but does NOT start the count yet */125 /* This loads the count register but does NOT start the count yet */
124 mpcore_wdt_keepalive(wdt);126 mpcore_wdt_keepalive(wdt);
125 127
@@ -130,7 +132,6 @@ static void mpcore_wdt_start(struct mpcore_wdt *wdt) · 4 unmodified lines
130 /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */132 /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */
131 writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL);133 writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL);
132 }134 }
133 spin_unlock(&wdt_lock);
134}135}
135 136
136static int mpcore_wdt_set_heartbeat(int t)137static int mpcore_wdt_set_heartbeat(int t)
@@ -360,7 +361,7 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev) · 223 unmodified lines
360 mpcore_wdt_miscdev.parent = &dev->dev;361 mpcore_wdt_miscdev.parent = &dev->dev;
361 ret = misc_register(&mpcore_wdt_miscdev);362 ret = misc_register(&mpcore_wdt_miscdev);
362 if (ret) {363 if (ret) {
363 dev_printk(KERN_ERR, _dev,364 dev_printk(KERN_ERR, wdt->dev,
364 "cannot register miscdev on minor=%d (err=%d)\n",365 "cannot register miscdev on minor=%d (err=%d)\n",
365 WATCHDOG_MINOR, ret);366 WATCHDOG_MINOR, ret);
366 goto err_misc;367 goto err_misc;
@@ -369,13 +370,13 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev) · 2 unmodified lines
369 ret = request_irq(wdt->irq, mpcore_wdt_fire, IRQF_DISABLED,370 ret = request_irq(wdt->irq, mpcore_wdt_fire, IRQF_DISABLED,
370 "mpcore_wdt", wdt);371 "mpcore_wdt", wdt);
371 if (ret) {372 if (ret) {
372 dev_printk(KERN_ERR, _dev,373 dev_printk(KERN_ERR, wdt->dev,
373 "cannot register IRQ%d for watchdog\n", wdt->irq);374 "cannot register IRQ%d for watchdog\n", wdt->irq);
374 goto err_irq;375 goto err_irq;
375 }376 }
376 377
377 mpcore_wdt_stop(wdt);378 mpcore_wdt_stop(wdt);
378 platform_set_drvdata(&dev->dev, wdt);379 platform_set_drvdata(dev, wdt);
379 mpcore_wdt_dev = dev;380 mpcore_wdt_dev = dev;
380 381
381 return 0;382 return 0;