All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] arm: omap: musb: proper error checking
@ 2010-05-19  9:40 felipe.balbi
  2010-05-19  9:40 ` [PATCH 2/3] arm: omap: let pm code always handle musb pm init felipe.balbi
  2010-05-19  9:40 ` [PATCH 3/3] arm: omap: musb: do not issue SOFTRESET on omap3630 felipe.balbi
  0 siblings, 2 replies; 6+ messages in thread
From: felipe.balbi @ 2010-05-19  9:40 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Linux OMAP Mailing List, Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

We need to clk_put() and iounmap() to fully release
the resources.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 arch/arm/mach-omap2/usb-musb.c |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 116548d..085e22e 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -60,23 +60,34 @@ static void __init usb_musb_pm_init(void)
 
 	dev_set_name(dev, "musb_hdrc");
 	otg_clk = clk_get(dev, "ick");
+	if (IS_ERR(otg_clk)) {
+		printk(KERN_WARNING "%s: Unable to get clock for MUSB.\n",
+				__func__);
+		goto out0;
+	}
 
-	if (otg_clk && clk_enable(otg_clk)) {
+	if (clk_enable(otg_clk)) {
 		printk(KERN_WARNING
 			"%s: Unable to enable clocks for MUSB, "
 			"cannot reset.\n",  __func__);
-	} else {
-		/* Reset OTG controller. After reset, it will be in
-		 * force-idle, force-standby mode. */
-		__raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG);
-
-		while (!(OTG_SYSS_RESETDONE &
-					__raw_readl(otg_base + OTG_SYSSTATUS)))
-			cpu_relax();
+		goto out1;
 	}
 
-	if (otg_clk)
-		clk_disable(otg_clk);
+	/* Reset OTG controller. After reset, it will be in
+	 * force-idle, force-standby mode. */
+	__raw_writel(OTG_SYSC_SOFTRESET, otg_base + OTG_SYSCONFIG);
+
+	while (!(OTG_SYSS_RESETDONE &
+				__raw_readl(otg_base + OTG_SYSSTATUS)))
+		cpu_relax();
+
+	clk_disable(otg_clk);
+
+out1:
+	clk_put(otg_clk);
+
+out0:
+	iounmap(otg_base);
 }
 
 void usb_musb_disable_autoidle(void)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] arm: omap: let pm code always handle musb pm init
  2010-05-19  9:40 [PATCH 1/3] arm: omap: musb: proper error checking felipe.balbi
@ 2010-05-19  9:40 ` felipe.balbi
  2010-05-19 11:24   ` Eduardo Valentin
  2010-05-19  9:40 ` [PATCH 3/3] arm: omap: musb: do not issue SOFTRESET on omap3630 felipe.balbi
  1 sibling, 1 reply; 6+ messages in thread
From: felipe.balbi @ 2010-05-19  9:40 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Linux OMAP Mailing List, Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

musb pm has special needs on omap3430, let pm init
code handle usb_musb_pm_init() so we can always
release all resources after initializing PM.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 arch/arm/mach-omap2/pm34xx.c          |    9 +++------
 arch/arm/mach-omap2/usb-musb.c        |   29 +++++++++--------------------
 arch/arm/plat-omap/include/plat/usb.h |    2 +-
 3 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 48857a4..cec9d8b 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -516,12 +516,6 @@ void omap_sram_idle(void)
 			omap3_prcm_restore_context();
 			omap3_sram_restore_context();
 			omap2_sms_restore_context();
-			/*
-			 * Errata 1.164 fix : OTG autoidle can prevent
-			 * sleep
-			 */
-			if (cpu_is_omap3430())
-				usb_musb_disable_autoidle();
 		}
 		omap_uart_resume_idle(0);
 		omap_uart_resume_idle(1);
@@ -1242,6 +1236,9 @@ static int __init omap3_pm_init(void)
 	pm_dbg_regset_init(2);
 
 	omap3_save_scratchpad_contents();
+
+	/* Errata 1.164 fix : OTG autoidle can prevent sleep */
+	usb_musb_pm_init();
 err1:
 	return ret;
 err2:
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 085e22e..de3e768 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -44,12 +44,12 @@ static struct platform_device dummy_pdev = {
 	},
 };
 
-static void __iomem *otg_base;
-static struct clk *otg_clk;
-
-static void __init usb_musb_pm_init(void)
+void __init usb_musb_pm_init(void)
 {
-	struct device *dev = &dummy_pdev.dev;
+	struct device		*dev = &dummy_pdev.dev;
+	void __iomem		*otg_base;
+	struct clk		*otg_clk;
+	unsigned long		r;
 
 	if (!cpu_is_omap34xx())
 		return;
@@ -81,6 +81,10 @@ static void __init usb_musb_pm_init(void)
 				__raw_readl(otg_base + OTG_SYSSTATUS)))
 		cpu_relax();
 
+	r = __raw_readl(otg_base + OTG_SYSCONFIG);
+	r &= ~(1 << 0);
+	__raw_writel(r, otg_base + OTG_SYSCONFIG);
+
 	clk_disable(otg_clk);
 
 out1:
@@ -90,18 +94,6 @@ out0:
 	iounmap(otg_base);
 }
 
-void usb_musb_disable_autoidle(void)
-{
-	if (otg_clk) {
-		unsigned long reg;
-
-		clk_enable(otg_clk);
-		reg = __raw_readl(otg_base + OTG_SYSCONFIG);
-		__raw_writel(reg & ~1, otg_base + OTG_SYSCONFIG);
-		clk_disable(otg_clk);
-	}
-}
-
 #ifdef CONFIG_USB_MUSB_SOC
 
 static struct resource musb_resources[] = {
@@ -181,13 +173,10 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
 
 	if (platform_device_register(&musb_device) < 0)
 		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
-
-	usb_musb_pm_init();
 }
 
 #else
 void __init usb_musb_init(struct omap_musb_board_data *board_data)
 {
-	usb_musb_pm_init();
 }
 #endif /* CONFIG_USB_MUSB_SOC */
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index ec7c025..cae3508 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -56,7 +56,7 @@ extern void usb_musb_init(struct omap_musb_board_data *board_data);
 extern void usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata);
 
 /* This is needed for OMAP3 errata 1.164: enabled autoidle can prevent sleep */
-extern void usb_musb_disable_autoidle(void);
+extern void usb_musb_pm_init(void);
 
 #endif
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] arm: omap: musb: do not issue SOFTRESET on omap3630
  2010-05-19  9:40 [PATCH 1/3] arm: omap: musb: proper error checking felipe.balbi
  2010-05-19  9:40 ` [PATCH 2/3] arm: omap: let pm code always handle musb pm init felipe.balbi
@ 2010-05-19  9:40 ` felipe.balbi
  2010-05-19 17:26   ` Gadiyar, Anand
  1 sibling, 1 reply; 6+ messages in thread
From: felipe.balbi @ 2010-05-19  9:40 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Linux OMAP Mailing List, Felipe Balbi

From: Felipe Balbi <felipe.balbi@nokia.com>

Errata ID i445 says we SOFTRESET doesn't work properly
on omap3630, so let's avoid issuing that here.

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 arch/arm/mach-omap2/usb-musb.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index de3e768..97dae0d 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -54,6 +54,10 @@ void __init usb_musb_pm_init(void)
 	if (!cpu_is_omap34xx())
 		return;
 
+	/* Errata ID i445 fix : Do not use SOFTRESET with OMAP3630 */
+	if (cpu_is_omap3630())
+		return;
+
 	otg_base = ioremap(OMAP34XX_HSUSB_OTG_BASE, SZ_4K);
 	if (WARN_ON(!otg_base))
 		return;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] arm: omap: let pm code always handle musb pm init
  2010-05-19  9:40 ` [PATCH 2/3] arm: omap: let pm code always handle musb pm init felipe.balbi
@ 2010-05-19 11:24   ` Eduardo Valentin
  2010-05-19 11:43     ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Eduardo Valentin @ 2010-05-19 11:24 UTC (permalink / raw)
  To: Balbi Felipe (Nokia-D/Helsinki); +Cc: Kevin Hilman, Linux OMAP Mailing List

On Wed, May 19, 2010 at 11:40:17AM +0200, Balbi Felipe (Nokia-D/Helsinki) wrote:
> From: Felipe Balbi <felipe.balbi@nokia.com>
> 
> musb pm has special needs on omap3430, let pm init
> code handle usb_musb_pm_init() so we can always
> release all resources after initializing PM.

Right..

> 
> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---
>  arch/arm/mach-omap2/pm34xx.c          |    9 +++------
>  arch/arm/mach-omap2/usb-musb.c        |   29 +++++++++--------------------
>  arch/arm/plat-omap/include/plat/usb.h |    2 +-
>  3 files changed, 13 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
> index 48857a4..cec9d8b 100644
> --- a/arch/arm/mach-omap2/pm34xx.c
> +++ b/arch/arm/mach-omap2/pm34xx.c
> @@ -516,12 +516,6 @@ void omap_sram_idle(void)
>  			omap3_prcm_restore_context();
>  			omap3_sram_restore_context();
>  			omap2_sms_restore_context();
> -			/*
> -			 * Errata 1.164 fix : OTG autoidle can prevent
> -			 * sleep
> -			 */
> -			if (cpu_is_omap3430())
> -				usb_musb_disable_autoidle();

But IIRC, if we are coming back from OFF mode the autoidle bit will be 1 again.
Which means, we still need this part to set it back to 0, otherwise, the sw wa is screwed.


>  		}
>  		omap_uart_resume_idle(0);
>  		omap_uart_resume_idle(1);
> @@ -1242,6 +1236,9 @@ static int __init omap3_pm_init(void)
>  	pm_dbg_regset_init(2);
>  
>  	omap3_save_scratchpad_contents();
> +
> +	/* Errata 1.164 fix : OTG autoidle can prevent sleep */
> +	usb_musb_pm_init();
>  err1:
>  	return ret;
>  err2:
> diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
> index 085e22e..de3e768 100644
> --- a/arch/arm/mach-omap2/usb-musb.c
> +++ b/arch/arm/mach-omap2/usb-musb.c
> @@ -44,12 +44,12 @@ static struct platform_device dummy_pdev = {
>  	},
>  };
>  
> -static void __iomem *otg_base;
> -static struct clk *otg_clk;
> -
> -static void __init usb_musb_pm_init(void)
> +void __init usb_musb_pm_init(void)
>  {
> -	struct device *dev = &dummy_pdev.dev;
> +	struct device		*dev = &dummy_pdev.dev;
> +	void __iomem		*otg_base;
> +	struct clk		*otg_clk;
> +	unsigned long		r;
>  
>  	if (!cpu_is_omap34xx())
>  		return;
> @@ -81,6 +81,10 @@ static void __init usb_musb_pm_init(void)
>  				__raw_readl(otg_base + OTG_SYSSTATUS)))
>  		cpu_relax();
>  
> +	r = __raw_readl(otg_base + OTG_SYSCONFIG);
> +	r &= ~(1 << 0);
> +	__raw_writel(r, otg_base + OTG_SYSCONFIG);
> +
>  	clk_disable(otg_clk);
>  
>  out1:
> @@ -90,18 +94,6 @@ out0:
>  	iounmap(otg_base);
>  }
>  
> -void usb_musb_disable_autoidle(void)
> -{
> -	if (otg_clk) {
> -		unsigned long reg;
> -
> -		clk_enable(otg_clk);
> -		reg = __raw_readl(otg_base + OTG_SYSCONFIG);
> -		__raw_writel(reg & ~1, otg_base + OTG_SYSCONFIG);
> -		clk_disable(otg_clk);
> -	}
> -}
> -
>  #ifdef CONFIG_USB_MUSB_SOC
>  
>  static struct resource musb_resources[] = {
> @@ -181,13 +173,10 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
>  
>  	if (platform_device_register(&musb_device) < 0)
>  		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
> -
> -	usb_musb_pm_init();
>  }
>  
>  #else
>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>  {
> -	usb_musb_pm_init();
>  }
>  #endif /* CONFIG_USB_MUSB_SOC */
> diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
> index ec7c025..cae3508 100644
> --- a/arch/arm/plat-omap/include/plat/usb.h
> +++ b/arch/arm/plat-omap/include/plat/usb.h
> @@ -56,7 +56,7 @@ extern void usb_musb_init(struct omap_musb_board_data *board_data);
>  extern void usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata);
>  
>  /* This is needed for OMAP3 errata 1.164: enabled autoidle can prevent sleep */
> -extern void usb_musb_disable_autoidle(void);
> +extern void usb_musb_pm_init(void);
>  
>  #endif
>  
> -- 
> 1.7.1
> 
> --
> 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] 6+ messages in thread

* Re: [PATCH 2/3] arm: omap: let pm code always handle musb pm init
  2010-05-19 11:24   ` Eduardo Valentin
@ 2010-05-19 11:43     ` Felipe Balbi
  0 siblings, 0 replies; 6+ messages in thread
From: Felipe Balbi @ 2010-05-19 11:43 UTC (permalink / raw)
  To: Valentin Eduardo (Nokia-D/Helsinki)
  Cc: Balbi Felipe (Nokia-D/Helsinki), Kevin Hilman,
	Linux OMAP Mailing List, Tony Lindgren

On Wed, May 19, 2010 at 01:24:31PM +0200, Valentin Eduardo (Nokia-D/Helsinki) wrote:
>But IIRC, if we are coming back from OFF mode the autoidle bit will be 
>1 again.
>Which means, we still need this part to set it back to 0, otherwise, 
>the sw wa is screwed.

ok, I'll put it back here, or we could leave this to be done by the musb 
driver as, ideally, the same are shouldn't be ioremapped twice.

Kevin and Tony, do you have comments ?

-- 
balbi

DefectiveByDesign.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 3/3] arm: omap: musb: do not issue SOFTRESET on omap3630
  2010-05-19  9:40 ` [PATCH 3/3] arm: omap: musb: do not issue SOFTRESET on omap3630 felipe.balbi
@ 2010-05-19 17:26   ` Gadiyar, Anand
  0 siblings, 0 replies; 6+ messages in thread
From: Gadiyar, Anand @ 2010-05-19 17:26 UTC (permalink / raw)
  To: felipe.balbi@nokia.com, Kevin Hilman; +Cc: Linux OMAP Mailing List

felipe.balbi@nokia.com wrote:
> From: Felipe Balbi <felipe.balbi@nokia.com>
> 
> Errata ID i445 says we SOFTRESET doesn't work properly
> on omap3630, so let's avoid issuing that here.
> 

Not really - all it says is that a ULPI reset is not propagated
to the PHY when you softreset the controller.

The controller softreset itself is quite functional.

Also, this is applicable to 3430 as well and is not 3630 specific.

So I'd NAK this patch.


> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---
>  arch/arm/mach-omap2/usb-musb.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
> index de3e768..97dae0d 100644
> --- a/arch/arm/mach-omap2/usb-musb.c
> +++ b/arch/arm/mach-omap2/usb-musb.c
> @@ -54,6 +54,10 @@ void __init usb_musb_pm_init(void)
>  	if (!cpu_is_omap34xx())
>  		return;
>  
> +	/* Errata ID i445 fix : Do not use SOFTRESET with OMAP3630 */
> +	if (cpu_is_omap3630())
> +		return;
> +
>  	otg_base = ioremap(OMAP34XX_HSUSB_OTG_BASE, SZ_4K);
>  	if (WARN_ON(!otg_base))
>  		return;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-19 17:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19  9:40 [PATCH 1/3] arm: omap: musb: proper error checking felipe.balbi
2010-05-19  9:40 ` [PATCH 2/3] arm: omap: let pm code always handle musb pm init felipe.balbi
2010-05-19 11:24   ` Eduardo Valentin
2010-05-19 11:43     ` Felipe Balbi
2010-05-19  9:40 ` [PATCH 3/3] arm: omap: musb: do not issue SOFTRESET on omap3630 felipe.balbi
2010-05-19 17:26   ` Gadiyar, Anand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.