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
175175
176176 config MPCORE_WATCHDOG
177177 tristate "MPcore watchdog"
178− depends on ARM_MPCORE_PLATFORM && LOCAL_TIMERS
178+ depends on HAVE_ARM_TWD
179179 help
180180 Watchdog timer embedded into the MPcore system.
181181
drivers/watchdog/mpcore_wdt.c+11−10
@@ -31,8 +31,9 @@ · 30 unmodified lines
3131 #include <linux/platform_device.h>
3232 #include <linux/uaccess.h>
3333 #include <linux/slab.h>
34+#include <linux/io.h>
3435
35−#include <asm/hardware/arm_twd.h>
36+#include <asm/smp_twd.h>
3637
3738 struct mpcore_wdt {
3839 unsigned long timer_alive;
@@ -44,7 +45,7 @@ struct mpcore_wdt { · 5 unmodified lines
4445 };
4546
4647 static struct platform_device *mpcore_wdt_dev;
47−extern unsigned int mpcore_timer_rate;
48+static DEFINE_SPINLOCK(wdt_lock);
4849
4950 #define TIMER_MARGIN 60
5051 static int mpcore_margin = TIMER_MARGIN;
@@ -94,13 +95,15 @@ static irqreturn_t mpcore_wdt_fire(int irq, void *arg) · 43 unmodified lines
9495 */
9596 static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt)
9697 {
97− unsigned int count;
98+ unsigned long count;
9899
100+ spin_lock(&wdt_lock);
99101 /* 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;
101105
102106 /* Reload the counter */
103− spin_lock(&wdt_lock);
104107 writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);
105108 wdt->perturb = wdt->perturb ? 0 : 1;
106109 spin_unlock(&wdt_lock);
@@ -119,7 +122,6 @@ static void mpcore_wdt_start(struct mpcore_wdt *wdt) · 12 unmodified lines
119122 {
120123 dev_printk(KERN_INFO, wdt->dev, "enabling watchdog.\n");
121124
122− spin_lock(&wdt_lock);
123125 /* This loads the count register but does NOT start the count yet */
124126 mpcore_wdt_keepalive(wdt);
125127
@@ -130,7 +132,6 @@ static void mpcore_wdt_start(struct mpcore_wdt *wdt) · 4 unmodified lines
130132 /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */
131133 writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL);
132134 }
133− spin_unlock(&wdt_lock);
134135 }
135136
136137 static int mpcore_wdt_set_heartbeat(int t)
@@ -360,7 +361,7 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev) · 223 unmodified lines
360361 mpcore_wdt_miscdev.parent = &dev->dev;
361362 ret = misc_register(&mpcore_wdt_miscdev);
362363 if (ret) {
363− dev_printk(KERN_ERR, _dev,
364+ dev_printk(KERN_ERR, wdt->dev,
364365 "cannot register miscdev on minor=%d (err=%d)\n",
365366 WATCHDOG_MINOR, ret);
366367 goto err_misc;
@@ -369,13 +370,13 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev) · 2 unmodified lines
369370 ret = request_irq(wdt->irq, mpcore_wdt_fire, IRQF_DISABLED,
370371 "mpcore_wdt", wdt);
371372 if (ret) {
372− dev_printk(KERN_ERR, _dev,
373+ dev_printk(KERN_ERR, wdt->dev,
373374 "cannot register IRQ%d for watchdog\n", wdt->irq);
374375 goto err_irq;
375376 }
376377
377378 mpcore_wdt_stop(wdt);
378− platform_set_drvdata(&dev->dev, wdt);
379+ platform_set_drvdata(dev, wdt);
379380 mpcore_wdt_dev = dev;
380381
381382 return 0;