All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 6/8] usb: musb: Offmode fix for idle path
@ 2010-08-06 17:27 Hema HK
  2010-08-07  2:24 ` Bob Liu
       [not found] ` <1281115624-1174-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Hema HK @ 2010-08-06 17:27 UTC (permalink / raw)
  To: linux-usb, linux-omap
  Cc: Hema HK, Maulik Mankad, Felipe Balbi, Tony Lindgren, Kevin Hilman

From: Hema HK  <hemahk@ti.com>

With OMAP core-off support musb was not functional as context was getting
lost after wakeup from core-off. And also musb was blocking the core-off 
after loading the gadget driver even with no cable connected sometimes.

Added the conext save/restore api in the platform layer which will
be called in the idle and wakeup path.

Changed the usb sysconfig settings as per the usbotg functional spec.
When the device is not active, configure to force idle and force standby mode.
When it is being used, configure in smart standby and smart idle mode.
So while attempting to coreoff the usb is configured to force standby and 
force idle mode, after wakeup configured in smart idle and smart standby.

Signed-off-by: Hema HK <hemahk@ti.com>
Signed-off-by: Maulik Mankad <x0082077@ti.com>

Cc: Felipe Balbi <felipe.balbi@nokia.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
---

 arch/arm/mach-omap2/pm34xx.c          |    4 ++
 arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
 arch/arm/plat-omap/include/plat/usb.h |    2 +
 drivers/usb/musb/musb_core.c          |   11 -------
 drivers/usb/musb/omap2430.c           |   48 +++++++++++++++++++++++++++++++---
 5 files changed, 71 insertions(+), 15 deletions(-)

Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
===================================================================
--- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c	2010-08-06 09:23:01.153862710 -0400
+++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c	2010-08-06 10:44:06.393863125 -0400
@@ -39,6 +39,7 @@
 #include <plat/gpmc.h>
 #include <plat/dma.h>
 #include <plat/dmtimer.h>
+#include <plat/usb.h>
 
 #include <asm/tlbflush.h>
 
@@ -416,6 +417,8 @@
 		if (core_next_state == PWRDM_POWER_OFF) {
 			omap3_core_save_context();
 			omap3_prcm_save_context();
+			/* Save MUSB context */
+			musb_context_save_restore(1);
 		}
 	}
 
@@ -458,6 +461,8 @@
 			omap3_prcm_restore_context();
 			omap3_sram_restore_context();
 			omap2_sms_restore_context();
+			/* restore MUSB context */
+			musb_context_save_restore(0);
 		}
 		omap_uart_resume_idle(0);
 		omap_uart_resume_idle(1);
Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
===================================================================
--- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	2010-08-06 09:24:23.690112596 -0400
+++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	2010-08-06 10:44:06.385862697 -0400
@@ -120,6 +120,27 @@
 	}
 }
 
+void musb_context_save_restore(int save)
+{
+	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
+	struct omap_device *od = oh->od;
+	struct platform_device *pdev = &od->pdev;
+	struct device *dev = &pdev->dev;
+	struct device_driver *drv = dev->driver;
+
+	if (drv) {
+		struct musb_hdrc_platform_data *pdata = dev->platform_data;
+		const struct dev_pm_ops *pm = drv->pm;
+		if (!pdata->is_usb_active(dev)) {
+
+			if (save)
+				pm->suspend(dev);
+			else
+				pm->resume_noirq(dev);
+		}
+	}
+}
+
 #else
 void __init usb_musb_init(struct omap_musb_board_data *board_data)
 {
Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
===================================================================
--- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h	2010-08-06 09:23:01.137862514 -0400
+++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h	2010-08-06 10:44:06.381864367 -0400
@@ -79,6 +79,8 @@
 
 extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata);
 
+/* For saving and restoring the musb context during off/wakeup*/
+extern void musb_context_save_restore(int save);
 #endif
 
 
Index: linux-omap-pm/drivers/usb/musb/musb_core.c
===================================================================
--- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	2010-08-06 09:24:21.069863329 -0400
+++ linux-omap-pm/drivers/usb/musb/musb_core.c	2010-08-06 10:44:06.369863527 -0400
@@ -2427,11 +2427,6 @@
 	}
 
 	musb_save_context(musb);
-
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 0);
-	else
-		clk_disable(musb->clock);
 	spin_unlock_irqrestore(&musb->lock, flags);
 	return 0;
 }
@@ -2443,12 +2438,6 @@
 
 	if (!musb->clock)
 		return 0;
-
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 1);
-	else
-		clk_enable(musb->clock);
-
 	musb_restore_context(musb);
 
 	/* for static cmos like DaVinci, register values were preserved
Index: linux-omap-pm/drivers/usb/musb/omap2430.c
===================================================================
--- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	2010-08-06 09:24:21.069863329 -0400
+++ linux-omap-pm/drivers/usb/musb/omap2430.c	2010-08-06 10:44:30.093914217 -0400
@@ -189,6 +189,19 @@
 	return 0;
 }
 
+int is_musb_active(struct device *dev)
+{
+	struct musb *musb;
+
+#ifdef CONFIG_USB_MUSB_HDRC_HCD
+	/* usbcore insists dev->driver_data is a "struct hcd *" */
+	musb = hcd_to_musb(dev_get_drvdata(dev));
+#else
+	musb = dev_get_drvdata(dev);
+#endif
+	return musb->is_active;
+}
+
 int __init musb_platform_init(struct musb *musb)
 {
 	u32 l;
@@ -250,6 +263,7 @@
 	if (is_host_enabled(musb))
 		musb->board_set_vbus = omap_set_vbus;
 
+	plat->is_usb_active = is_musb_active;
 	setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
 
 	return 0;
@@ -259,15 +273,42 @@
 void musb_platform_save_context(struct musb *musb,
 		struct musb_context_registers *musb_context)
 {
-	musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
+	/*
+	 * As per the omap-usbotg specification, configure it to forced standby
+	 * and  force idle mode when no activity on usb.
+	 */
+	void __iomem *musb_base = musb->mregs;
+
+	musb_writel(musb_base, OTG_FORCESTDBY, 0);
+
+	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
+				OTG_SYSCONFIG) & ~(NOSTDBY | SMARTSTDBY));
+
+	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
+					OTG_SYSCONFIG) & ~(AUTOIDLE));
+
+	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
+				OTG_SYSCONFIG) & ~(NOIDLE | SMARTIDLE));
+
+	musb_writel(musb_base, OTG_FORCESTDBY, 1);
 }
 
 void musb_platform_restore_context(struct musb *musb,
 		struct musb_context_registers *musb_context)
 {
-	musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig);
-	musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby);
+	/*
+	 * As per the omap-usbotg specification, configure it smart standby
+	 * and smart idle during operation.
+	 */
+	void __iomem *musb_base = musb->mregs;
+
+	musb_writel(musb_base, OTG_FORCESTDBY, 0);
+
+	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
+				OTG_SYSCONFIG) | (SMARTSTDBY));
+
+	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
+				OTG_SYSCONFIG) | (SMARTIDLE));
 }
 #endif
 
Index: linux-omap-pm/include/linux/usb/musb.h
===================================================================
--- linux-omap-pm.orig/include/linux/usb/musb.h	2010-08-06 09:23:01.161864151 -0400
+++ linux-omap-pm/include/linux/usb/musb.h	2010-08-06 10:44:06.401862567 -0400
@@ -126,6 +126,9 @@
 
 	/* Architecture specific board data	*/
 	void		*board_data;
+
+	/* check usb device active state*/
+	int		(*is_usb_active)(struct device *dev);
 };
 
 

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

* Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
  2010-08-06 17:27 [PATCH V2 6/8] usb: musb: Offmode fix for idle path Hema HK
@ 2010-08-07  2:24 ` Bob Liu
  2010-08-10  7:09   ` Kalliguddi, Hema
       [not found] ` <1281115624-1174-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  1 sibling, 1 reply; 13+ messages in thread
From: Bob Liu @ 2010-08-07  2:24 UTC (permalink / raw)
  To: Hema HK
  Cc: linux-usb, linux-omap, Maulik Mankad, Felipe Balbi,
	Tony Lindgren, Kevin Hilman

On Sat, Aug 7, 2010 at 1:27 AM, Hema HK <hemahk@ti.com> wrote:
> From: Hema HK  <hemahk@ti.com>
>
> With OMAP core-off support musb was not functional as context was getting
> lost after wakeup from core-off. And also musb was blocking the core-off
> after loading the gadget driver even with no cable connected sometimes.
>
> Added the conext save/restore api in the platform layer which will
> be called in the idle and wakeup path.
>
> Changed the usb sysconfig settings as per the usbotg functional spec.
> When the device is not active, configure to force idle and force standby mode.
> When it is being used, configure in smart standby and smart idle mode.
> So while attempting to coreoff the usb is configured to force standby and
> force idle mode, after wakeup configured in smart idle and smart standby.
>
> Signed-off-by: Hema HK <hemahk@ti.com>
> Signed-off-by: Maulik Mankad <x0082077@ti.com>
>
> Cc: Felipe Balbi <felipe.balbi@nokia.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Kevin Hilman <khilman@deeprootsystems.com>
> ---
>
>  arch/arm/mach-omap2/pm34xx.c          |    4 ++
>  arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
>  arch/arm/plat-omap/include/plat/usb.h |    2 +
>  drivers/usb/musb/musb_core.c          |   11 -------
>  drivers/usb/musb/omap2430.c           |   48 +++++++++++++++++++++++++++++++---
>  5 files changed, 71 insertions(+), 15 deletions(-)
>
> Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c     2010-08-06 09:23:01.153862710 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c  2010-08-06 10:44:06.393863125 -0400
> @@ -39,6 +39,7 @@
>  #include <plat/gpmc.h>
>  #include <plat/dma.h>
>  #include <plat/dmtimer.h>
> +#include <plat/usb.h>
>
>  #include <asm/tlbflush.h>
>
> @@ -416,6 +417,8 @@
>                if (core_next_state == PWRDM_POWER_OFF) {
>                        omap3_core_save_context();
>                        omap3_prcm_save_context();
> +                       /* Save MUSB context */
> +                       musb_context_save_restore(1);
>                }
>        }
>
> @@ -458,6 +461,8 @@
>                        omap3_prcm_restore_context();
>                        omap3_sram_restore_context();
>                        omap2_sms_restore_context();
> +                       /* restore MUSB context */
> +                       musb_context_save_restore(0);
>                }
>                omap_uart_resume_idle(0);
>                omap_uart_resume_idle(1);
> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c   2010-08-06 09:24:23.690112596 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c        2010-08-06 10:44:06.385862697 -0400
> @@ -120,6 +120,27 @@
>        }
>  }
>
> +void musb_context_save_restore(int save)
> +{
> +       struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
> +       struct omap_device *od = oh->od;
> +       struct platform_device *pdev = &od->pdev;
> +       struct device *dev = &pdev->dev;
> +       struct device_driver *drv = dev->driver;
> +
> +       if (drv) {
> +               struct musb_hdrc_platform_data *pdata = dev->platform_data;
> +               const struct dev_pm_ops *pm = drv->pm;
> +               if (!pdata->is_usb_active(dev)) {
> +
> +                       if (save)
> +                               pm->suspend(dev);
> +                       else
> +                               pm->resume_noirq(dev);
> +               }
> +       }
> +}
> +
>  #else
>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>  {
> Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h    2010-08-06 09:23:01.137862514 -0400
> +++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h 2010-08-06 10:44:06.381864367 -0400
> @@ -79,6 +79,8 @@
>
>  extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata);
>
> +/* For saving and restoring the musb context during off/wakeup*/
> +extern void musb_context_save_restore(int save);
>  #endif
>
>
> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c     2010-08-06 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/musb_core.c  2010-08-06 10:44:06.369863527 -0400
> @@ -2427,11 +2427,6 @@
>        }
>
>        musb_save_context(musb);
> -
> -       if (musb->set_clock)
> -               musb->set_clock(musb->clock, 0);
> -       else
> -               clk_disable(musb->clock);
>        spin_unlock_irqrestore(&musb->lock, flags);
>        return 0;
>  }
> @@ -2443,12 +2438,6 @@
>
>        if (!musb->clock)
>                return 0;

Is this check can be deleted also ?
Because our blackfin platform have no clock support now.
Thanks.

> -
> -       if (musb->set_clock)
> -               musb->set_clock(musb->clock, 1);
> -       else
> -               clk_enable(musb->clock);
> -
>        musb_restore_context(musb);
>
>        /* for static cmos like DaVinci, register values were preserved
> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c      2010-08-06 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/omap2430.c   2010-08-06 10:44:30.093914217 -0400
> @@ -189,6 +189,19 @@
>        return 0;
>  }
>
> +int is_musb_active(struct device *dev)
> +{
> +       struct musb *musb;
> +
> +#ifdef CONFIG_USB_MUSB_HDRC_HCD
> +       /* usbcore insists dev->driver_data is a "struct hcd *" */
> +       musb = hcd_to_musb(dev_get_drvdata(dev));
> +#else
> +       musb = dev_get_drvdata(dev);
> +#endif
> +       return musb->is_active;
> +}
> +
>  int __init musb_platform_init(struct musb *musb)
>  {
>        u32 l;
> @@ -250,6 +263,7 @@
>        if (is_host_enabled(musb))
>                musb->board_set_vbus = omap_set_vbus;
>
> +       plat->is_usb_active = is_musb_active;
>        setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
>
>        return 0;
> @@ -259,15 +273,42 @@
>  void musb_platform_save_context(struct musb *musb,
>                struct musb_context_registers *musb_context)
>  {
> -       musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
> -       musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
> +       /*
> +        * As per the omap-usbotg specification, configure it to forced standby
> +        * and  force idle mode when no activity on usb.
> +        */
> +       void __iomem *musb_base = musb->mregs;
> +
> +       musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +                               OTG_SYSCONFIG) & ~(NOSTDBY | SMARTSTDBY));
> +
> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +                                       OTG_SYSCONFIG) & ~(AUTOIDLE));
> +
> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +                               OTG_SYSCONFIG) & ~(NOIDLE | SMARTIDLE));
> +
> +       musb_writel(musb_base, OTG_FORCESTDBY, 1);
>  }
>
>  void musb_platform_restore_context(struct musb *musb,
>                struct musb_context_registers *musb_context)
>  {
> -       musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig);
> -       musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby);
> +       /*
> +        * As per the omap-usbotg specification, configure it smart standby
> +        * and smart idle during operation.
> +        */
> +       void __iomem *musb_base = musb->mregs;
> +
> +       musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +                               OTG_SYSCONFIG) | (SMARTSTDBY));
> +
> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +                               OTG_SYSCONFIG) | (SMARTIDLE));
>  }
>  #endif
>
> Index: linux-omap-pm/include/linux/usb/musb.h
> ===================================================================
> --- linux-omap-pm.orig/include/linux/usb/musb.h 2010-08-06 09:23:01.161864151 -0400
> +++ linux-omap-pm/include/linux/usb/musb.h      2010-08-06 10:44:06.401862567 -0400
> @@ -126,6 +126,9 @@
>
>        /* Architecture specific board data     */
>        void            *board_data;
> +
> +       /* check usb device active state*/
> +       int             (*is_usb_active)(struct device *dev);
>  };
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

-- 
Regards,
--Bob
--
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] 13+ messages in thread

* Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
       [not found] ` <1281115624-1174-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
@ 2010-08-07 15:25   ` Sergei Shtylyov
       [not found]     ` <4C5D7AE5.7040506-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
  2010-08-09 13:01   ` Cousson, Benoit
  2010-08-09 16:43   ` DebBarma, Tarun Kanti
  2 siblings, 1 reply; 13+ messages in thread
From: Sergei Shtylyov @ 2010-08-07 15:25 UTC (permalink / raw)
  To: Hema HK
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Maulik Mankad, Felipe Balbi,
	Tony Lindgren, Kevin Hilman

Hello.

Hema HK wrote:

> With OMAP core-off support musb was not functional as context was getting
> lost after wakeup from core-off. And also musb was blocking the core-off 
> after loading the gadget driver even with no cable connected sometimes.

> Added the conext save/restore api in the platform layer which will
> be called in the idle and wakeup path.

> Changed the usb sysconfig settings as per the usbotg functional spec.
> When the device is not active, configure to force idle and force standby mode.
> When it is being used, configure in smart standby and smart idle mode.
> So while attempting to coreoff the usb is configured to force standby and 
> force idle mode, after wakeup configured in smart idle and smart standby.

> Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
> Signed-off-by: Maulik Mankad <x0082077-l0cyMroinI0@public.gmane.org>

> Cc: Felipe Balbi <felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>

[...]

> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	2010-08-06 09:24:23.690112596 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	2010-08-06 10:44:06.385862697 -0400
> @@ -120,6 +120,27 @@
>  	}
>  }
>  
> +void musb_context_save_restore(int save)
> +{
> +	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
> +	struct omap_device *od = oh->od;
> +	struct platform_device *pdev = &od->pdev;
> +	struct device *dev = &pdev->dev;
> +	struct device_driver *drv = dev->driver;
> +
> +	if (drv) {
> +		struct musb_hdrc_platform_data *pdata = dev->platform_data;
> +		const struct dev_pm_ops *pm = drv->pm;

    Should be an empty line after the declaration block...

> +		if (!pdata->is_usb_active(dev)) {
> +
> +			if (save)
> +				pm->suspend(dev);
> +			else
> +				pm->resume_noirq(dev);
> +		}
> +	}
> +}
> +
>  #else
>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>  {
> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	2010-08-06 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	2010-08-06 10:44:06.369863527 -0400
> @@ -2427,11 +2427,6 @@
>  	}
>  
>  	musb_save_context(musb);
> -
> -	if (musb->set_clock)
> -		musb->set_clock(musb->clock, 0);
> -	else
> -		clk_disable(musb->clock);
>  	spin_unlock_irqrestore(&musb->lock, flags);
>  	return 0;
>  }
> @@ -2443,12 +2438,6 @@
>  
>  	if (!musb->clock)
>  		return 0;
> -
> -	if (musb->set_clock)
> -		musb->set_clock(musb->clock, 1);
> -	else
> -		clk_enable(musb->clock);
> -
>  	musb_restore_context(musb);

   The same question again: are you sure that clocks are auto-gated on 
non-OMAP platfroms?

> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	2010-08-06 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	2010-08-06 10:44:30.093914217 -0400
[...]
> @@ -259,15 +273,42 @@
>  void musb_platform_save_context(struct musb *musb,
>  		struct musb_context_registers *musb_context)
>  {
> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
> -	musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);

    If you're not saving the registers, you should remove the corresponding 
fields from 'struct musb_context_registers'.

> +	/*
> +	 * As per the omap-usbotg specification, configure it to forced standby
> +	 * and  force idle mode when no activity on usb.
> +	 */
> +	void __iomem *musb_base = musb->mregs;
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) & ~(NOSTDBY | SMARTSTDBY));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +					OTG_SYSCONFIG) & ~(AUTOIDLE));

    Pointless parens around AUTOIDLE...

> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) & ~(NOIDLE | SMARTIDLE));
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 1);
>  }
>  
>  void musb_platform_restore_context(struct musb *musb,
>  		struct musb_context_registers *musb_context)
>  {
> -	musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig);
> -	musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby);
> +	/*
> +	 * As per the omap-usbotg specification, configure it smart standby
> +	 * and smart idle during operation.
> +	 */
> +	void __iomem *musb_base = musb->mregs;
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) | (SMARTSTDBY));

    Pointless parens around SMARTSTDBY...

> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) | (SMARTIDLE));

    Pointless parens around SMARTIDLE...

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
       [not found] ` <1281115624-1174-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2010-08-07 15:25   ` Sergei Shtylyov
@ 2010-08-09 13:01   ` Cousson, Benoit
  2010-08-09 13:12     ` Kalliguddi, Hema
  2010-08-09 16:43   ` DebBarma, Tarun Kanti
  2 siblings, 1 reply; 13+ messages in thread
From: Cousson, Benoit @ 2010-08-09 13:01 UTC (permalink / raw)
  To: Kalliguddi, Hema
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Mankad, Maulik Ojas,
	Felipe Balbi, Tony Lindgren, Kevin Hilman

On 8/6/2010 7:27 PM, Kalliguddi, Hema wrote:
> From: Hema HK<hemahk-l0cyMroinI0@public.gmane.org>
>
> With OMAP core-off support musb was not functional as context was getting
> lost after wakeup from core-off. And also musb was blocking the core-off
> after loading the gadget driver even with no cable connected sometimes.
>
> Added the conext save/restore api in the platform layer which will
> be called in the idle and wakeup path.
>
> Changed the usb sysconfig settings as per the usbotg functional spec.
> When the device is not active, configure to force idle and force standby mode.
> When it is being used, configure in smart standby and smart idle mode.
> So while attempting to coreoff the usb is configured to force standby and
> force idle mode, after wakeup configured in smart idle and smart standby.

Is this valid for OMAP3 and OMAP4? I checked quickly the OMAP4 TRM vB in 
the USB_OTG chapter related to PM (23.13.4.2 Power-Management), and I 
cannot find any note regarding that specific programming model.
Could give us reference to the documentation that contains the details 
about that?

Benoit

>
> Signed-off-by: Hema HK<hemahk-l0cyMroinI0@public.gmane.org>
> Signed-off-by: Maulik Mankad<x0082077-l0cyMroinI0@public.gmane.org>
>
> Cc: Felipe Balbi<felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> Cc: Tony Lindgren<tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> Cc: Kevin Hilman<khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
> ---
>
>   arch/arm/mach-omap2/pm34xx.c          |    4 ++
>   arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
>   arch/arm/plat-omap/include/plat/usb.h |    2 +
>   drivers/usb/musb/musb_core.c          |   11 -------
>   drivers/usb/musb/omap2430.c           |   48 +++++++++++++++++++++++++++++++---
>   5 files changed, 71 insertions(+), 15 deletions(-)
>
> Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c	2010-08-06 09:23:01.153862710 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c	2010-08-06 10:44:06.393863125 -0400
> @@ -39,6 +39,7 @@
>   #include<plat/gpmc.h>
>   #include<plat/dma.h>
>   #include<plat/dmtimer.h>
> +#include<plat/usb.h>
>
>   #include<asm/tlbflush.h>
>
> @@ -416,6 +417,8 @@
>   		if (core_next_state == PWRDM_POWER_OFF) {
>   			omap3_core_save_context();
>   			omap3_prcm_save_context();
> +			/* Save MUSB context */
> +			musb_context_save_restore(1);
>   		}
>   	}
>
> @@ -458,6 +461,8 @@
>   			omap3_prcm_restore_context();
>   			omap3_sram_restore_context();
>   			omap2_sms_restore_context();
> +			/* restore MUSB context */
> +			musb_context_save_restore(0);
>   		}
>   		omap_uart_resume_idle(0);
>   		omap_uart_resume_idle(1);
> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	2010-08-06 09:24:23.690112596 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	2010-08-06 10:44:06.385862697 -0400
> @@ -120,6 +120,27 @@
>   	}
>   }
>
> +void musb_context_save_restore(int save)
> +{
> +	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
> +	struct omap_device *od = oh->od;
> +	struct platform_device *pdev =&od->pdev;
> +	struct device *dev =&pdev->dev;
> +	struct device_driver *drv = dev->driver;
> +
> +	if (drv) {
> +		struct musb_hdrc_platform_data *pdata = dev->platform_data;
> +		const struct dev_pm_ops *pm = drv->pm;
> +		if (!pdata->is_usb_active(dev)) {
> +
> +			if (save)
> +				pm->suspend(dev);
> +			else
> +				pm->resume_noirq(dev);
> +		}
> +	}
> +}
> +
>   #else
>   void __init usb_musb_init(struct omap_musb_board_data *board_data)
>   {
> Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h	2010-08-06 09:23:01.137862514 -0400
> +++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h	2010-08-06 10:44:06.381864367 -0400
> @@ -79,6 +79,8 @@
>
>   extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata);
>
> +/* For saving and restoring the musb context during off/wakeup*/
> +extern void musb_context_save_restore(int save);
>   #endif
>
>
> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	2010-08-06 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	2010-08-06 10:44:06.369863527 -0400
> @@ -2427,11 +2427,6 @@
>   	}
>
>   	musb_save_context(musb);
> -
> -	if (musb->set_clock)
> -		musb->set_clock(musb->clock, 0);
> -	else
> -		clk_disable(musb->clock);
>   	spin_unlock_irqrestore(&musb->lock, flags);
>   	return 0;
>   }
> @@ -2443,12 +2438,6 @@
>
>   	if (!musb->clock)
>   		return 0;
> -
> -	if (musb->set_clock)
> -		musb->set_clock(musb->clock, 1);
> -	else
> -		clk_enable(musb->clock);
> -
>   	musb_restore_context(musb);
>
>   	/* for static cmos like DaVinci, register values were preserved
> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	2010-08-06 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	2010-08-06 10:44:30.093914217 -0400
> @@ -189,6 +189,19 @@
>   	return 0;
>   }
>
> +int is_musb_active(struct device *dev)
> +{
> +	struct musb *musb;
> +
> +#ifdef CONFIG_USB_MUSB_HDRC_HCD
> +	/* usbcore insists dev->driver_data is a "struct hcd *" */
> +	musb = hcd_to_musb(dev_get_drvdata(dev));
> +#else
> +	musb = dev_get_drvdata(dev);
> +#endif
> +	return musb->is_active;
> +}
> +
>   int __init musb_platform_init(struct musb *musb)
>   {
>   	u32 l;
> @@ -250,6 +263,7 @@
>   	if (is_host_enabled(musb))
>   		musb->board_set_vbus = omap_set_vbus;
>
> +	plat->is_usb_active = is_musb_active;
>   	setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
>
>   	return 0;
> @@ -259,15 +273,42 @@
>   void musb_platform_save_context(struct musb *musb,
>   		struct musb_context_registers *musb_context)
>   {
> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
> -	musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
> +	/*
> +	 * As per the omap-usbotg specification, configure it to forced standby
> +	 * and  force idle mode when no activity on usb.
> +	 */
> +	void __iomem *musb_base = musb->mregs;
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG)&  ~(NOSTDBY | SMARTSTDBY));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +					OTG_SYSCONFIG)&  ~(AUTOIDLE));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG)&  ~(NOIDLE | SMARTIDLE));
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 1);
>   }
>
>   void musb_platform_restore_context(struct musb *musb,
>   		struct musb_context_registers *musb_context)
>   {
> -	musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig);
> -	musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby);
> +	/*
> +	 * As per the omap-usbotg specification, configure it smart standby
> +	 * and smart idle during operation.
> +	 */
> +	void __iomem *musb_base = musb->mregs;
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) | (SMARTSTDBY));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) | (SMARTIDLE));
>   }
>   #endif
>
> Index: linux-omap-pm/include/linux/usb/musb.h
> ===================================================================
> --- linux-omap-pm.orig/include/linux/usb/musb.h	2010-08-06 09:23:01.161864151 -0400
> +++ linux-omap-pm/include/linux/usb/musb.h	2010-08-06 10:44:06.401862567 -0400
> @@ -126,6 +126,9 @@
>
>   	/* Architecture specific board data	*/
>   	void		*board_data;
> +
> +	/* check usb device active state*/
> +	int		(*is_usb_active)(struct device *dev);
>   };
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
  2010-08-09 13:01   ` Cousson, Benoit
@ 2010-08-09 13:12     ` Kalliguddi, Hema
       [not found]       ` <E0D41E29EB0DAC4E9F3FF173962E9E940270943E2D-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Kalliguddi, Hema @ 2010-08-09 13:12 UTC (permalink / raw)
  To: Cousson, Benoit
  Cc: linux-usb, linux-omap, Mankad, Maulik Ojas, Felipe Balbi,
	Tony Lindgren, Kevin Hilman

 Hi,

>-----Original Message-----
>From: Cousson, Benoit 
>Sent: Monday, August 09, 2010 6:31 PM
>To: Kalliguddi, Hema
>Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org; 
>Mankad, Maulik Ojas; Felipe Balbi; Tony Lindgren; Kevin Hilman
>Subject: Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
>
>On 8/6/2010 7:27 PM, Kalliguddi, Hema wrote:
>> From: Hema HK<hemahk@ti.com>
>>
>> With OMAP core-off support musb was not functional as 
>context was getting
>> lost after wakeup from core-off. And also musb was blocking 
>the core-off
>> after loading the gadget driver even with no cable connected 
>sometimes.
>>
>> Added the conext save/restore api in the platform layer which will
>> be called in the idle and wakeup path.
>>
>> Changed the usb sysconfig settings as per the usbotg functional spec.
>> When the device is not active, configure to force idle and 
>force standby mode.
>> When it is being used, configure in smart standby and smart 
>idle mode.
>> So while attempting to coreoff the usb is configured to 
>force standby and
>> force idle mode, after wakeup configured in smart idle and 
>smart standby.
>
>Is this valid for OMAP3 and OMAP4? I checked quickly the OMAP4 
>TRM vB in 
>the USB_OTG chapter related to PM (23.13.4.2 Power-Management), and I 
>cannot find any note regarding that specific programming model.
>Could give us reference to the documentation that contains the details 
>about that?
>
>Benoit
>

This is valid for both OMAP3 and OMAP4. You can find this in 24.1.5.4 section
With different modes. When not used with any application the mode has to be programmed 
is force idle and force standby. What I observed is that without this USB was 
blocking the coreoff.

http://focus.ti.com/pdfs/wtbu/SWPU223D_Final_EPDF_06_07_2010.pdf 

Regards,
Hema
>>
>> Signed-off-by: Hema HK<hemahk@ti.com>
>> Signed-off-by: Maulik Mankad<x0082077@ti.com>
>>
>> Cc: Felipe Balbi<felipe.balbi@nokia.com>
>> Cc: Tony Lindgren<tony@atomide.com>
>> Cc: Kevin Hilman<khilman@deeprootsystems.com>
>> ---
>>
>>   arch/arm/mach-omap2/pm34xx.c          |    4 ++
>>   arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
>>   arch/arm/plat-omap/include/plat/usb.h |    2 +
>>   drivers/usb/musb/musb_core.c          |   11 -------
>>   drivers/usb/musb/omap2430.c           |   48 
>+++++++++++++++++++++++++++++++---
>>   5 files changed, 71 insertions(+), 15 deletions(-)
>>
>> Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c	
>2010-08-06 09:23:01.153862710 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c	
>2010-08-06 10:44:06.393863125 -0400
>> @@ -39,6 +39,7 @@
>>   #include<plat/gpmc.h>
>>   #include<plat/dma.h>
>>   #include<plat/dmtimer.h>
>> +#include<plat/usb.h>
>>
>>   #include<asm/tlbflush.h>
>>
>> @@ -416,6 +417,8 @@
>>   		if (core_next_state == PWRDM_POWER_OFF) {
>>   			omap3_core_save_context();
>>   			omap3_prcm_save_context();
>> +			/* Save MUSB context */
>> +			musb_context_save_restore(1);
>>   		}
>>   	}
>>
>> @@ -458,6 +461,8 @@
>>   			omap3_prcm_restore_context();
>>   			omap3_sram_restore_context();
>>   			omap2_sms_restore_context();
>> +			/* restore MUSB context */
>> +			musb_context_save_restore(0);
>>   		}
>>   		omap_uart_resume_idle(0);
>>   		omap_uart_resume_idle(1);
>> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	
>2010-08-06 09:24:23.690112596 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	
>2010-08-06 10:44:06.385862697 -0400
>> @@ -120,6 +120,27 @@
>>   	}
>>   }
>>
>> +void musb_context_save_restore(int save)
>> +{
>> +	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
>> +	struct omap_device *od = oh->od;
>> +	struct platform_device *pdev =&od->pdev;
>> +	struct device *dev =&pdev->dev;
>> +	struct device_driver *drv = dev->driver;
>> +
>> +	if (drv) {
>> +		struct musb_hdrc_platform_data *pdata = 
>dev->platform_data;
>> +		const struct dev_pm_ops *pm = drv->pm;
>> +		if (!pdata->is_usb_active(dev)) {
>> +
>> +			if (save)
>> +				pm->suspend(dev);
>> +			else
>> +				pm->resume_noirq(dev);
>> +		}
>> +	}
>> +}
>> +
>>   #else
>>   void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>   {
>> Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h	
>2010-08-06 09:23:01.137862514 -0400
>> +++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h	
>2010-08-06 10:44:06.381864367 -0400
>> @@ -79,6 +79,8 @@
>>
>>   extern void usb_ohci_init(const struct 
>ohci_hcd_omap_platform_data *pdata);
>>
>> +/* For saving and restoring the musb context during off/wakeup*/
>> +extern void musb_context_save_restore(int save);
>>   #endif
>>
>>
>> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	
>2010-08-06 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	
>2010-08-06 10:44:06.369863527 -0400
>> @@ -2427,11 +2427,6 @@
>>   	}
>>
>>   	musb_save_context(musb);
>> -
>> -	if (musb->set_clock)
>> -		musb->set_clock(musb->clock, 0);
>> -	else
>> -		clk_disable(musb->clock);
>>   	spin_unlock_irqrestore(&musb->lock, flags);
>>   	return 0;
>>   }
>> @@ -2443,12 +2438,6 @@
>>
>>   	if (!musb->clock)
>>   		return 0;
>> -
>> -	if (musb->set_clock)
>> -		musb->set_clock(musb->clock, 1);
>> -	else
>> -		clk_enable(musb->clock);
>> -
>>   	musb_restore_context(musb);
>>
>>   	/* for static cmos like DaVinci, register values were preserved
>> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	
>2010-08-06 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	
>2010-08-06 10:44:30.093914217 -0400
>> @@ -189,6 +189,19 @@
>>   	return 0;
>>   }
>>
>> +int is_musb_active(struct device *dev)
>> +{
>> +	struct musb *musb;
>> +
>> +#ifdef CONFIG_USB_MUSB_HDRC_HCD
>> +	/* usbcore insists dev->driver_data is a "struct hcd *" */
>> +	musb = hcd_to_musb(dev_get_drvdata(dev));
>> +#else
>> +	musb = dev_get_drvdata(dev);
>> +#endif
>> +	return musb->is_active;
>> +}
>> +
>>   int __init musb_platform_init(struct musb *musb)
>>   {
>>   	u32 l;
>> @@ -250,6 +263,7 @@
>>   	if (is_host_enabled(musb))
>>   		musb->board_set_vbus = omap_set_vbus;
>>
>> +	plat->is_usb_active = is_musb_active;
>>   	setup_timer(&musb_idle_timer, musb_do_idle, (unsigned 
>long) musb);
>>
>>   	return 0;
>> @@ -259,15 +273,42 @@
>>   void musb_platform_save_context(struct musb *musb,
>>   		struct musb_context_registers *musb_context)
>>   {
>> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, 
>OTG_SYSCONFIG);
>> -	musb_context->otg_forcestandby = 
>musb_readl(musb->mregs, OTG_FORCESTDBY);
>> +	/*
>> +	 * As per the omap-usbotg specification, configure it 
>to forced standby
>> +	 * and  force idle mode when no activity on usb.
>> +	 */
>> +	void __iomem *musb_base = musb->mregs;
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG)&  ~(NOSTDBY | 
>SMARTSTDBY));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +					OTG_SYSCONFIG)&  ~(AUTOIDLE));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG)&  ~(NOIDLE | SMARTIDLE));
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 1);
>>   }
>>
>>   void musb_platform_restore_context(struct musb *musb,
>>   		struct musb_context_registers *musb_context)
>>   {
>> -	musb_writel(musb->mregs, OTG_SYSCONFIG, 
>musb_context->otg_sysconfig);
>> -	musb_writel(musb->mregs, OTG_FORCESTDBY, 
>musb_context->otg_forcestandby);
>> +	/*
>> +	 * As per the omap-usbotg specification, configure it 
>smart standby
>> +	 * and smart idle during operation.
>> +	 */
>> +	void __iomem *musb_base = musb->mregs;
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) | (SMARTSTDBY));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) | (SMARTIDLE));
>>   }
>>   #endif
>>
>> Index: linux-omap-pm/include/linux/usb/musb.h
>> ===================================================================
>> --- linux-omap-pm.orig/include/linux/usb/musb.h	
>2010-08-06 09:23:01.161864151 -0400
>> +++ linux-omap-pm/include/linux/usb/musb.h	2010-08-06 
>10:44:06.401862567 -0400
>> @@ -126,6 +126,9 @@
>>
>>   	/* Architecture specific board data	*/
>>   	void		*board_data;
>> +
>> +	/* check usb device active state*/
>> +	int		(*is_usb_active)(struct device *dev);
>>   };
>>
>>
>> --
>> 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] 13+ messages in thread

* RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
       [not found] ` <1281115624-1174-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2010-08-07 15:25   ` Sergei Shtylyov
  2010-08-09 13:01   ` Cousson, Benoit
@ 2010-08-09 16:43   ` DebBarma, Tarun Kanti
  2010-08-10  8:23     ` Kalliguddi, Hema
  2 siblings, 1 reply; 13+ messages in thread
From: DebBarma, Tarun Kanti @ 2010-08-09 16:43 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA
  Cc: Kalliguddi, Hema, Mankad, Maulik Ojas, Felipe Balbi,
	Tony Lindgren, Kevin Hilman

Hema,

> -----Original Message-----
> From: linux-omap-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org [mailto:linux-omap-
> owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org] On Behalf Of Hema HK
> Sent: Friday, August 06, 2010 10:57 PM
> To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Kalliguddi, Hema; Mankad, Maulik Ojas; Felipe Balbi; Tony Lindgren;
> Kevin Hilman
> Subject: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
> 
> From: Hema HK  <hemahk-l0cyMroinI0@public.gmane.org>
> 
> With OMAP core-off support musb was not functional as context was getting
> lost after wakeup from core-off. And also musb was blocking the core-off
> after loading the gadget driver even with no cable connected sometimes.
> 
> Added the conext save/restore api in the platform layer which will
> be called in the idle and wakeup path.
> 
> Changed the usb sysconfig settings as per the usbotg functional spec.
> When the device is not active, configure to force idle and force standby
> mode.
> When it is being used, configure in smart standby and smart idle mode.
> So while attempting to coreoff the usb is configured to force standby and
> force idle mode, after wakeup configured in smart idle and smart standby.
> 
> Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
> Signed-off-by: Maulik Mankad <x0082077-l0cyMroinI0@public.gmane.org>
> 
> Cc: Felipe Balbi <felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
> ---
> 
>  arch/arm/mach-omap2/pm34xx.c          |    4 ++
>  arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
>  arch/arm/plat-omap/include/plat/usb.h |    2 +
>  drivers/usb/musb/musb_core.c          |   11 -------
>  drivers/usb/musb/omap2430.c           |   48
> +++++++++++++++++++++++++++++++---
>  5 files changed, 71 insertions(+), 15 deletions(-)
> 
> Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c	2010-08-06
> 09:23:01.153862710 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c	2010-08-06
> 10:44:06.393863125 -0400
> @@ -39,6 +39,7 @@
>  #include <plat/gpmc.h>
>  #include <plat/dma.h>
>  #include <plat/dmtimer.h>
> +#include <plat/usb.h>
> 
>  #include <asm/tlbflush.h>
> 
> @@ -416,6 +417,8 @@
>  		if (core_next_state == PWRDM_POWER_OFF) {
>  			omap3_core_save_context();
>  			omap3_prcm_save_context();
> +			/* Save MUSB context */
> +			musb_context_save_restore(1);
>  		}
>  	}
> 
> @@ -458,6 +461,8 @@
>  			omap3_prcm_restore_context();
>  			omap3_sram_restore_context();
>  			omap2_sms_restore_context();
> +			/* restore MUSB context */
> +			musb_context_save_restore(0);
>  		}
>  		omap_uart_resume_idle(0);
>  		omap_uart_resume_idle(1);
> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	2010-08-06
> 09:24:23.690112596 -0400
> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	2010-08-06
> 10:44:06.385862697 -0400
> @@ -120,6 +120,27 @@
>  	}
>  }
> 
> +void musb_context_save_restore(int save)
> +{
> +	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
Might be good idea to check (oh) before proceeding?
if (!oh) {
	/* error message */
	return;
}

> +	struct omap_device *od = oh->od;
> +	struct platform_device *pdev = &od->pdev;
> +	struct device *dev = &pdev->dev;
> +	struct device_driver *drv = dev->driver;
> +
> +	if (drv) {
> +		struct musb_hdrc_platform_data *pdata = dev->platform_data;
> +		const struct dev_pm_ops *pm = drv->pm;
> +		if (!pdata->is_usb_active(dev)) {
> +
> +			if (save)
> +				pm->suspend(dev);
> +			else
> +				pm->resume_noirq(dev);
> +		}
> +	}
> +}
> +
>  #else
>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>  {
> Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
> ===================================================================
> --- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h	2010-08-
> 06 09:23:01.137862514 -0400
> +++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h	2010-08-06
> 10:44:06.381864367 -0400
> @@ -79,6 +79,8 @@
> 
>  extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data
> *pdata);
> 
> +/* For saving and restoring the musb context during off/wakeup*/
> +extern void musb_context_save_restore(int save);
>  #endif
> 
> 
> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	2010-08-06
> 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	2010-08-06
> 10:44:06.369863527 -0400
> @@ -2427,11 +2427,6 @@
>  	}
> 
>  	musb_save_context(musb);
> -
> -	if (musb->set_clock)
> -		musb->set_clock(musb->clock, 0);
> -	else
> -		clk_disable(musb->clock);
>  	spin_unlock_irqrestore(&musb->lock, flags);
>  	return 0;
>  }
> @@ -2443,12 +2438,6 @@
> 
>  	if (!musb->clock)
>  		return 0;
> -
> -	if (musb->set_clock)
> -		musb->set_clock(musb->clock, 1);
> -	else
> -		clk_enable(musb->clock);
> -
>  	musb_restore_context(musb);
> 
>  	/* for static cmos like DaVinci, register values were preserved
> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
> ===================================================================
> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	2010-08-06
> 09:24:21.069863329 -0400
> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	2010-08-06
> 10:44:30.093914217 -0400
> @@ -189,6 +189,19 @@
>  	return 0;
>  }
> 
> +int is_musb_active(struct device *dev)
> +{
> +	struct musb *musb;
> +
> +#ifdef CONFIG_USB_MUSB_HDRC_HCD
> +	/* usbcore insists dev->driver_data is a "struct hcd *" */
> +	musb = hcd_to_musb(dev_get_drvdata(dev));
> +#else
> +	musb = dev_get_drvdata(dev);
> +#endif
> +	return musb->is_active;
> +}
> +
>  int __init musb_platform_init(struct musb *musb)
>  {
>  	u32 l;
> @@ -250,6 +263,7 @@
>  	if (is_host_enabled(musb))
>  		musb->board_set_vbus = omap_set_vbus;
> 
> +	plat->is_usb_active = is_musb_active;
>  	setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
> 
>  	return 0;
> @@ -259,15 +273,42 @@
>  void musb_platform_save_context(struct musb *musb,
>  		struct musb_context_registers *musb_context)
>  {
> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
> -	musb_context->otg_forcestandby = musb_readl(musb->mregs,
> OTG_FORCESTDBY);
> +	/*
> +	 * As per the omap-usbotg specification, configure it to forced
> standby
> +	 * and  force idle mode when no activity on usb.
> +	 */
> +	void __iomem *musb_base = musb->mregs;
> +
Just to clarify, have you already taken care of ioremap() / request_mem_region() for musb_base?


> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) & ~(NOSTDBY | SMARTSTDBY));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +					OTG_SYSCONFIG) & ~(AUTOIDLE));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) & ~(NOIDLE | SMARTIDLE));
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 1);
>  }
> 
>  void musb_platform_restore_context(struct musb *musb,
>  		struct musb_context_registers *musb_context)
>  {
> -	musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig);
> -	musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context-
> >otg_forcestandby);
> +	/*
> +	 * As per the omap-usbotg specification, configure it smart standby
> +	 * and smart idle during operation.
> +	 */
> +	void __iomem *musb_base = musb->mregs;
> +
> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) | (SMARTSTDBY));
> +
> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
> +				OTG_SYSCONFIG) | (SMARTIDLE));
>  }
>  #endif
> 
> Index: linux-omap-pm/include/linux/usb/musb.h
> ===================================================================
> --- linux-omap-pm.orig/include/linux/usb/musb.h	2010-08-06
> 09:23:01.161864151 -0400
> +++ linux-omap-pm/include/linux/usb/musb.h	2010-08-06 10:44:06.401862567
> -0400
> @@ -126,6 +126,9 @@
> 
>  	/* Architecture specific board data	*/
>  	void		*board_data;
> +
> +	/* check usb device active state*/
> +	int		(*is_usb_active)(struct device *dev);
>  };
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
       [not found]       ` <E0D41E29EB0DAC4E9F3FF173962E9E940270943E2D-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
@ 2010-08-09 21:01         ` Kevin Hilman
  0 siblings, 0 replies; 13+ messages in thread
From: Kevin Hilman @ 2010-08-09 21:01 UTC (permalink / raw)
  To: Kalliguddi, Hema
  Cc: Cousson, Benoit, linux-usb@vger.kernel.org,
	linux-omap@vger.kernel.org, Mankad, Maulik Ojas, Felipe Balbi,
	Tony Lindgren

"Kalliguddi, Hema" <hemahk-l0cyMroinI0@public.gmane.org> writes:

[...]

>>>
>>> Changed the usb sysconfig settings as per the usbotg functional spec.
>>> When the device is not active, configure to force idle and 
>>force standby mode.
>>> When it is being used, configure in smart standby and smart 
>>idle mode.
>>> So while attempting to coreoff the usb is configured to 
>>force standby and
>>> force idle mode, after wakeup configured in smart idle and 
>>smart standby.
>>
>>Is this valid for OMAP3 and OMAP4? I checked quickly the OMAP4 
>>TRM vB in 
>>the USB_OTG chapter related to PM (23.13.4.2 Power-Management), and I 
>>cannot find any note regarding that specific programming model.
>>Could give us reference to the documentation that contains the details 
>>about that?
>>
>>Benoit
>>
>
> This is valid for both OMAP3 and OMAP4. You can find this in 24.1.5.4 section
> With different modes. When not used with any application the mode has to be programmed 
> is force idle and force standby. What I observed is that without this USB was 
> blocking the coreoff.
>
> http://focus.ti.com/pdfs/wtbu/SWPU223D_Final_EPDF_06_07_2010.pdf 
>

For the next rev, please include links to public docs in the changelog.

Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
  2010-08-07  2:24 ` Bob Liu
@ 2010-08-10  7:09   ` Kalliguddi, Hema
  0 siblings, 0 replies; 13+ messages in thread
From: Kalliguddi, Hema @ 2010-08-10  7:09 UTC (permalink / raw)
  To: Bob Liu
  Cc: linux-usb, linux-omap, Mankad, Maulik Ojas, Felipe Balbi,
	Tony Lindgren, Kevin Hilman

 

>-----Original Message-----
>From: Bob Liu [mailto:lliubbo@gmail.com] 
>Sent: Saturday, August 07, 2010 7:54 AM
>To: Kalliguddi, Hema
>Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org; 
>Mankad, Maulik Ojas; Felipe Balbi; Tony Lindgren; Kevin Hilman
>Subject: Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
>
>On Sat, Aug 7, 2010 at 1:27 AM, Hema HK <hemahk@ti.com> wrote:
>> From: Hema HK  <hemahk@ti.com>
>>
>> With OMAP core-off support musb was not functional as 
>context was getting
>> lost after wakeup from core-off. And also musb was blocking 
>the core-off
>> after loading the gadget driver even with no cable connected 
>sometimes.
>>
>> Added the conext save/restore api in the platform layer which will
>> be called in the idle and wakeup path.
>>
>> Changed the usb sysconfig settings as per the usbotg functional spec.
>> When the device is not active, configure to force idle and 
>force standby mode.
>> When it is being used, configure in smart standby and smart 
>idle mode.
>> So while attempting to coreoff the usb is configured to 
>force standby and
>> force idle mode, after wakeup configured in smart idle and 
>smart standby.
>>
>> Signed-off-by: Hema HK <hemahk@ti.com>
>> Signed-off-by: Maulik Mankad <x0082077@ti.com>
>>
>> Cc: Felipe Balbi <felipe.balbi@nokia.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Kevin Hilman <khilman@deeprootsystems.com>
>> ---
>>
>>  arch/arm/mach-omap2/pm34xx.c          |    4 ++
>>  arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
>>  arch/arm/plat-omap/include/plat/usb.h |    2 +
>>  drivers/usb/musb/musb_core.c          |   11 -------
>>  drivers/usb/musb/omap2430.c           |   48 
>+++++++++++++++++++++++++++++++---
>>  5 files changed, 71 insertions(+), 15 deletions(-)
>>
>> Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c     
>2010-08-06 09:23:01.153862710 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c  2010-08-06 
>10:44:06.393863125 -0400
>> @@ -39,6 +39,7 @@
>>  #include <plat/gpmc.h>
>>  #include <plat/dma.h>
>>  #include <plat/dmtimer.h>
>> +#include <plat/usb.h>
>>
>>  #include <asm/tlbflush.h>
>>
>> @@ -416,6 +417,8 @@
>>                if (core_next_state == PWRDM_POWER_OFF) {
>>                        omap3_core_save_context();
>>                        omap3_prcm_save_context();
>> +                       /* Save MUSB context */
>> +                       musb_context_save_restore(1);
>>                }
>>        }
>>
>> @@ -458,6 +461,8 @@
>>                        omap3_prcm_restore_context();
>>                        omap3_sram_restore_context();
>>                        omap2_sms_restore_context();
>> +                       /* restore MUSB context */
>> +                       musb_context_save_restore(0);
>>                }
>>                omap_uart_resume_idle(0);
>>                omap_uart_resume_idle(1);
>> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c   
>2010-08-06 09:24:23.690112596 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c        
>2010-08-06 10:44:06.385862697 -0400
>> @@ -120,6 +120,27 @@
>>        }
>>  }
>>
>> +void musb_context_save_restore(int save)
>> +{
>> +       struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
>> +       struct omap_device *od = oh->od;
>> +       struct platform_device *pdev = &od->pdev;
>> +       struct device *dev = &pdev->dev;
>> +       struct device_driver *drv = dev->driver;
>> +
>> +       if (drv) {
>> +               struct musb_hdrc_platform_data *pdata = 
>dev->platform_data;
>> +               const struct dev_pm_ops *pm = drv->pm;
>> +               if (!pdata->is_usb_active(dev)) {
>> +
>> +                       if (save)
>> +                               pm->suspend(dev);
>> +                       else
>> +                               pm->resume_noirq(dev);
>> +               }
>> +       }
>> +}
>> +
>>  #else
>>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>  {
>> Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h 
>   2010-08-06 09:23:01.137862514 -0400
>> +++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h 
>2010-08-06 10:44:06.381864367 -0400
>> @@ -79,6 +79,8 @@
>>
>>  extern void usb_ohci_init(const struct 
>ohci_hcd_omap_platform_data *pdata);
>>
>> +/* For saving and restoring the musb context during off/wakeup*/
>> +extern void musb_context_save_restore(int save);
>>  #endif
>>
>>
>> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c     
>2010-08-06 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/musb_core.c  2010-08-06 
>10:44:06.369863527 -0400
>> @@ -2427,11 +2427,6 @@
>>        }
>>
>>        musb_save_context(musb);
>> -
>> -       if (musb->set_clock)
>> -               musb->set_clock(musb->clock, 0);
>> -       else
>> -               clk_disable(musb->clock);
>>        spin_unlock_irqrestore(&musb->lock, flags);
>>        return 0;
>>  }
>> @@ -2443,12 +2438,6 @@
>>
>>        if (!musb->clock)
>>                return 0;
>
>Is this check can be deleted also ?
>Because our blackfin platform have no clock support now.

I think this can be removed. 

>Thanks.
>
>> -
>> -       if (musb->set_clock)
>> -               musb->set_clock(musb->clock, 1);
>> -       else
>> -               clk_enable(musb->clock);
>> -
>>        musb_restore_context(musb);
>>
>>        /* for static cmos like DaVinci, register values were 
>preserved
>> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c      
>2010-08-06 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/omap2430.c   2010-08-06 
>10:44:30.093914217 -0400
>> @@ -189,6 +189,19 @@
>>        return 0;
>>  }
>>
>> +int is_musb_active(struct device *dev)
>> +{
>> +       struct musb *musb;
>> +
>> +#ifdef CONFIG_USB_MUSB_HDRC_HCD
>> +       /* usbcore insists dev->driver_data is a "struct hcd *" */
>> +       musb = hcd_to_musb(dev_get_drvdata(dev));
>> +#else
>> +       musb = dev_get_drvdata(dev);
>> +#endif
>> +       return musb->is_active;
>> +}
>> +
>>  int __init musb_platform_init(struct musb *musb)
>>  {
>>        u32 l;
>> @@ -250,6 +263,7 @@
>>        if (is_host_enabled(musb))
>>                musb->board_set_vbus = omap_set_vbus;
>>
>> +       plat->is_usb_active = is_musb_active;
>>        setup_timer(&musb_idle_timer, musb_do_idle, (unsigned 
>long) musb);
>>
>>        return 0;
>> @@ -259,15 +273,42 @@
>>  void musb_platform_save_context(struct musb *musb,
>>                struct musb_context_registers *musb_context)
>>  {
>> -       musb_context->otg_sysconfig = 
>musb_readl(musb->mregs, OTG_SYSCONFIG);
>> -       musb_context->otg_forcestandby = 
>musb_readl(musb->mregs, OTG_FORCESTDBY);
>> +       /*
>> +        * As per the omap-usbotg specification, configure 
>it to forced standby
>> +        * and  force idle mode when no activity on usb.
>> +        */
>> +       void __iomem *musb_base = musb->mregs;
>> +
>> +       musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +                               OTG_SYSCONFIG) & ~(NOSTDBY | 
>SMARTSTDBY));
>> +
>> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +                                       OTG_SYSCONFIG) & 
>~(AUTOIDLE));
>> +
>> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +                               OTG_SYSCONFIG) & ~(NOIDLE | 
>SMARTIDLE));
>> +
>> +       musb_writel(musb_base, OTG_FORCESTDBY, 1);
>>  }
>>
>>  void musb_platform_restore_context(struct musb *musb,
>>                struct musb_context_registers *musb_context)
>>  {
>> -       musb_writel(musb->mregs, OTG_SYSCONFIG, 
>musb_context->otg_sysconfig);
>> -       musb_writel(musb->mregs, OTG_FORCESTDBY, 
>musb_context->otg_forcestandby);
>> +       /*
>> +        * As per the omap-usbotg specification, configure 
>it smart standby
>> +        * and smart idle during operation.
>> +        */
>> +       void __iomem *musb_base = musb->mregs;
>> +
>> +       musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +                               OTG_SYSCONFIG) | (SMARTSTDBY));
>> +
>> +       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +                               OTG_SYSCONFIG) | (SMARTIDLE));
>>  }
>>  #endif
>>
>> Index: linux-omap-pm/include/linux/usb/musb.h
>> ===================================================================
>> --- linux-omap-pm.orig/include/linux/usb/musb.h 2010-08-06 
>09:23:01.161864151 -0400
>> +++ linux-omap-pm/include/linux/usb/musb.h      2010-08-06 
>10:44:06.401862567 -0400
>> @@ -126,6 +126,9 @@
>>
>>        /* Architecture specific board data     */
>>        void            *board_data;
>> +
>> +       /* check usb device active state*/
>> +       int             (*is_usb_active)(struct device *dev);
>>  };
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe 
>linux-usb" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
>-- 
>Regards,
>--Bob
>--
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] 13+ messages in thread

* RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
       [not found]     ` <4C5D7AE5.7040506-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
@ 2010-08-10  7:31       ` Kalliguddi, Hema
  2010-08-10 11:19         ` Sergei Shtylyov
  0 siblings, 1 reply; 13+ messages in thread
From: Kalliguddi, Hema @ 2010-08-10  7:31 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Mankad, Maulik Ojas,
	Felipe Balbi, Tony Lindgren, Kevin Hilman

Hi,

>-----Original Message-----
>From: Sergei Shtylyov [mailto:sshtylyov-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org] 
>Sent: Saturday, August 07, 2010 8:55 PM
>To: Kalliguddi, Hema
>Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; 
>Mankad, Maulik Ojas; Felipe Balbi; Tony Lindgren; Kevin Hilman
>Subject: Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
>
>Hello.
>
>Hema HK wrote:
>
>> With OMAP core-off support musb was not functional as 
>context was getting
>> lost after wakeup from core-off. And also musb was blocking 
>the core-off 
>> after loading the gadget driver even with no cable connected 
>sometimes.
>
>> Added the conext save/restore api in the platform layer which will
>> be called in the idle and wakeup path.
>
>> Changed the usb sysconfig settings as per the usbotg functional spec.
>> When the device is not active, configure to force idle and 
>force standby mode.
>> When it is being used, configure in smart standby and smart 
>idle mode.
>> So while attempting to coreoff the usb is configured to 
>force standby and 
>> force idle mode, after wakeup configured in smart idle and 
>smart standby.
>
>> Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
>> Signed-off-by: Maulik Mankad <x0082077-l0cyMroinI0@public.gmane.org>
>
>> Cc: Felipe Balbi <felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
>> Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
>> Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
>
>[...]
>
>> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	
>2010-08-06 09:24:23.690112596 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	
>2010-08-06 10:44:06.385862697 -0400
>> @@ -120,6 +120,27 @@
>>  	}
>>  }
>>  
>> +void musb_context_save_restore(int save)
>> +{
>> +	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
>> +	struct omap_device *od = oh->od;
>> +	struct platform_device *pdev = &od->pdev;
>> +	struct device *dev = &pdev->dev;
>> +	struct device_driver *drv = dev->driver;
>> +
>> +	if (drv) {
>> +		struct musb_hdrc_platform_data *pdata = 
>dev->platform_data;
>> +		const struct dev_pm_ops *pm = drv->pm;
>
>    Should be an empty line after the declaration block...
Ok.
>
>> +		if (!pdata->is_usb_active(dev)) {
>> +
>> +			if (save)
>> +				pm->suspend(dev);
>> +			else
>> +				pm->resume_noirq(dev);
>> +		}
>> +	}
>> +}
>> +
>>  #else
>>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>  {
>> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	
>2010-08-06 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	
>2010-08-06 10:44:06.369863527 -0400
>> @@ -2427,11 +2427,6 @@
>>  	}
>>  
>>  	musb_save_context(musb);
>> -
>> -	if (musb->set_clock)
>> -		musb->set_clock(musb->clock, 0);
>> -	else
>> -		clk_disable(musb->clock);
>>  	spin_unlock_irqrestore(&musb->lock, flags);
>>  	return 0;
>>  }
>> @@ -2443,12 +2438,6 @@
>>  
>>  	if (!musb->clock)
>>  		return 0;
>> -
>> -	if (musb->set_clock)
>> -		musb->set_clock(musb->clock, 1);
>> -	else
>> -		clk_enable(musb->clock);
>> -
>>  	musb_restore_context(musb);
>
>   The same question again: are you sure that clocks are auto-gated on 
>non-OMAP platfroms?

Bon Lui confirmed that there is no clock for blackfin.

>
>> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	
>2010-08-06 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	
>2010-08-06 10:44:30.093914217 -0400
>[...]
>> @@ -259,15 +273,42 @@
>>  void musb_platform_save_context(struct musb *musb,
>>  		struct musb_context_registers *musb_context)
>>  {
>> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, 
>OTG_SYSCONFIG);
>> -	musb_context->otg_forcestandby = 
>musb_readl(musb->mregs, OTG_FORCESTDBY);
>
>    If you're not saving the registers, you should remove the 
>corresponding 
>fields from 'struct musb_context_registers'.

Agreed. I will remove them from the structure.

>> +	/*
>> +	 * As per the omap-usbotg specification, configure it 
>to forced standby
>> +	 * and  force idle mode when no activity on usb.
>> +	 */
>> +	void __iomem *musb_base = musb->mregs;
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) & ~(NOSTDBY | 
>SMARTSTDBY));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +					OTG_SYSCONFIG) & ~(AUTOIDLE));
>
>    Pointless parens around AUTOIDLE...

Ok. I will remove.

>
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) & ~(NOIDLE | SMARTIDLE));
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 1);
>>  }
>>  
>>  void musb_platform_restore_context(struct musb *musb,
>>  		struct musb_context_registers *musb_context)
>>  {
>> -	musb_writel(musb->mregs, OTG_SYSCONFIG, 
>musb_context->otg_sysconfig);
>> -	musb_writel(musb->mregs, OTG_FORCESTDBY, 
>musb_context->otg_forcestandby);
>> +	/*
>> +	 * As per the omap-usbotg specification, configure it 
>smart standby
>> +	 * and smart idle during operation.
>> +	 */
>> +	void __iomem *musb_base = musb->mregs;
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) | (SMARTSTDBY));
>
>    Pointless parens around SMARTSTDBY...

Ok. I will remove.

>
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) | (SMARTIDLE));
>
>    Pointless parens around SMARTIDLE...

Ok. I will remove.
>
>WBR, Sergei
>
>--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
  2010-08-09 16:43   ` DebBarma, Tarun Kanti
@ 2010-08-10  8:23     ` Kalliguddi, Hema
  2010-08-10 13:53       ` Sergei Shtylyov
  0 siblings, 1 reply; 13+ messages in thread
From: Kalliguddi, Hema @ 2010-08-10  8:23 UTC (permalink / raw)
  To: DebBarma, Tarun Kanti, linux-usb, linux-omap
  Cc: Mankad, Maulik Ojas, Felipe Balbi, Tony Lindgren, Kevin Hilman

 

>-----Original Message-----
>From: DebBarma, Tarun Kanti 
>Sent: Monday, August 09, 2010 10:14 PM
>To: Kalliguddi, Hema; linux-usb@vger.kernel.org; 
>linux-omap@vger.kernel.org
>Cc: Kalliguddi, Hema; Mankad, Maulik Ojas; Felipe Balbi; Tony 
>Lindgren; Kevin Hilman
>Subject: RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
>
>Hema,
>
>> -----Original Message-----
>> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
>> owner@vger.kernel.org] On Behalf Of Hema HK
>> Sent: Friday, August 06, 2010 10:57 PM
>> To: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org
>> Cc: Kalliguddi, Hema; Mankad, Maulik Ojas; Felipe Balbi; 
>Tony Lindgren;
>> Kevin Hilman
>> Subject: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
>> 
>> From: Hema HK  <hemahk@ti.com>
>> 
>> With OMAP core-off support musb was not functional as 
>context was getting
>> lost after wakeup from core-off. And also musb was blocking 
>the core-off
>> after loading the gadget driver even with no cable connected 
>sometimes.
>> 
>> Added the conext save/restore api in the platform layer which will
>> be called in the idle and wakeup path.
>> 
>> Changed the usb sysconfig settings as per the usbotg functional spec.
>> When the device is not active, configure to force idle and 
>force standby
>> mode.
>> When it is being used, configure in smart standby and smart 
>idle mode.
>> So while attempting to coreoff the usb is configured to 
>force standby and
>> force idle mode, after wakeup configured in smart idle and 
>smart standby.
>> 
>> Signed-off-by: Hema HK <hemahk@ti.com>
>> Signed-off-by: Maulik Mankad <x0082077@ti.com>
>> 
>> Cc: Felipe Balbi <felipe.balbi@nokia.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Kevin Hilman <khilman@deeprootsystems.com>
>> ---
>> 
>>  arch/arm/mach-omap2/pm34xx.c          |    4 ++
>>  arch/arm/mach-omap2/usb-musb.c        |   21 ++++++++++++++
>>  arch/arm/plat-omap/include/plat/usb.h |    2 +
>>  drivers/usb/musb/musb_core.c          |   11 -------
>>  drivers/usb/musb/omap2430.c           |   48
>> +++++++++++++++++++++++++++++++---
>>  5 files changed, 71 insertions(+), 15 deletions(-)
>> 
>> Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c	2010-08-06
>> 09:23:01.153862710 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c	2010-08-06
>> 10:44:06.393863125 -0400
>> @@ -39,6 +39,7 @@
>>  #include <plat/gpmc.h>
>>  #include <plat/dma.h>
>>  #include <plat/dmtimer.h>
>> +#include <plat/usb.h>
>> 
>>  #include <asm/tlbflush.h>
>> 
>> @@ -416,6 +417,8 @@
>>  		if (core_next_state == PWRDM_POWER_OFF) {
>>  			omap3_core_save_context();
>>  			omap3_prcm_save_context();
>> +			/* Save MUSB context */
>> +			musb_context_save_restore(1);
>>  		}
>>  	}
>> 
>> @@ -458,6 +461,8 @@
>>  			omap3_prcm_restore_context();
>>  			omap3_sram_restore_context();
>>  			omap2_sms_restore_context();
>> +			/* restore MUSB context */
>> +			musb_context_save_restore(0);
>>  		}
>>  		omap_uart_resume_idle(0);
>>  		omap_uart_resume_idle(1);
>> Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/mach-omap2/usb-musb.c	
>2010-08-06
>> 09:24:23.690112596 -0400
>> +++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c	2010-08-06
>> 10:44:06.385862697 -0400
>> @@ -120,6 +120,27 @@
>>  	}
>>  }
>> 
>> +void musb_context_save_restore(int save)
>> +{
>> +	struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
>Might be good idea to check (oh) before proceeding?
>if (!oh) {
>	/* error message */
>	return;
>}

You are right. I will put a check.

>
>> +	struct omap_device *od = oh->od;
>> +	struct platform_device *pdev = &od->pdev;
>> +	struct device *dev = &pdev->dev;
>> +	struct device_driver *drv = dev->driver;
>> +
>> +	if (drv) {
>> +		struct musb_hdrc_platform_data *pdata = 
>dev->platform_data;
>> +		const struct dev_pm_ops *pm = drv->pm;
>> +		if (!pdata->is_usb_active(dev)) {
>> +
>> +			if (save)
>> +				pm->suspend(dev);
>> +			else
>> +				pm->resume_noirq(dev);
>> +		}
>> +	}
>> +}
>> +
>>  #else
>>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>  {
>> Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
>> ===================================================================
>> --- linux-omap-pm.orig/arch/arm/plat-omap/include/plat/usb.h	2010-08-
>> 06 09:23:01.137862514 -0400
>> +++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h	
>2010-08-06
>> 10:44:06.381864367 -0400
>> @@ -79,6 +79,8 @@
>> 
>>  extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data
>> *pdata);
>> 
>> +/* For saving and restoring the musb context during off/wakeup*/
>> +extern void musb_context_save_restore(int save);
>>  #endif
>> 
>> 
>> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	2010-08-06
>> 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	2010-08-06
>> 10:44:06.369863527 -0400
>> @@ -2427,11 +2427,6 @@
>>  	}
>> 
>>  	musb_save_context(musb);
>> -
>> -	if (musb->set_clock)
>> -		musb->set_clock(musb->clock, 0);
>> -	else
>> -		clk_disable(musb->clock);
>>  	spin_unlock_irqrestore(&musb->lock, flags);
>>  	return 0;
>>  }
>> @@ -2443,12 +2438,6 @@
>> 
>>  	if (!musb->clock)
>>  		return 0;
>> -
>> -	if (musb->set_clock)
>> -		musb->set_clock(musb->clock, 1);
>> -	else
>> -		clk_enable(musb->clock);
>> -
>>  	musb_restore_context(musb);
>> 
>>  	/* for static cmos like DaVinci, register values were preserved
>> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
>> ===================================================================
>> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	2010-08-06
>> 09:24:21.069863329 -0400
>> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	2010-08-06
>> 10:44:30.093914217 -0400
>> @@ -189,6 +189,19 @@
>>  	return 0;
>>  }
>> 
>> +int is_musb_active(struct device *dev)
>> +{
>> +	struct musb *musb;
>> +
>> +#ifdef CONFIG_USB_MUSB_HDRC_HCD
>> +	/* usbcore insists dev->driver_data is a "struct hcd *" */
>> +	musb = hcd_to_musb(dev_get_drvdata(dev));
>> +#else
>> +	musb = dev_get_drvdata(dev);
>> +#endif
>> +	return musb->is_active;
>> +}
>> +
>>  int __init musb_platform_init(struct musb *musb)
>>  {
>>  	u32 l;
>> @@ -250,6 +263,7 @@
>>  	if (is_host_enabled(musb))
>>  		musb->board_set_vbus = omap_set_vbus;
>> 
>> +	plat->is_usb_active = is_musb_active;
>>  	setup_timer(&musb_idle_timer, musb_do_idle, (unsigned 
>long) musb);
>> 
>>  	return 0;
>> @@ -259,15 +273,42 @@
>>  void musb_platform_save_context(struct musb *musb,
>>  		struct musb_context_registers *musb_context)
>>  {
>> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, 
>OTG_SYSCONFIG);
>> -	musb_context->otg_forcestandby = musb_readl(musb->mregs,
>> OTG_FORCESTDBY);
>> +	/*
>> +	 * As per the omap-usbotg specification, configure it to forced
>> standby
>> +	 * and  force idle mode when no activity on usb.
>> +	 */
>> +	void __iomem *musb_base = musb->mregs;
>> +
>Just to clarify, have you already taken care of ioremap() / 
>request_mem_region() for musb_base?
>
>
This is already done.

>> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) & ~(NOSTDBY | 
>SMARTSTDBY));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +					OTG_SYSCONFIG) & ~(AUTOIDLE));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) & ~(NOIDLE | SMARTIDLE));
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 1);
>>  }
>> 
>>  void musb_platform_restore_context(struct musb *musb,
>>  		struct musb_context_registers *musb_context)
>>  {
>> -	musb_writel(musb->mregs, OTG_SYSCONFIG, 
>musb_context->otg_sysconfig);
>> -	musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context-
>> >otg_forcestandby);
>> +	/*
>> +	 * As per the omap-usbotg specification, configure it 
>smart standby
>> +	 * and smart idle during operation.
>> +	 */
>> +	void __iomem *musb_base = musb->mregs;
>> +
>> +	musb_writel(musb_base, OTG_FORCESTDBY, 0);
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) | (SMARTSTDBY));
>> +
>> +	musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
>> +				OTG_SYSCONFIG) | (SMARTIDLE));
>>  }
>>  #endif
>> 
>> Index: linux-omap-pm/include/linux/usb/musb.h
>> ===================================================================
>> --- linux-omap-pm.orig/include/linux/usb/musb.h	2010-08-06
>> 09:23:01.161864151 -0400
>> +++ linux-omap-pm/include/linux/usb/musb.h	2010-08-06 
>10:44:06.401862567
>> -0400
>> @@ -126,6 +126,9 @@
>> 
>>  	/* Architecture specific board data	*/
>>  	void		*board_data;
>> +
>> +	/* check usb device active state*/
>> +	int		(*is_usb_active)(struct device *dev);
>>  };
>> 
>> 
>> --
>> 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] 13+ messages in thread

* Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
  2010-08-10  7:31       ` Kalliguddi, Hema
@ 2010-08-10 11:19         ` Sergei Shtylyov
       [not found]           ` <4C6135D1.2000909-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Sergei Shtylyov @ 2010-08-10 11:19 UTC (permalink / raw)
  To: Kalliguddi, Hema
  Cc: Sergei Shtylyov, linux-usb, linux-omap, Mankad, Maulik Ojas,
	Felipe Balbi, Tony Lindgren, Kevin Hilman

Hello.

Kalliguddi, Hema wrote:

>>> With OMAP core-off support musb was not functional as context was getting
>>> lost after wakeup from core-off. And also musb was blocking the core-off 
>>> after loading the gadget driver even with no cable connected sometimes.

>>> Added the conext save/restore api in the platform layer which will
>>> be called in the idle and wakeup path.
>>> Changed the usb sysconfig settings as per the usbotg functional spec.
>>> When the device is not active, configure to force idle and force standby mode.
>>> When it is being used, configure in smart standby and smart idle mode.
>>> So while attempting to coreoff the usb is configured to force standby and 
>>> force idle mode, after wakeup configured in smart idle and smart standby.

>>> Signed-off-by: Hema HK <hemahk@ti.com>
>>> Signed-off-by: Maulik Mankad <x0082077@ti.com>
>>> Cc: Felipe Balbi <felipe.balbi@nokia.com>
>>> Cc: Tony Lindgren <tony@atomide.com>
>>> Cc: Kevin Hilman <khilman@deeprootsystems.com>

>> [...]

>>> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
>>> ===================================================================
>>> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	
>> 2010-08-06 09:24:21.069863329 -0400
>>> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	
>> 2010-08-06 10:44:06.369863527 -0400
>>> @@ -2427,11 +2427,6 @@
>>>  	}
>>>  
>>>  	musb_save_context(musb);
>>> -
>>> -	if (musb->set_clock)
>>> -		musb->set_clock(musb->clock, 0);
>>> -	else
>>> -		clk_disable(musb->clock);
>>>  	spin_unlock_irqrestore(&musb->lock, flags);
>>>  	return 0;
>>>  }
>>> @@ -2443,12 +2438,6 @@
>>>  
>>>  	if (!musb->clock)
>>>  		return 0;
>>> -
>>> -	if (musb->set_clock)
>>> -		musb->set_clock(musb->clock, 1);
>>> -	else
>>> -		clk_enable(musb->clock);
>>> -
>>>  	musb_restore_context(musb);

>>   The same question again: are you sure that clocks are auto-gated on 
>> non-OMAP platfroms?

> Bon Lui confirmed that there is no clock for blackfin.

    What about DaVinci (and the coming DA8xx)?

WBR, Sergei


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

* RE: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
       [not found]           ` <4C6135D1.2000909-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
@ 2010-08-10 11:59             ` Kalliguddi, Hema
  0 siblings, 0 replies; 13+ messages in thread
From: Kalliguddi, Hema @ 2010-08-10 11:59 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Mankad, Maulik Ojas,
	Felipe Balbi, Tony Lindgren, Kevin Hilman

Hi, 

>-----Original Message-----
>From: Sergei Shtylyov [mailto:sshtylyov-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org] 
>Sent: Tuesday, August 10, 2010 4:50 PM
>To: Kalliguddi, Hema
>Cc: Sergei Shtylyov; linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; 
>linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Mankad, Maulik Ojas; Felipe Balbi; 
>Tony Lindgren; Kevin Hilman
>Subject: Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
>
>Hello.
>
>Kalliguddi, Hema wrote:
>
>>>> With OMAP core-off support musb was not functional as 
>context was getting
>>>> lost after wakeup from core-off. And also musb was 
>blocking the core-off 
>>>> after loading the gadget driver even with no cable 
>connected sometimes.
>
>>>> Added the conext save/restore api in the platform layer which will
>>>> be called in the idle and wakeup path.
>>>> Changed the usb sysconfig settings as per the usbotg 
>functional spec.
>>>> When the device is not active, configure to force idle and 
>force standby mode.
>>>> When it is being used, configure in smart standby and 
>smart idle mode.
>>>> So while attempting to coreoff the usb is configured to 
>force standby and 
>>>> force idle mode, after wakeup configured in smart idle and 
>smart standby.
>
>>>> Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
>>>> Signed-off-by: Maulik Mankad <x0082077-l0cyMroinI0@public.gmane.org>
>>>> Cc: Felipe Balbi <felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
>>>> Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
>>>> Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
>
>>> [...]
>
>>>> Index: linux-omap-pm/drivers/usb/musb/musb_core.c
>>>> ===================================================================
>>>> --- linux-omap-pm.orig/drivers/usb/musb/musb_core.c	
>>> 2010-08-06 09:24:21.069863329 -0400
>>>> +++ linux-omap-pm/drivers/usb/musb/musb_core.c	
>>> 2010-08-06 10:44:06.369863527 -0400
>>>> @@ -2427,11 +2427,6 @@
>>>>  	}
>>>>  
>>>>  	musb_save_context(musb);
>>>> -
>>>> -	if (musb->set_clock)
>>>> -		musb->set_clock(musb->clock, 0);
>>>> -	else
>>>> -		clk_disable(musb->clock);
>>>>  	spin_unlock_irqrestore(&musb->lock, flags);
>>>>  	return 0;
>>>>  }
>>>> @@ -2443,12 +2438,6 @@
>>>>  
>>>>  	if (!musb->clock)
>>>>  		return 0;
>>>> -
>>>> -	if (musb->set_clock)
>>>> -		musb->set_clock(musb->clock, 1);
>>>> -	else
>>>> -		clk_enable(musb->clock);
>>>> -
>>>>  	musb_restore_context(musb);
>
>>>   The same question again: are you sure that clocks are 
>auto-gated on 
>>> non-OMAP platfroms?
>
>> Bon Lui confirmed that there is no clock for blackfin.
>
>    What about DaVinci (and the coming DA8xx)?
>

I checked with Ajay, it is not auto gated for for Davinci so I can't just remove this.

I am thinking of adding a member variable(clk_autogated) in them usb_hdrc_platform_data structure and 
check this in the musb_suspend() And musb_resume() APIs. Do you see any problem with it?

Regards,
Hema



>WBR, Sergei
>
>--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V2 6/8] usb: musb: Offmode fix for idle path
  2010-08-10  8:23     ` Kalliguddi, Hema
@ 2010-08-10 13:53       ` Sergei Shtylyov
  0 siblings, 0 replies; 13+ messages in thread
From: Sergei Shtylyov @ 2010-08-10 13:53 UTC (permalink / raw)
  To: Kalliguddi, Hema
  Cc: DebBarma, Tarun Kanti, linux-usb, linux-omap, Mankad,
	Maulik Ojas, Felipe Balbi, Tony Lindgren, Kevin Hilman

Hello.

Kalliguddi, Hema wrote:

>> Hema,

>>> -----Original Message-----
>>> From: linux-omap-owner@vger.kernel.org [mailto:linux-omap-
>>> owner@vger.kernel.org] On Behalf Of Hema HK
>>> Sent: Friday, August 06, 2010 10:57 PM
>>> To: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org
>>> Cc: Kalliguddi, Hema; Mankad, Maulik Ojas; Felipe Balbi; Tony Lindgren;
>>> Kevin Hilman
>>> Subject: [PATCH V2 6/8] usb: musb: Offmode fix for idle path

>>> From: Hema HK  <hemahk@ti.com>

>>> With OMAP core-off support musb was not functional as context was getting
>>> lost after wakeup from core-off. And also musb was blocking the core-off
>>> after loading the gadget driver even with no cable connected sometimes.

>>> Added the conext save/restore api in the platform layer which will
>>> be called in the idle and wakeup path.

>>> Changed the usb sysconfig settings as per the usbotg functional spec.
>>> When the device is not active, configure to force idle and force standby
>>> mode.
>>> When it is being used, configure in smart standby and smart idle mode.
>>> So while attempting to coreoff the usb is configured to force standby and
>>> force idle mode, after wakeup configured in smart idle and smart standby.

>>> Signed-off-by: Hema HK <hemahk@ti.com>
>>> Signed-off-by: Maulik Mankad <x0082077@ti.com>

>>> Cc: Felipe Balbi <felipe.balbi@nokia.com>
>>> Cc: Tony Lindgren <tony@atomide.com>
>>> Cc: Kevin Hilman <khilman@deeprootsystems.com>

>>> Index: linux-omap-pm/drivers/usb/musb/omap2430.c
>>> ===================================================================
>>> --- linux-omap-pm.orig/drivers/usb/musb/omap2430.c	2010-08-06
>>> 09:24:21.069863329 -0400
>>> +++ linux-omap-pm/drivers/usb/musb/omap2430.c	2010-08-06
>>> 10:44:30.093914217 -0400
[...]
>>> @@ -259,15 +273,42 @@
>>>  void musb_platform_save_context(struct musb *musb,
>>>  		struct musb_context_registers *musb_context)
>>>  {
>>> -	musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
>>> -	musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
>>> +	/*
>>> +	 * As per the omap-usbotg specification, configure it to forced standby
>>> +	 * and  force idle mode when no activity on usb.
>>> +	 */
>>> +	void __iomem *musb_base = musb->mregs;
>>> +

>> Just to clarify, have you already taken care of ioremap() / 
>> request_mem_region() for musb_base?

> This is already done.

    Not quite. MUSB driver doesn't call request_mem_region().

WBR, Sergei

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

end of thread, other threads:[~2010-08-10 13:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-06 17:27 [PATCH V2 6/8] usb: musb: Offmode fix for idle path Hema HK
2010-08-07  2:24 ` Bob Liu
2010-08-10  7:09   ` Kalliguddi, Hema
     [not found] ` <1281115624-1174-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2010-08-07 15:25   ` Sergei Shtylyov
     [not found]     ` <4C5D7AE5.7040506-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-08-10  7:31       ` Kalliguddi, Hema
2010-08-10 11:19         ` Sergei Shtylyov
     [not found]           ` <4C6135D1.2000909-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-08-10 11:59             ` Kalliguddi, Hema
2010-08-09 13:01   ` Cousson, Benoit
2010-08-09 13:12     ` Kalliguddi, Hema
     [not found]       ` <E0D41E29EB0DAC4E9F3FF173962E9E940270943E2D-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-08-09 21:01         ` Kevin Hilman
2010-08-09 16:43   ` DebBarma, Tarun Kanti
2010-08-10  8:23     ` Kalliguddi, Hema
2010-08-10 13:53       ` Sergei Shtylyov

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.