Skip to contentSkip to conversation

OMAP2/3/4: PM: reset USB OTG module on boot

PATCH Superseded Kevin Hilman 1 participant 2 messages Jun 24, 2009

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 OMAP2/3/4: PM: reset USB OTG module on boot

Rather than simply setting force-idle mode on boot, do a reset of the OTG module. This really ensures that any bootloader/bootstrap code that leaves it active will not prevent future retention. After reset, OTG module will be in force-idle, force-standby mode.

In addition, ensure that the iclk is enabled before attempting a write to the module SYSCONFIG register.

Problem reported by Mike Chan <[email protected]>

---
 arch/arm/mach-omap2/usb-musb.c |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/usb-musb.c +34 -4
index d85296d..3abbe5a 100644
@@ -26,18 +26,48 @@
 
 #include <linux/usb/musb.h>
 
+#include <asm/sizes.h>
+
 #include <mach/hardware.h>
 #include <mach/irqs.h>
 #include <mach/mux.h>
 #include <mach/usb.h>
 
-#define OTG_SYSCONFIG	(OMAP34XX_HSUSB_OTG_BASE + 0x404)
+#define OTG_SYSCONFIG	   0x404
+#define OTG_SYSC_SOFTRESET BIT(1)
 
 static void __init usb_musb_pm_init(void)
 {
-	/* Ensure force-idle mode for OTG controller */
-	if (cpu_is_omap34xx())
-		omap_writel(0, OTG_SYSCONFIG);
+	struct clk *iclk;
+	u32 phys_base;
+	void __iomem *otg_base;
+
+	if (cpu_is_omap243x())
+		phys_base = OMAP2_OTG_BASE;
+	else if (cpu_is_omap34xx())
+		phys_base = OMAP34XX_HSUSB_OTG_BASE;
+	else
+		/* FIXME: add OMAP4 support */
+		return;
+
+	otg_base = ioremap(phys_base, SZ_4K);
+	if (WARN_ON(!otg_base))
+		return;
+
+	iclk = clk_get(NULL, "hsotgusb_ick");
+	if (WARN_ON(!iclk))
+		goto out;
+
+	clk_enable(iclk);
+
+	/* Reset OTG controller.  After reset, it will be in
+	 * force-idle, force-standby mode. */
+	__raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG);
+
+	clk_disable(iclk);
+	clk_put(iclk);
+out:
+	iounmap(otg_base);
 }
 
 #ifdef CONFIG_USB_MUSB_SOC
Signature · 1 line
1.6.3.2
#1 lore raw

Kevin Hilman <[email protected]> writes:

[...]

arch/arm/mach-omap2/usb-musb.c line 59

Quoted 3 lines
arch/arm/mach-omap2/usb-musb.c +3 -0
+	iclk = clk_get(NULL, "hsotgusb_ick");
+	if (WARN_ON(!iclk))
+		goto out;

doh, this error check is wrong and will never fail. Need to use IS_ERR(). v5 spinning up...

Kevin