* [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot
@ 2009-06-24 18:27 Kevin Hilman
2009-06-24 19:12 ` Pandita, Vikram
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hilman @ 2009-06-24 18:27 UTC (permalink / raw)
To: linux-omap
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 <mikechan@google.com>
Tested-by: Mike Chan <mikechan@google.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
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(-)
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index d85296d..1ea2ac7 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -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
--
1.6.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot
2009-06-24 18:27 [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot Kevin Hilman
@ 2009-06-24 19:12 ` Pandita, Vikram
2009-06-24 21:08 ` Kevin Hilman
0 siblings, 1 reply; 3+ messages in thread
From: Pandita, Vikram @ 2009-06-24 19:12 UTC (permalink / raw)
To: Kevin Hilman, linux-omap@vger.kernel.org
Kevin
>-----Original Message-----
>From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Kevin
>Hilman
>Sent: Wednesday, June 24, 2009 1:28 PM
>To: linux-omap@vger.kernel.org
>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 !!
>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 <mikechan@google.com>
>
>Tested-by: Mike Chan <mikechan@google.com>
>Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
>---
>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(-)
>
>diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
>index d85296d..1ea2ac7 100644
>--- a/arch/arm/mach-omap2/usb-musb.c
>+++ b/arch/arm/mach-omap2/usb-musb.c
>@@ -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))
Need to iounmap(otg_base); and clk_put() in case of error
Goto error;
>+ 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:
>+ 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 majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot
2009-06-24 19:12 ` Pandita, Vikram
@ 2009-06-24 21:08 ` Kevin Hilman
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Hilman @ 2009-06-24 21:08 UTC (permalink / raw)
To: Pandita, Vikram; +Cc: linux-omap@vger.kernel.org
"Pandita, Vikram" <vikram.pandita@ti.com> writes:
> Kevin
>
>>-----Original Message-----
>>From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Kevin
>>Hilman
>>Sent: Wednesday, June 24, 2009 1:28 PM
>>To: linux-omap@vger.kernel.org
>>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 !!
>
sigh, sending these too quickly... thanks for the reviews.
>>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 <mikechan@google.com>
>>
>>Tested-by: Mike Chan <mikechan@google.com>
>>Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
>>---
>>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(-)
>>
>>diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
>>index d85296d..1ea2ac7 100644
>>--- a/arch/arm/mach-omap2/usb-musb.c
>>+++ b/arch/arm/mach-omap2/usb-musb.c
>>@@ -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))
>
> Need to iounmap(otg_base); and clk_put() in case of error
> Goto error;
actually just need to iounmap in case clk_get fails.
>>+ 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:
>>+ clk_put(iclk);
and error: should go here.
>>+ 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 majordomo@vger.kernel.org
>>More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-24 21:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-24 18:27 [PATCH v3] OMAP2/3/4: PM: reset USB OTG module on boot Kevin Hilman
2009-06-24 19:12 ` Pandita, Vikram
2009-06-24 21:08 ` Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox