diff mbox

omap: wd_timer: Fix crash frm wdt_probe when !CONFIG_RUNTIME_PM

Message ID f0b57f3b0e11566d8c1864d3388ce5e6@mail.gmail.com (mailing list archive)
State Deferred
Delegated to: Paul Walmsley
Headers show

Commit Message

R Sricharan Feb. 24, 2011, 4:13 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 657f3c8..2641d73 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -382,24 +382,6 @@  void __init omap2_init_common_infrastructure(void)
 #endif
 	omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state);

-	/*
-	 * Set the default postsetup state for unusual modules (like
-	 * MPU WDT).
-	 *
-	 * The postsetup_state is not actually used until
-	 * omap_hwmod_late_init(), so boards that desire full watchdog
-	 * coverage of kernel initialization can reprogram the
-	 * postsetup_state between the calls to
-	 * omap2_init_common_infra() and omap2_init_common_devices().
-	 *
-	 * XXX ideally we could detect whether the MPU WDT was currently
-	 * enabled here and make this conditional
-	 */
-	postsetup_state = _HWMOD_STATE_DISABLED;
-	omap_hwmod_for_each_by_class("wd_timer",
-				     _set_hwmod_postsetup_state,
-				     &postsetup_state);
-
 	omap_pm_if_early_init();

 	if (cpu_is_omap2420())
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 879f55f..d665ee5 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -545,7 +545,8 @@  static struct omap_hwmod_class_sysconfig i2c_sysc = {
 static struct omap_hwmod_class omap3xxx_wd_timer_hwmod_class = {
 	.name		= "wd_timer",
 	.sysc		= &omap3xxx_wd_timer_sysc,
-	.pre_shutdown	= &omap2_wd_timer_disable
+	.pre_shutdown	= &omap2_wd_timer_disable,
+	.reset		= &omap2_wd_timer_reset
 };

 /* wd_timer2 */
diff --git a/arch/arm/mach-omap2/wd_timer.c
b/arch/arm/mach-omap2/wd_timer.c
index 4067669..e11c5f3 100644
--- a/arch/arm/mach-omap2/wd_timer.c
+++ b/arch/arm/mach-omap2/wd_timer.c
@@ -24,7 +24,8 @@ 
  */
 #define OMAP_WDT_WPS		0x34
 #define OMAP_WDT_SPR		0x48
-
+#define OMAP_WDT_DSC		0x10
+#define OMAP_WDT_DST		0x14

 int omap2_wd_timer_disable(struct omap_hwmod *oh)
 {
@@ -54,3 +55,32 @@  int omap2_wd_timer_disable(struct omap_hwmod *oh)
 	return 0;
 }

+int omap2_wd_timer_reset(struct omap_hwmod *oh)
+{
+	void __iomem *base;
+	pr_err("\n\n\n\n\n\n\n\n\n omap2_wd_timer_reset \n\n\n\n\n");
+
+	if (!oh) {
+		pr_err("%s: could not look up wdtimer_hwmod\n",__func__);
+	}
+
+	base = omap_hwmod_get_mpu_rt_va(oh);
+	if(!base) {
+		pr_err("%s: Could not get the base address for %s\n",
+				oh->name, __func__);
+		return -EINVAL;
+	}
+
+	/* soft reset on watch dog timer */
+	__raw_writel(0x02, base + OMAP_WDT_DSC);
+	while (__raw_readl(base + OMAP_WDT_DST) & 0x1)
+		cpu_relax();
+
+#ifdef CONFIG_OMAP_WATCHDOG
+	/* Disable the watchdog */
+	omap2_wd_timer_disable(oh);
+#endif
+
+	return 0;
+}
+
diff --git a/arch/arm/mach-omap2/wd_timer.h
b/arch/arm/mach-omap2/wd_timer.h
index e0054a2..f6bbba7 100644
--- a/arch/arm/mach-omap2/wd_timer.h
+++ b/arch/arm/mach-omap2/wd_timer.h
@@ -13,5 +13,6 @@ 
 #include <plat/omap_hwmod.h>

 extern int omap2_wd_timer_disable(struct omap_hwmod *oh);
+extern int omap2_wd_timer_reset(struct omap_hwmod *oh);