summaryrefslogtreecommitdiffstats
path: root/target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch
diff options
context:
space:
mode:
authorkaloz <kaloz@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-02-11 15:58:14 +0000
committerkaloz <kaloz@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-02-11 15:58:14 +0000
commit63815e7b5d6aecfc4743f7a83a178bdeb3a79f58 (patch)
treee99a60326b860fa3c0dbccbdb114a99865ed4127 /target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch
parent3613a733563440815eaf2b5b7b0b1b30f56f403f (diff)
[cns3xxx]: rename 2.6.39 patches directory
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@30453 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch')
-rw-r--r--target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch b/target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch
new file mode 100644
index 000000000..85a73ab1d
--- /dev/null
+++ b/target/linux/cns3xxx/patches-2.6.39/053-cns3xxx_wdt.patch
@@ -0,0 +1,77 @@
+--- a/drivers/watchdog/Kconfig
++++ b/drivers/watchdog/Kconfig
+@@ -188,7 +188,7 @@ config SA1100_WATCHDOG
+
+ config MPCORE_WATCHDOG
+ tristate "MPcore watchdog"
+- depends on HAVE_ARM_TWD
++ depends on ARCH_CNS3XXX
+ help
+ Watchdog timer embedded into the MPcore system.
+
+--- a/drivers/watchdog/mpcore_wdt.c
++++ b/drivers/watchdog/mpcore_wdt.c
+@@ -32,11 +32,14 @@
+ #include <linux/uaccess.h>
+ #include <linux/slab.h>
+ #include <linux/io.h>
++#include <linux/jiffies.h>
++#include <linux/delay.h>
+
+ #include <asm/smp_twd.h>
+
+ struct mpcore_wdt {
+ unsigned long timer_alive;
++ unsigned long timer_rate;
+ struct device *dev;
+ void __iomem *base;
+ int irq;
+@@ -98,14 +101,12 @@ static void mpcore_wdt_keepalive(struct
+ unsigned long count;
+
+ spin_lock(&wdt_lock);
+- /* Assume prescale is set to 256 */
+- count = __raw_readl(wdt->base + TWD_WDOG_COUNTER);
+- count = (0xFFFFFFFFU - count) * (HZ / 5);
+- count = (count / 256) * mpcore_margin;
++ count = (wdt->timer_rate / 256) * mpcore_margin;
+
+ /* Reload the counter */
+ writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD);
+ wdt->perturb = wdt->perturb ? 0 : 1;
++
+ spin_unlock(&wdt_lock);
+ }
+
+@@ -329,6 +330,8 @@ static int __devinit mpcore_wdt_probe(st
+ struct mpcore_wdt *wdt;
+ struct resource *res;
+ int ret;
++ unsigned long count;
++ u64 waitjiffies;
+
+ /* We only accept one device, and it must have an id of -1 */
+ if (dev->id != -1)
+@@ -375,6 +378,22 @@ static int __devinit mpcore_wdt_probe(st
+ goto err_irq;
+ }
+
++ waitjiffies = get_jiffies_64() + 1;
++ while (get_jiffies_64() < waitjiffies)
++ udelay(10);
++
++ waitjiffies += 5;
++
++ __raw_writel(0x00000001, wdt->base + TWD_WDOG_CONTROL);
++ __raw_writel(0xFFFFFFFFU, wdt->base + TWD_WDOG_LOAD);
++
++ while (get_jiffies_64() < waitjiffies)
++ udelay(10);
++
++ count = __raw_readl(wdt->base + TWD_WDOG_COUNTER);
++
++ wdt->timer_rate = (0xFFFFFFFFU - count) * (HZ / 5);
++
+ mpcore_wdt_stop(wdt);
+ platform_set_drvdata(dev, wdt);
+ mpcore_wdt_dev = dev;