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