Skip to contentSkip to conversation

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

PATCH Superseded Kevin Hilman 2 participants 3 messages Jun 24, 2009

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 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]>

---
Updates from v2
- reset for OMAP2 as well (needs update for OMAP4, see FIXME)

 arch/arm/mach-omap2/usb-musb.c |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/usb-musb.c +33 -4
index d85296d..1ea2ac7 100644
@@ -26,18 +26,47 @@
 
 #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))
+		return;
+
+	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);
+	iounmap(otg_base);
 }
 
 #ifdef CONFIG_USB_MUSB_SOC
Signature · 1 line
1.6.3.2
#1 lore raw

Kevin

Quoted 7 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kevin Hilman
Sent: Wednesday, June 24, 2009 1:28 PM
To: [email protected]
Subject: [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot

Have some more comments that I should have given before the re-spin v3 !!

Quoted 51 lines

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]>

---
Updates from v2
- reset for OMAP2 as well (needs update for OMAP4, see FIXME)

arch/arm/mach-omap2/usb-musb.c | 37 +++++++++++++++++++++++++++++++++----

1 files changed, 33 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/usb-musb.c +12 -4
index d85296d..1ea2ac7 100644
@@ -26,18 +26,47 @@
 
 #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;

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

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +10 -0
+	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))

Need to iounmap(otg_base); and clk_put() in case of error Goto error;

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

Quoted 9 lines
arch/arm/mach-omap2/usb-musb.c +9 -0
+		return;
+
+	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);

error:

Quoted 12 lines
arch/arm/mach-omap2/usb-musb.c +2 -1
+	clk_put(iclk);
+	iounmap(otg_base);
 }
 
 #ifdef CONFIG_USB_MUSB_SOC
--

1.6.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 10 lines · Vikram

Kevin

Quoted 7 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kevin Hilman
Sent: Wednesday, June 24, 2009 1:28 PM
To: [email protected]
Subject: [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot

Quoted 2 lines

Have some more comments that I should have given before the re-spin v3 !!

sigh, sending these too quickly... thanks for the reviews.

Quoted 56 lines
Quoted 56 lines

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]>

---
Updates from v2
- reset for OMAP2 as well (needs update for OMAP4, see FIXME)

arch/arm/mach-omap2/usb-musb.c | 37 +++++++++++++++++++++++++++++++++----

1 files changed, 33 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/usb-musb.c +17 -4
index d85296d..1ea2ac7 100644
@@ -26,18 +26,47 @@
 
 #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);
Quoted 8 lines

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

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

Need to iounmap(otg_base); and clk_put() in case of error Goto error;

actually just need to iounmap in case clk_get fails.

Quoted 11 lines

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

Quoted 9 lines
arch/arm/mach-omap2/usb-musb.c +9 -0
+		return;
+
+	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);

error:

Quoted 1 line

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

Quoted 1 line
arch/arm/mach-omap2/usb-musb.c +1 -0
+	clk_put(iclk);

and error: should go here.

Quoted 11 lines
Quoted 11 lines
arch/arm/mach-omap2/usb-musb.c +1 -1
+	iounmap(otg_base);
 }
 
 #ifdef CONFIG_USB_MUSB_SOC
--

1.6.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html