@@ -41,6 +41,7 @@
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/platform_data/omap-wd-timer.h>
+#include <linux/delay.h>
#include "omap_wdt.h"
@@ -81,6 +82,31 @@ static void omap_wdt_reload(struct omap_wdt_dev *wdev)
static int omap_wdt_is_running(struct omap_wdt_dev *wdev)
{
void __iomem *base = wdev->base;
+ unsigned long cntrl, counter1, counter2, shift;
+ /*
+ * There is no register that tells us if the timer is running,
+ * so we have to resort to sample twice. Use shortest delay
+ * depending on the actual prescaling value.
+ *
+ * Note! If bootloader configured a very large prescaler
+ * value, we might delay up to 4ms here. If that happens, you
+ * are better to fix your bootloader anyway!
+ */
+
+ /*
+ cntrl = readl_relaxed(base + OMAP_WATCHDOG_CNTRL);
+ if (cntrl & (1 << 5))
+ shift = (cntrl >> 2) & 0x7;
+ else
+ shift = 0;
+ */
+
+ counter1 = readl_relaxed(base + OMAP_WATCHDOG_CRR);
+ /*udelay(31 << shift);*/
+ msleep(4);
+ counter2 = readl_relaxed(base + OMAP_WATCHDOG_CRR);
+
+ return counter1 != counter2;
return readl_relaxed(base + OMAP_WATCHDOG_SPR) == 0x4444;
}