Skip to contentSkip to conversation

usb : musb:Using runtime pm apis for musb.

PATCH In review Hema HK 4 participants 6 messages Aug 6, 2010 – Aug 16, 2010 3 messages not in the archive

Subsystems (7)
lore
Share & tools
lore

Hema HK

author
#0 lore raw

PATCH 8/8 usb : musb:Using runtime pm apis for musb.

From: Hema HK <[email protected]>

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

used omap_hwmod_enable_wakeup & omap_hwmod_disable_wakeup apis to set/clear the wakeup enable bit.
Also need to put the USB in force standby and force idle mode when usb not used and set it back to smart idle and smart stndby after wakeup.
these cases are handled using the oh flags.
For omap3430 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>

---

 arch/arm/mach-omap2/pm34xx.c          |   10 +++-
 arch/arm/mach-omap2/usb-musb.c        |   72 ++++++++++++++++++++++++++++++-
 arch/arm/plat-omap/include/plat/usb.h |    9 +++
 drivers/usb/musb/musb_core.c          |   12 +++++
 drivers/usb/musb/omap2430.c           |   77 +++++-----------------------------
 include/linux/usb/musb.h              |   18 +++++++
 6 files changed, 126 insertions(+), 72 deletions(-)
arch/arm/mach-omap2/pm34xx.c +7 -3
Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
===================================================================
@@ -418,7 +418,9 @@
 			omap3_core_save_context();
 			omap3_prcm_save_context();
 			/* Save MUSB context */
-			musb_context_save_restore(1);
+			musb_context_save_restore(save_context);
+		} else {
+			musb_context_save_restore(disable_clk);
 		}
 	}
 
@@ -462,8 +464,10 @@
 			omap3_sram_restore_context();
 			omap2_sms_restore_context();
 			/* restore MUSB context */
-			musb_context_save_restore(0);
-		}
+			musb_context_save_restore(restore_context);
+		} else {
+			musb_context_save_restore(enable_clk);
+ 		}
 		omap_uart_resume_idle(0);
 		omap_uart_resume_idle(1);
 		if (core_next_state == PWRDM_POWER_OFF)
arch/arm/mach-omap2/usb-musb.c +68 -4

106 lines not on this page · raw message

arch/arm/plat-omap/include/plat/usb.h +8 -1
Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
===================================================================
@@ -71,6 +71,13 @@
 	unsigned extvbus:1;
 };
 
+enum musb_state {
+	save_context = 1,
+	disable_clk,
+	restore_context,
+	enable_clk,
+	};
+
 enum musb_interface    {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
 
 extern void usb_musb_init(struct omap_musb_board_data *board_data);
@@ -80,7 +87,7 @@
 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);
+extern void musb_context_save_restore(enum musb_state state);
 #endif
 
 
drivers/usb/musb/musb_core.c +12 -0
Index: linux-omap-pm/drivers/usb/musb/musb_core.c
===================================================================
@@ -2447,9 +2447,21 @@
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+	return 0;
+}
+
 static const struct dev_pm_ops musb_dev_pm_ops = {
 	.suspend	= musb_suspend,
 	.resume_noirq	= musb_resume_noirq,
+	.runtime_suspend = musb_runtime_suspend,
+	.runtime_resume	 = musb_runtime_resume,
 };
 
 #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)
drivers/usb/musb/omap2430.c +13 -64

136 lines not on this page · raw message

include/linux/usb/musb.h +18 -0
Index: linux-omap-pm/include/linux/usb/musb.h
===================================================================
@@ -10,6 +10,9 @@
 #ifndef __LINUX_USB_MUSB_H
 #define __LINUX_USB_MUSB_H
 
+#include <linux/platform_device.h>
+#include <plat/omap_hwmod.h>
+
 /* The USB role is defined by the connector used on the board, so long as
  * standards are being followed.  (Developer boards sometimes won't.)
  */
@@ -129,6 +132,21 @@
 
 	/* check usb device active state*/
 	int		(*is_usb_active)(struct device *dev);
+
+	/* omap hwmod data structure	 */
+	struct	omap_hwmod *oh;
+
+	/* enable clocks and set sysconfig register*/
+	int		(*device_enable)(struct platform_device *pdev);
+
+	/* Disable clock and reset the sysconfig register settings*/
+	int		(*device_idle)(struct platform_device *pdev);
+
+	/* set the enable wakeup bit of sysconfig register */
+	int		(*enable_wakeup)(struct omap_device *od);
+
+	/* Clear the enable wakeup bit  of sysconfig register */
+	int		(*disable_wakeup)(struct omap_device *od);
 };
 
 

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

A message that is not in the archive (sent off-list or not yet received): 1281115749-1601-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org

#2 lore raw

Hello.

Quoted 15 lines · Hema HK

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

used omap_hwmod_enable_wakeup & omap_hwmod_disable_wakeup apis to set/clear
the wakeup enable bit.
Also need to put the USB in force standby and force idle mode when usb not used
and set it back to smart idle and smart stndby after wakeup.
these cases are handled using the oh flags.
For omap3430 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>

[...]

Quoted 9 lines

Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
===================================================================

arch/arm/mach-omap2/usb-musb.c +0 -0
@@ -129,14 +143,64 @@
 	struct device_driver *drv = dev->driver;
 
 	if (drv) {

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

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +5 -2
+#ifdef CONFIG_PM_RUNTIME
 		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)
+		if (!pdata->is_usb_active(dev)) {
+			switch (state) {
+			case save_context:
+				/* If the usb device not active then Save

Why "usb" not in capitals, while "Save" starts from capital? :-)

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

Quoted 1 line
arch/arm/mach-omap2/usb-musb.c +1 -0
+				 * the context,set the sysconfig setting to

Missing space before "set".

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

Quoted 13 lines
arch/arm/mach-omap2/usb-musb.c +11 -1
+				 * force standby force idle during idle and
+				 * disable the clock.
+				 */
+				oh->flags |= HWMOD_SWSUP_SIDLE
+						| HWMOD_SWSUP_MSTANDBY;
 				pm->suspend(dev);
-			else
+				pdata->device_idle(pdev);
+
+				break;
+			case disable_clk:
+				/* If the usb device not active then
+				 * Save the context, set the sysconfig setting

Same comment about "usb" and "Save"...

Quoted 4 lines
arch/arm/mach-omap2/usb-musb.c +4 -0
+				 * to force standby force idle during idle and
+				 * disable the clock.
+				 */
+

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

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +10 -0
+				oh->flags |= HWMOD_SWSUP_SIDLE
+					| HWMOD_SWSUP_MSTANDBY;
+				pdata->device_idle(pdev);
+
+				break;
+
+			case restore_context:
+				/* Enable the clock, set the sysconfig
+				 * back to smart idle and smart stndby after
+				 * wakeup. restore the context.

Should be "Restore" at the start of sentence, no?

Quoted 4 lines

Index: linux-omap-pm/drivers/usb/musb/omap2430.c
===================================================================

drivers/usb/musb/omap2430.c +0 -0

[...]

drivers/usb/musb/omap2430.c line 214

Quoted 7 lines
drivers/usb/musb/omap2430.c +0 -3
@@ -209,10 +210,6 @@
 	struct musb_hdrc_platform_data *plat = dev->platform_data;
 	struct omap_musb_board_data *data = plat->board_data;
 
-#if defined(CONFIG_ARCH_OMAP2430)
-	omap_cfg_reg(AE5_2430_USB0HS_STP);
-#endif

There's separate patch removing this in Greg's queue:

http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/usb/usb-musb-kill-board-specific-pinmux-from-driver-file.patch

include/linux/usb/musb.h line 13

Quoted 9 lines

Index: linux-omap-pm/include/linux/usb/musb.h
===================================================================

include/linux/usb/musb.h +1 -0
@@ -10,6 +10,9 @@
 #ifndef __LINUX_USB_MUSB_H
 #define __LINUX_USB_MUSB_H
 
+#include <linux/platform_device.h>

You could just use incomplete declaration of 'struct platfrom_device'
instead of this #include.

include/linux/usb/musb.h line 137

Quoted 12 lines
include/linux/usb/musb.h +5 -0
+#include <plat/omap_hwmod.h>
+
 /* The USB role is defined by the connector used on the board, so long as
  * standards are being followed.  (Developer boards sometimes won't.)
  */
@@ -129,6 +132,21 @@
 
 	/* check usb device active state*/
 	int		(*is_usb_active)(struct device *dev);
+
+	/* omap hwmod data structure	 */
+	struct	omap_hwmod *oh;

This should be wrapped into #ifdef, don't you think?

include/linux/usb/musb.h line 149

Quoted 11 lines
include/linux/usb/musb.h +11 -0
+	/* enable clocks and set sysconfig register*/
+	int		(*device_enable)(struct platform_device *pdev);
+
+	/* Disable clock and reset the sysconfig register settings*/
+	int		(*device_idle)(struct platform_device *pdev);
+
+	/* set the enable wakeup bit of sysconfig register */
+	int		(*enable_wakeup)(struct omap_device *od);
+
+	/* Clear the enable wakeup bit  of sysconfig register */
+	int		(*disable_wakeup)(struct omap_device *od);

This should be wrapped too, I think...

WBR, Sergei

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hello.

Quoted 15 lines · I wrote:
Quoted 15 lines

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

used omap_hwmod_enable_wakeup & omap_hwmod_disable_wakeup apis to set/clear
the wakeup enable bit.
Also need to put the USB in force standby and force idle mode when usb not used
and set it back to smart idle and smart stndby after wakeup.
these cases are handled using the oh flags.
For omap3430 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>

[...]

Quoted 10 lines
Quoted 10 lines

Index: linux-omap-pm/include/linux/usb/musb.h
===================================================================
--- linux-omap-pm.orig/include/linux/usb/musb.h 2010-08-06
10:44:06.000000000 -0400
+++ linux-omap-pm/include/linux/usb/musb.h 2010-08-06
10:44:42.946115274 -0400

include/linux/usb/musb.h +0 -0
@@ -10,6 +10,9 @@
 #ifndef __LINUX_USB_MUSB_H
 #define __LINUX_USB_MUSB_H
 
Quoted 6 lines

include/linux/usb/musb.h line 13

Quoted 1 line
include/linux/usb/musb.h +1 -0
+#include <linux/platform_device.h>

You could just use incomplete declaration of 'struct platfrom_device'
instead of this #include.

Quoted 1 line
(quoted diff) +1 -0
+#include <plat/omap_hwmod.h>

Did you think about the other platfroms where this file doesn't exist? How
are they supposed to compile?!
I think this #include needs to be wrapped in #ifdef as well...

Quoted 15 lines

include/linux/usb/musb.h line 137

Quoted 12 lines
(quoted diff) +1 -0
+
 /* The USB role is defined by the connector used on the board, so 

long as
* standards are being followed. (Developer boards sometimes won't.) */

include/linux/usb/musb.h +3 -0
@@ -129,6 +132,21 @@
 
     /* check usb device active state*/
     int        (*is_usb_active)(struct device *dev);
+
+    /* omap hwmod data structure     */
+    struct    omap_hwmod *oh;

This should be wrapped into #ifdef, don't you think?

Quoted 13 lines

include/linux/usb/musb.h line 149

Quoted 11 lines
include/linux/usb/musb.h +11 -0
+    /* enable clocks and set sysconfig register*/
+    int        (*device_enable)(struct platform_device *pdev);
+
+    /* Disable clock and reset the sysconfig register settings*/
+    int        (*device_idle)(struct platform_device *pdev);
+
+    /* set the enable wakeup bit of sysconfig register */
+    int        (*enable_wakeup)(struct omap_device *od);
+
+    /* Clear the enable wakeup bit  of sysconfig register */
+    int        (*disable_wakeup)(struct omap_device *od);

This should be wrapped too, I think...

WBR, Sergei

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Hi,

Quoted 51 lines

-----Original Message-----
From: Sergei Shtylyov [mailto:[email protected]]
Sent: Wednesday, August 11, 2010 5:05 PM
To: Kalliguddi, Hema
Cc: [email protected]; [email protected]; Basak, Partha; Felipe Balbi; Tony Lindgren; Kevin Hilman
Subject: Re: [PATCH 8/8 ]usb : musb:Using runtime pm apis for musb.

Hello.

Quoted 8 lines · I wrote:
Quoted 8 lines

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

used omap_hwmod_enable_wakeup & omap_hwmod_disable_wakeup apis to set/clear
the wakeup enable bit.
Also need to put the USB in force standby and force idle

mode when usb

Quoted 4 lines
Quoted 4 lines

not used
and set it back to smart idle and smart stndby after wakeup. these cases are handled using the oh flags.
For omap3430 auto idle bit has to be disabled because of

the errata.So

Quoted 8 lines
Quoted 8 lines

using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>

[...]

Quoted 10 lines
Quoted 10 lines

Index: linux-omap-pm/include/linux/usb/musb.h
===================================================================
--- linux-omap-pm.orig/include/linux/usb/musb.h 2010-08-06
10:44:06.000000000 -0400
+++ linux-omap-pm/include/linux/usb/musb.h 2010-08-06
10:44:42.946115274 -0400

include/linux/usb/musb.h +0 -0
@@ -10,6 +10,9 @@
 #ifndef __LINUX_USB_MUSB_H
 #define __LINUX_USB_MUSB_H
 
Quoted 3 lines

include/linux/usb/musb.h line 13

Quoted 1 line
include/linux/usb/musb.h +1 -0
+#include <linux/platform_device.h>

You could just use incomplete declaration of 'struct

platfrom_device'

Quoted 8 lines
Quoted 3 lines

instead of this #include.

Quoted 1 line
(quoted diff) +1 -0
+#include <plat/omap_hwmod.h>

Did you think about the other platfroms where this file
doesn't exist? How
are they supposed to compile?!
I think this #include needs to be wrapped in #ifdef as well...

Good point. I did not think of it. It need not be wrapped. Instead I am changing the Enable_wakeup/disable_wakeup parameter to platform_device instead of omap_device. So that I can avoid these includes.

Quoted 30 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +1 -0
+
 /* The USB role is defined by the connector used on the board, so 

long as
* standards are being followed. (Developer boards

sometimes won't.)

Quoted 24 lines

include/linux/usb/musb.h line 137

Quoted 8 lines

*/

include/linux/usb/musb.h +3 -0
@@ -129,6 +132,21 @@
 
     /* check usb device active state*/
     int        (*is_usb_active)(struct device *dev);
+
+    /* omap hwmod data structure     */
+    struct    omap_hwmod *oh;

This should be wrapped into #ifdef, don't you think?

include/linux/usb/musb.h line 149

Quoted 11 lines
include/linux/usb/musb.h +11 -0
+    /* enable clocks and set sysconfig register*/
+    int        (*device_enable)(struct platform_device *pdev);
+
+    /* Disable clock and reset the sysconfig register settings*/
+    int        (*device_idle)(struct platform_device *pdev);
+
+    /* set the enable wakeup bit of sysconfig register */
+    int        (*enable_wakeup)(struct omap_device *od);
+
+    /* Clear the enable wakeup bit  of sysconfig register */
+    int        (*disable_wakeup)(struct omap_device *od);

This should be wrapped too, I think...

It will be taken care.

Quoted 4 lines

WBR, Sergei

--

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

#7 lore raw
In reply to a message not in the archive
Quoted 77 lines · Hema HK

From: Hema HK<[email protected]>

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

used omap_hwmod_enable_wakeup& omap_hwmod_disable_wakeup apis to set/clear the wakeup enable bit.
Also need to put the USB in force standby and force idle mode when usb not used and set it back to smart idle and smart stndby after wakeup.
these cases are handled using the oh flags.
For omap3430 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi<[email protected]>
Cc Tony Lindgren<[email protected]>
Cc Kevin Hilman<[email protected]>

---

  arch/arm/mach-omap2/pm34xx.c          |   10 +++-
  arch/arm/mach-omap2/usb-musb.c        |   72 ++++++++++++++++++++++++++++++-
  arch/arm/plat-omap/include/plat/usb.h |    9 +++
  drivers/usb/musb/musb_core.c          |   12 +++++
  drivers/usb/musb/omap2430.c           |   77 +++++-----------------------------
  include/linux/usb/musb.h              |   18 +++++++
  6 files changed, 126 insertions(+), 72 deletions(-)

Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
===================================================================

arch/arm/mach-omap2/pm34xx.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/pm34xx.c 2010-08-06 10:44:06.000000000 -0400 +7 -3
@@ -418,7 +418,9 @@
                         omap3_core_save_context();
                         omap3_prcm_save_context();
                         /* Save MUSB context */
-                       musb_context_save_restore(1);
+                       musb_context_save_restore(save_context);
+               } else {
+                       musb_context_save_restore(disable_clk);
                 }
         }
 
@@ -462,8 +464,10 @@
                         omap3_sram_restore_context();
                         omap2_sms_restore_context();
                         /* restore MUSB context */
-                       musb_context_save_restore(0);
-               }
+                       musb_context_save_restore(restore_context);
+               } else {
+                       musb_context_save_restore(enable_clk);
+               }
                 omap_uart_resume_idle(0);
                 omap_uart_resume_idle(1);
                 if (core_next_state == PWRDM_POWER_OFF)

Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
===================================================================

arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +2 -0
@@ -25,11 +25,13 @@
  #include<linux/io.h>
 
  #include<linux/usb/musb.h>
+#include<linux/pm_runtime.h>
 
  #include<mach/hardware.h>
  #include<mach/irqs.h>
  #include<plat/usb.h>
  #include<plat/omap_device.h>
+#include<plat/omap_hwmod.h>
 
  #ifdef CONFIG_USB_MUSB_SOC
 
@@ -99,6 +101,18 @@
                 musb_plat.board_data = board_data;

arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 line 111

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +8 -0
                 musb_plat.power = board_data->power>>  1;
                 musb_plat.mode = board_data->mode;
+               musb_plat.device_enable = omap_device_enable;
+               musb_plat.device_idle = omap_device_idle;
+               musb_plat.enable_wakeup = omap_device_enable_wakeup;
+               musb_plat.disable_wakeup = omap_device_disable_wakeup;
+               /*
+                * Errata 1.166 idle_req/ack is broken in omap3430
+                * workaround is to disable the autodile bit for omap3430.
+                */

As written in the errata document: Unique reference to be used for communication, Errata ID: i479. You should not use 1.166. Also the description is a little bit different:
idle_req / idle_ack mechanism potentially broken when autoidle is enabled.
OK, it looks like it can occur randomly during run time, meaning that "potentially" can be probably removed.

In that case, what is the point of the previous patch that separate smartidle and autoidle modification?

arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 line 113

Quoted 2 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +2 -0
+               if (cpu_is_omap3430())
+                       oh->flags |= HWMOD_NO_OCP_AUTOIDLE;

You should not access omap_hwmod structure from here and moreover the flags attribute is a not supposed to be changed dynamically. It is reflecting the capability of the hwmod and should considered as a constant. For that kind of fix, you just have to modified the omap3 hwmod data file.

Quoted 24 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +4 -3
+
+               musb_plat.oh = oh;
                 pdata =&musb_plat;
 
                 od = omap_device_build(name, bus_id, oh, pdata,
@@ -120,7 +134,7 @@
         }
  }
 
-void musb_context_save_restore(int save)
+void musb_context_save_restore(enum musb_state state)
  {
         struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
         struct omap_device *od = oh->od;
@@ -129,14 +143,64 @@
         struct device_driver *drv = dev->driver;
 
         if (drv) {
+#ifdef CONFIG_PM_RUNTIME
                 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)

arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 line 159

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +10 -0
+               if (!pdata->is_usb_active(dev)) {
+                       switch (state) {
+                       case save_context:
+                               /* If the usb device not active then Save
+                                * the context,set the sysconfig setting to
+                                * force standby force idle during idle and
+                                * disable the clock.
+                                */
+                               oh->flags |= HWMOD_SWSUP_SIDLE
+                                               | HWMOD_SWSUP_MSTANDBY;

You should not access this directly. Moreover, since the autoidle is broken, you can just set HWMOD_SWSUP_SIDLE, and that will take care of changing the modes during enable / idle.

Quoted 5 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +3 -1
                                 pm->suspend(dev);
-                       else
+                               pdata->device_idle(pdev);
+
+                               break;

arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 line 173

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +10 -0
+                       case disable_clk:
+                               /* If the usb device not active then
+                                * Save the context, set the sysconfig setting
+                                * to force standby force idle during idle and
+                                * disable the clock.
+                                */
+
+                               oh->flags |= HWMOD_SWSUP_SIDLE
+                                       | HWMOD_SWSUP_MSTANDBY;
+                               pdata->device_idle(pdev);

How is this mode used? What is point of all these different states? Is musb_context_save_restore saving anything in that case?

Quoted 74 lines
arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/mach-omap2/usb-musb.c 2010-08-06 10:44:06.000000000 -0400 +29 -0
+
+                               break;
+
+                       case restore_context:
+                               /* Enable the clock, set the sysconfig
+                                * back to smart idle and smart stndby after
+                                * wakeup. restore the context.
+                                */
+                               oh->flags&= ~(HWMOD_SWSUP_SIDLE
+                                       | HWMOD_SWSUP_MSTANDBY);
+                               pdata->device_enable(pdev);
                                 pm->resume_noirq(dev);
+
+                               break;
+
+                       case enable_clk:
+                               /* Set the sysconfig back to smart
+                                * idle and smart stndby after wakeup and
+                                * enable the clock
+                                */
+                               oh->flags&= ~(HWMOD_SWSUP_SIDLE
+                                       | HWMOD_SWSUP_MSTANDBY);
+                               pdata->device_enable(pdev);
+
+                               break;
+
+                       default:
+                               break;
+                       }
+#endif
                 }
         }
  }

Index: linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h
===================================================================

arch/arm/plat-omap/include/plat/usb.h 2010-08-06 10:44:42.942112875 -0400 renamed from arch/arm/plat-omap/include/plat/usb.h 2010-08-06 10:44:06.000000000 -0400 +8 -1
@@ -71,6 +71,13 @@
         unsigned extvbus:1;
  };
 
+enum musb_state {
+       save_context = 1,
+       disable_clk,
+       restore_context,
+       enable_clk,
+       };
+
  enum musb_interface    {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
 
  extern void usb_musb_init(struct omap_musb_board_data *board_data);
@@ -80,7 +87,7 @@
  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);
+extern void musb_context_save_restore(enum musb_state state);
  #endif
 
 

Index: linux-omap-pm/drivers/usb/musb/musb_core.c
===================================================================

drivers/usb/musb/musb_core.c 2010-08-06 10:44:42.942112875 -0400 renamed from drivers/usb/musb/musb_core.c 2010-08-06 10:44:06.000000000 -0400 +6 -0
@@ -2447,9 +2447,21 @@
         return 0;
  }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+       return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)

drivers/usb/musb/musb_core.c 2010-08-06 10:44:42.942112875 -0400 line 2465

Quoted 10 lines
drivers/usb/musb/musb_core.c 2010-08-06 10:44:42.942112875 -0400 renamed from drivers/usb/musb/musb_core.c 2010-08-06 10:44:06.000000000 -0400 +6 -0
+{
+       return 0;
+}
+
  static const struct dev_pm_ops musb_dev_pm_ops = {
         .suspend        = musb_suspend,
         .resume_noirq   = musb_resume_noirq,
+       .runtime_suspend = musb_runtime_suspend,
+       .runtime_resume  = musb_runtime_resume,
  };

These are probably not needed, considering that they are both empty.

Quoted 101 lines
drivers/usb/musb/musb_core.c 2010-08-06 10:44:42.942112875 -0400 renamed from drivers/usb/musb/musb_core.c 2010-08-06 10:44:06.000000000 -0400 +0 -0
  #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)

Index: linux-omap-pm/drivers/usb/musb/omap2430.c
===================================================================

drivers/usb/musb/omap2430.c 2010-08-06 10:44:42.942112875 -0400 renamed from drivers/usb/musb/omap2430.c 2010-08-06 10:44:30.093914217 -0400 +4 -45
@@ -31,6 +31,7 @@
  #include<linux/list.h>
  #include<linux/clk.h>
  #include<linux/io.h>
+#include<linux/pm_runtime.h>
 
  #include<plat/mux.h>
 
@@ -209,10 +210,6 @@
         struct musb_hdrc_platform_data *plat = dev->platform_data;
         struct omap_musb_board_data *data = plat->board_data;
 
-#if defined(CONFIG_ARCH_OMAP2430)
-       omap_cfg_reg(AE5_2430_USB0HS_STP);
-#endif
-
         /* We require some kind of external transceiver, hooked
          * up through ULPI.  TWL4030-family PMICs include one,
          * which needs a driver, drivers aren't always needed.
@@ -224,22 +221,6 @@
         }
 
         musb_platform_resume(musb);
-
-       l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-       l&= ~ENABLEWAKEUP;     /* disable wakeup */
-       l&= ~NOSTDBY;          /* remove possible nostdby */
-       l |= SMARTSTDBY;        /* enable smart standby */
-       l&= ~AUTOIDLE;         /* disable auto idle */
-       l&= ~NOIDLE;           /* remove possible noidle */
-       l |= SMARTIDLE;         /* enable smart idle */
-       /*
-        * MUSB AUTOIDLE don't work in 3430.
-        * Workaround by Richard Woodruff/TI
-        */
-       if (!cpu_is_omap3430())
-               l |= AUTOIDLE;          /* enable auto idle */
-       musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
         l = musb_readl(musb->mregs, OTG_INTERFSEL);
 
         if (data->interface_type == MUSB_INTERFACE_UTMI) {
@@ -273,48 +254,26 @@
  void musb_platform_save_context(struct musb *musb,
                 struct musb_context_registers *musb_context)
  {
-       /*
-        * 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)
  {
-       /*
-        * 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
 
  static int musb_platform_suspend(struct musb *musb)
  {
         u32 l;
+       struct device *dev = musb->controller;
+       struct musb_hdrc_platform_data *pdata = dev->platform_data;
+       struct omap_hwmod *oh = pdata->oh;
 
         if (!musb->clock)
                 return 0;

drivers/usb/musb/omap2430.c 2010-08-06 10:44:42.942112875 -0400 line 286

Quoted 8 lines
drivers/usb/musb/omap2430.c 2010-08-06 10:44:42.942112875 -0400 renamed from drivers/usb/musb/omap2430.c 2010-08-06 10:44:30.093914217 -0400 +1 -4
@@ -324,16 +283,9 @@
         l |= ENABLEFORCE;       /* enable MSTANDBY */
         musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 
-       l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-       l |= ENABLEWAKEUP;      /* enable wakeup */
-       musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
+       pdata->enable_wakeup(oh->od);

Why do you have to explicitely enable and disable wakeup?

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

#8 lore raw

Hi,

Quoted 109 lines

-----Original Message-----
From: Cousson, Benoit
Sent: Monday, August 09, 2010 7:37 PM
To: Kalliguddi, Hema
Cc: [email protected]; [email protected]; Basak, Partha; Felipe Balbi; Tony Lindgren; Kevin Hilman
Subject: Re: [PATCH 8/8 ]usb : musb:Using runtime pm apis for musb.

Quoted 3 lines · Hema HK

From: Hema HK<[email protected]>

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

used omap_hwmod_enable_wakeup& omap_hwmod_disable_wakeup

apis to set/clear

Quoted 2 lines

the wakeup enable bit.
Also need to put the USB in force standby and force idle

mode when usb not used

Quoted 3 lines

and set it back to smart idle and smart stndby after wakeup. these cases are handled using the oh flags.
For omap3430 auto idle bit has to be disabled because of the

errata.So using

Quoted 5 lines

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Quoted 7 lines
Cc Felipe Balbi<[email protected]>
Cc Tony Lindgren<[email protected]>
Cc Kevin Hilman<[email protected]>

---

  arch/arm/mach-omap2/pm34xx.c          |   10 +++-
  arch/arm/mach-omap2/usb-musb.c        |   72

++++++++++++++++++++++++++++++-

Quoted 3 lines
  arch/arm/plat-omap/include/plat/usb.h |    9 +++
  drivers/usb/musb/musb_core.c          |   12 +++++
  drivers/usb/musb/omap2430.c           |   77

+++++-----------------------------

Quoted 6 lines
  include/linux/usb/musb.h              |   18 +++++++
  6 files changed, 126 insertions(+), 72 deletions(-)

Index: linux-omap-pm/arch/arm/mach-omap2/pm34xx.c
===================================================================
--- linux-omap-pm.orig/arch/arm/mach-omap2/pm34xx.c

2010-08-06 10:44:06.000000000 -0400
Quoted 1 line

+++ linux-omap-pm/arch/arm/mach-omap2/pm34xx.c 2010-08-06

10:44:42.942112875 -0400

Quoted 24 lines
arch/arm/mach-omap2/pm34xx.c +7 -3
@@ -418,7 +418,9 @@
                         omap3_core_save_context();
                         omap3_prcm_save_context();
                         /* Save MUSB context */
-                       musb_context_save_restore(1);
+                       musb_context_save_restore(save_context);
+               } else {
+                       musb_context_save_restore(disable_clk);
                 }
         }
 
@@ -462,8 +464,10 @@
                         omap3_sram_restore_context();
                         omap2_sms_restore_context();
                         /* restore MUSB context */
-                       musb_context_save_restore(0);
-               }
+                       musb_context_save_restore(restore_context);
+               } else {
+                       musb_context_save_restore(enable_clk);
+               }
                 omap_uart_resume_idle(0);
                 omap_uart_resume_idle(1);
                 if (core_next_state == PWRDM_POWER_OFF)
Quoted 3 lines

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 10:44:06.000000000 -0400
Quoted 1 line

+++ linux-omap-pm/arch/arm/mach-omap2/usb-musb.c

2010-08-06 10:44:42.942112875 -0400
Quoted 15 lines
arch/arm/mach-omap2/usb-musb.c +2 -0
@@ -25,11 +25,13 @@
  #include<linux/io.h>
 
  #include<linux/usb/musb.h>
+#include<linux/pm_runtime.h>
 
  #include<mach/hardware.h>
  #include<mach/irqs.h>
  #include<plat/usb.h>
  #include<plat/omap_device.h>
+#include<plat/omap_hwmod.h>
 
  #ifdef CONFIG_USB_MUSB_SOC
 

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

Quoted 7 lines
arch/arm/mach-omap2/usb-musb.c +4 -0
@@ -99,6 +101,18 @@
                 musb_plat.board_data = board_data;
                 musb_plat.power = board_data->power>>  1;
                 musb_plat.mode = board_data->mode;
+               musb_plat.device_enable = omap_device_enable;
+               musb_plat.device_idle = omap_device_idle;
+               musb_plat.enable_wakeup = omap_device_enable_wakeup;
+               musb_plat.disable_wakeup =

omap_device_disable_wakeup;

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

Quoted 3 lines
arch/arm/mach-omap2/usb-musb.c +3 -0
+               /*
+                * Errata 1.166 idle_req/ack is broken in omap3430
+                * workaround is to disable the autodile bit

for omap3430.

Review line 111

Quoted 1 line
(quoted diff) +1 -0
+                */
Quoted 8 lines

As written in the errata document: Unique reference to be used for communication, Errata ID: i479. You should not use 1.166. Also the description is a little bit different:
idle_req / idle_ack mechanism potentially broken when autoidle is enabled.
OK, it looks like it can occur randomly during run time, meaning that "potentially" can be probably removed.

I will update it accordingly.

Quoted 2 lines

In that case, what is the point of the previous patch that separate smartidle and autoidle modification?

This errata is applicable to only OMAP3430. The previous patch required for OMAP4.

Quoted 10 lines

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

Quoted 3 lines
arch/arm/mach-omap2/usb-musb.c +2 -0
+               if (cpu_is_omap3430())
+                       oh->flags |= HWMOD_NO_OCP_AUTOIDLE;

You should not access omap_hwmod structure from here and moreover the flags attribute is a not supposed to be changed dynamically. It is reflecting the capability of the hwmod and should considered as a constant.
For that kind of fix, you just have to modified the omap3 hwmod data file.

Agreed. Thought of it... But did not do it.

Quoted 39 lines
Quoted 16 lines
arch/arm/mach-omap2/usb-musb.c +3 -1
+
+               musb_plat.oh = oh;
                 pdata =&musb_plat;
 
                 od = omap_device_build(name, bus_id, oh, pdata,
@@ -120,7 +134,7 @@
         }
  }
 
-void musb_context_save_restore(int save)
+void musb_context_save_restore(enum musb_state state)
  {
         struct omap_hwmod *oh = omap_hwmod_lookup("usb_otg_hs");
         struct omap_device *od = oh->od;

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

Quoted 5 lines
arch/arm/mach-omap2/usb-musb.c +1 -0
@@ -129,14 +143,64 @@
         struct device_driver *drv = dev->driver;
 
         if (drv) {
+#ifdef CONFIG_PM_RUNTIME
                 struct musb_hdrc_platform_data *pdata =

dev->platform_data;

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

Quoted 8 lines
arch/arm/mach-omap2/usb-musb.c +4 -2
                 const struct dev_pm_ops *pm = drv->pm;
-               if (!pdata->is_usb_active(dev)) {
 
-                       if (save)
+               if (!pdata->is_usb_active(dev)) {
+                       switch (state) {
+                       case save_context:
+                               /* If the usb device not

active then Save

Review line 154

Quoted 1 line
(quoted diff) +1 -0
+                                * the context,set the

sysconfig setting to

Review line 155

Quoted 1 line
(quoted diff) +1 -0
+                                * force standby force idle

during idle and

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

Quoted 4 lines
arch/arm/mach-omap2/usb-musb.c +4 -0
+                                * disable the clock.
+                                */
+                               oh->flags |= HWMOD_SWSUP_SIDLE
+                                               |
Quoted 5 lines

HWMOD_SWSUP_MSTANDBY;

You should not access this directly. Moreover, since the autoidle is broken, you can just set HWMOD_SWSUP_SIDLE, and that will take care of changing the modes during enable / idle.

By setting HWMOD_SWSUP_SIDLE, the enable /idle will set the modes to no-idle and Force-idle. But required setting is smart idle/standby and force idle/standby. Without accessing these flags I will not be able to set force idle/standby and Smart idle/standby using idle/enable functions.

Quoted 19 lines

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

Quoted 9 lines
arch/arm/mach-omap2/usb-musb.c +6 -1
                                 pm->suspend(dev);
-                       else
+                               pdata->device_idle(pdev);
+
+                               break;
+                       case disable_clk:
+                               /* If the usb device not active then
+                                * Save the context, set the

sysconfig setting

Review line 167

Quoted 1 line
(quoted diff) +1 -0
+                                * to force standby force

idle during idle and

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

Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +6 -0
+                                * disable the clock.
+                                */
+
+                               oh->flags |= HWMOD_SWSUP_SIDLE
+                                       | HWMOD_SWSUP_MSTANDBY;
+                               pdata->device_idle(pdev);
Quoted 2 lines

How is this mode used? What is point of all these different states? Is musb_context_save_restore saving anything in that case?

This mode is to just set the sysc setting to force idle/standby and disable the clock. In this state there is no context save. The comment needs correction.

In case save_context: there will will context save, sysconfig settings and disable clock.

Quoted 87 lines

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

Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +5 -0
+
+                               break;
+
+                       case restore_context:
+                               /* Enable the clock, set the

sysconfig

Review line 179

Quoted 1 line
(quoted diff) +1 -0
+                                * back to smart idle and

smart stndby after

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

Quoted 12 lines
arch/arm/mach-omap2/usb-musb.c +11 -0
+                                * wakeup. restore the context.
+                                */
+                               oh->flags&= ~(HWMOD_SWSUP_SIDLE
+                                       | HWMOD_SWSUP_MSTANDBY);
+                               pdata->device_enable(pdev);
                                 pm->resume_noirq(dev);
+
+                               break;
+
+                       case enable_clk:
+                               /* Set the sysconfig back to smart
+                                * idle and smart stndby

after wakeup and

Quoted 15 lines
arch/arm/mach-omap2/usb-musb.c +12 -0
+                                * enable the clock
+                                */
+                               oh->flags&= ~(HWMOD_SWSUP_SIDLE
+                                       | HWMOD_SWSUP_MSTANDBY);
+                               pdata->device_enable(pdev);
+
+                               break;
+
+                       default:
+                               break;
+                       }
+#endif
                 }
         }
  }
Quoted 3 lines

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 10:44:06.000000000 -0400
Quoted 1 line

+++ linux-omap-pm/arch/arm/plat-omap/include/plat/usb.h

2010-08-06 10:44:42.942112875 -0400
Quoted 15 lines
arch/arm/plat-omap/include/plat/usb.h +7 -0
@@ -71,6 +71,13 @@
         unsigned extvbus:1;
  };
 
+enum musb_state {
+       save_context = 1,
+       disable_clk,
+       restore_context,
+       enable_clk,
+       };
+
  enum musb_interface    {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
 
  extern void usb_musb_init(struct omap_musb_board_data *board_data);

arch/arm/plat-omap/include/plat/usb.h line 87

Quoted 1 line
arch/arm/plat-omap/include/plat/usb.h +0 -0
@@ -80,7 +87,7 @@
  extern void usb_ohci_init(const struct

ohci_hcd_omap_platform_data *pdata);

Quoted 10 lines
arch/arm/plat-omap/include/plat/usb.h +1 -1
  /* For saving and restoring the musb context during off/wakeup*/
-extern void musb_context_save_restore(int save);
+extern void musb_context_save_restore(enum musb_state state);
  #endif
 
 

Index: linux-omap-pm/drivers/usb/musb/musb_core.c
===================================================================
--- linux-omap-pm.orig/drivers/usb/musb/musb_core.c

2010-08-06 10:44:06.000000000 -0400
Quoted 1 line

+++ linux-omap-pm/drivers/usb/musb/musb_core.c 2010-08-06

10:44:42.942112875 -0400

Quoted 14 lines
drivers/usb/musb/musb_core.c +10 -0
@@ -2447,9 +2447,21 @@
         return 0;
  }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+       return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+       return 0;
+}
+
Quoted 8 lines

drivers/usb/musb/musb_core.c line 2465

Quoted 6 lines
drivers/usb/musb/musb_core.c +2 -0
  static const struct dev_pm_ops musb_dev_pm_ops = {
         .suspend        = musb_suspend,
         .resume_noirq   = musb_resume_noirq,
+       .runtime_suspend = musb_runtime_suspend,
+       .runtime_resume  = musb_runtime_resume,
  };

These are probably not needed, considering that they are both empty.

Agreed.

Quoted 112 lines
Quoted 6 lines
drivers/usb/musb/musb_core.c +0 -0
  #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)

Index: linux-omap-pm/drivers/usb/musb/omap2430.c
===================================================================
--- linux-omap-pm.orig/drivers/usb/musb/omap2430.c

2010-08-06 10:44:30.093914217 -0400
Quoted 1 line

+++ linux-omap-pm/drivers/usb/musb/omap2430.c 2010-08-06

10:44:42.942112875 -0400

Quoted 43 lines
drivers/usb/musb/omap2430.c +1 -20
@@ -31,6 +31,7 @@
  #include<linux/list.h>
  #include<linux/clk.h>
  #include<linux/io.h>
+#include<linux/pm_runtime.h>
 
  #include<plat/mux.h>
 
@@ -209,10 +210,6 @@
         struct musb_hdrc_platform_data *plat = dev->platform_data;
         struct omap_musb_board_data *data = plat->board_data;
 
-#if defined(CONFIG_ARCH_OMAP2430)
-       omap_cfg_reg(AE5_2430_USB0HS_STP);
-#endif
-
         /* We require some kind of external transceiver, hooked
          * up through ULPI.  TWL4030-family PMICs include one,
          * which needs a driver, drivers aren't always needed.
@@ -224,22 +221,6 @@
         }
 
         musb_platform_resume(musb);
-
-       l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-       l&= ~ENABLEWAKEUP;     /* disable wakeup */
-       l&= ~NOSTDBY;          /* remove possible nostdby */
-       l |= SMARTSTDBY;        /* enable smart standby */
-       l&= ~AUTOIDLE;         /* disable auto idle */
-       l&= ~NOIDLE;           /* remove possible noidle */
-       l |= SMARTIDLE;         /* enable smart idle */
-       /*
-        * MUSB AUTOIDLE don't work in 3430.
-        * Workaround by Richard Woodruff/TI
-        */
-       if (!cpu_is_omap3430())
-               l |= AUTOIDLE;          /* enable auto idle */
-       musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
         l = musb_readl(musb->mregs, OTG_INTERFSEL);
 
         if (data->interface_type == MUSB_INTERFACE_UTMI) {

drivers/usb/musb/omap2430.c line 277

Quoted 5 lines
drivers/usb/musb/omap2430.c +0 -2
@@ -273,48 +254,26 @@
  void musb_platform_save_context(struct musb *musb,
                 struct musb_context_registers *musb_context)
  {
-       /*
-        * As per the omap-usbotg specification, configure

it to forced standby

drivers/usb/musb/omap2430.c

Quoted 8 lines
drivers/usb/musb/omap2430.c +0 -6
-        * 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));

drivers/usb/musb/omap2430.c

Quoted 3 lines
drivers/usb/musb/omap2430.c +0 -3
-
-       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
-                                       OTG_SYSCONFIG)&

~(AUTOIDLE));

drivers/usb/musb/omap2430.c

Quoted 3 lines
drivers/usb/musb/omap2430.c +0 -3
-
-       musb_writel(musb_base, OTG_SYSCONFIG, musb_readl(musb_base,
-                               OTG_SYSCONFIG)&  ~(NOIDLE |

SMARTIDLE));

drivers/usb/musb/omap2430.c

Quoted 9 lines
drivers/usb/musb/omap2430.c +0 -3
-
         musb_writel(musb_base, OTG_FORCESTDBY, 1);
  }
 
  void musb_platform_restore_context(struct musb *musb,
                 struct musb_context_registers *musb_context)
  {
-       /*
-        * As per the omap-usbotg specification, configure

it smart standby

Quoted 27 lines
drivers/usb/musb/omap2430.c +3 -8
-        * 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
 
  static int musb_platform_suspend(struct musb *musb)
  {
         u32 l;
+       struct device *dev = musb->controller;
+       struct musb_hdrc_platform_data *pdata = dev->platform_data;
+       struct omap_hwmod *oh = pdata->oh;
 
         if (!musb->clock)
                 return 0;
@@ -324,16 +283,9 @@
         l |= ENABLEFORCE;       /* enable MSTANDBY */
         musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 
Quoted 7 lines

drivers/usb/musb/omap2430.c line 286

Quoted 5 lines
drivers/usb/musb/omap2430.c +1 -4
-       l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-       l |= ENABLEWAKEUP;      /* enable wakeup */
-       musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
+       pdata->enable_wakeup(oh->od);

Why do you have to explicitely enable and disable wakeup?

Existing code was doing this. I just migrated to use new APIs But I will check why is this needed.

Rehards,
Hema

Quoted 3 lines

Benoit