All of lore.kernel.org
 help / color / mirror / Atom feed
* Subject: [PATCH 0/5 v5]usb: musb: hwmod and runtime pm support for musb
@ 2010-12-10 14:35 Hema HK
  2010-12-10 14:35 ` [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation " Hema HK
       [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  0 siblings, 2 replies; 19+ messages in thread
From: Hema HK @ 2010-12-10 14:35 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-omap, Hema HK, Felipe Balbi, Tony Lindgren, Kevin Hilman,
	Cousson, Benoit, Paul Walmsley

This patch series makes OMAP2PLUS musb module implemented
in HWMOD FW way. It also implements musb driver to
use the runtime pm apis.

As per the OMAP usbotg specification[1] musb sysconfig register
has to be set to force idle and force standby when not used
and set smart idle/standby or no idle/standby during operation.
otherwise core-off will be prevented by musb.

[1]: http://focus.ti.com/pdfs/wtbu/SWPU223D_Final_EPDF_06_07_2010.pdf

This patch series is based on V2.6.37-rc4 + [2]+[3]+[4]

[2] http://www.listware.net/201011/linux-usb/
65625-patch-resend-v3-usb-musb-do-not-use-dma-for-control-transfers.html

[3] Felipe's musb-reorg patch series.
	http://gitorious.org/usb/usb/commits/musb-hw
	
[4] usb: otg: TWL6030: OMAP4430: musb & transceiver driver support
	for OMAP4 posted by me.

with this patch series tested musb functionality like testusb, masstorage
OMAP4430SDP, OMAP3630 zoom3, OMAP3430 SDP

Power management tests like retention and offmode validation tests are not
done with these patches.
There will be another set of patches submitted with PM on musb.

Version History:
---------------
Version V5:

Fixed review comments from Felipe.


Version V4:

Rebased the changes based on the re-orgnized patches submitted by Felipe.
Fixed review comments received for V3.
Dropped the idlepath  power management patch with this series.

Some of the links for V3 review comments:

https://patchwork.kernel.org/patch/199482/
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35488.html
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg33201.html
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg35387.html

Version V3

Added the patch for adding the hwmod database for OMAP2430.
Re-arranged the patches in such a way that first migrate the musb driver
to use the runtime PM apis and then added a patch to support offmode in idle path.
Calling the runtime PM apis before disbaling the interupts in the idle path.
Added the #ifdef CONFIG_PM_RUNTIME  check in the musb core driver for calling 
the runtime PM APIs as non-omap platforms may not have the runtime pm enabled
and clk_enable/disable should be called for them.

Optimized the context save restore of musb registers only if the next state is
going to offmode and previous state was offmode.

Some of the links for V2 review comments
----------------------------------------
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg34068.html
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32024.html
http://www.spinics.net/lists/linux-usb/msg35562.html
http://www.spinics.net/lists/linux-usb/msg35720.html

Vesrion v2:

Fixed review comments.
Removed the omap_hwmod.h inclusion from musb.h file which was 
breaking the non-omap platform build.
Using the runtime pm apis in the idle path(interrupts disabled).
Added the omap4 hwmod data base.

Version v1:
initial version of the patch series.

Some of the links for v1
------------------------

http://www.spinics.net/lists/linux-usb/msg34570.html
http://www.spinics.net/lists/linux-omap/msg34568.html
http://www.spinics.net/lists/linux-usb/msg34544.html
http://www.spinics.net/lists/linux-usb/msg34540.html
http://www.spinics.net/lists/linux-usb/msg34589.html
http://www.spinics.net/lists/linux-usb/msg34554.html
http://www.mail-archive.com/linux-omap@vger.kernel.org/msg32973.html

Signed-off-by: Hema HK <hemahk@ti.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Cousson, Benoit <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
---

Cousson, Benoit (1):
   OMAP4430: hwmod data: Adding USBOTG

Hema HK (4):
  OMAP2430: hwmod data: Add USBOTG
  OMAP3xxx: hwmod data: Add USBOTG
  OMAP2+: musb: HWMOD adaptation for musb.
  usb: musb: Using runtime pm APIs for musb.

  arch/arm/mach-omap2/omap_hwmod_2430_data.c |   97 +++++++++++++++++++++++++++
  arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  100 ++++++++++++++++++++++++++++
  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   94 ++++++++++++++++++++++++++
  arch/arm/mach-omap2/usb-musb.c             |   66 ++++++++++++++----
  drivers/usb/musb/musb_core.h               |    2 +-
  drivers/usb/musb/omap2430.c                |   77 +++++----------------
  6 files changed, 362 insertions(+), 74 deletions(-)

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

* [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG
       [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
@ 2010-12-10 14:35   ` Hema HK
       [not found]     ` <1291991739-21705-2-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2010-12-10 14:35   ` [PATCH 2/5 v5] OMAP3xxx: " Hema HK
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Hema HK @ 2010-12-10 14:35 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, Hema HK, Felipe Balbi,
	Tony Lindgren, Kevin Hilman, Cousson, Benoit, Paul Walmsley

OMAP2430 hwmod data structures are populated with base address, L3 and L4
interface clocks, IRQs and sysconfig register details.

As per OMAP USBOTG specification, need to configure the USBOTG
to smart idle/standby or no idle/standby during data transfer and
force idle/standby when not in use to support retention and off-mode.
By setting HWMOD_SWSUP_SIDLE and HWMOD_SWSUP_MSTANDBY flags, framework
will take care of configuring to no idle/standby when module is enabled
and force idle/standby when suspended.

Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   97 +++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)

Index: usb/arch/arm/mach-omap2/omap_hwmod_2430_data.c
===================================================================
--- usb.orig/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ usb/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -77,6 +77,15 @@ static struct omap_hwmod omap2430_l4_wku
 static struct omap_hwmod omap2430_uart1_hwmod;
 static struct omap_hwmod omap2430_uart2_hwmod;
 static struct omap_hwmod omap2430_uart3_hwmod;
+static struct omap_hwmod omap2430_usbhsotg_hwmod;
+
+/* l3_core -> usbhsotg  interface */
+static struct omap_hwmod_ocp_if omap2430_usbhsotg__l3 = {
+	.master		= &omap2430_usbhsotg_hwmod,
+	.slave		= &omap2430_l3_main_hwmod,
+	.clk		= "core_l3_ck",
+	.user		= OCP_USER_MPU,
+};
 
 /* L4_CORE -> L4_WKUP interface */
 static struct omap_hwmod_ocp_if omap2430_l4_core__l4_wkup = {
@@ -139,6 +148,35 @@ static struct omap_hwmod_ocp_if omap2_l4
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/*
+* usbhsotg interface data
+*/
+static struct omap_hwmod_addr_space omap2430_usbhsotg_addrs[] = {
+	{
+		.pa_start	= OMAP243X_HS_BASE,
+		.pa_end		= OMAP243X_HS_BASE + SZ_4K - 1,
+		.flags		= ADDR_TYPE_RT
+	},
+};
+
+/*  l4_core ->usbhsotg  interface */
+static struct omap_hwmod_ocp_if omap2430_l4_core__usbhsotg = {
+	.master		= &omap2430_l4_core_hwmod,
+	.slave		= &omap2430_usbhsotg_hwmod,
+	.clk		= "usb_l4_ick",
+	.addr		= omap2430_usbhsotg_addrs,
+	.addr_cnt	= ARRAY_SIZE(omap2430_usbhsotg_addrs),
+	.user		= OCP_USER_MPU,
+};
+
+static struct omap_hwmod_ocp_if *omap2430_usbhsotg_masters[] = {
+	&omap2430_usbhsotg__l3,
+};
+
+static struct omap_hwmod_ocp_if *omap2430_usbhsotg_slaves[] = {
+	&omap2430_l4_core__usbhsotg,
+};
+
 /* Slave interfaces on the L4_CORE interconnect */
 static struct omap_hwmod_ocp_if *omap2430_l4_core_slaves[] = {
 	&omap2430_l3_main__l4_core,
@@ -418,6 +456,62 @@ static struct omap_hwmod omap2430_uart3_
 	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
 };
 
+/*
+ * usbhsotg
+ */
+static struct omap_hwmod_class_sysconfig omap2430_usbhsotg_sysc = {
+	.rev_offs	= 0x0400,
+	.sysc_offs	= 0x0404,
+	.syss_offs	= 0x0408,
+	.sysc_flags	= (SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE|
+			  SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
+			  SYSC_HAS_AUTOIDLE),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			  MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class usbotg_class = {
+	.name = "usbotg",
+	.sysc = &omap2430_usbhsotg_sysc,
+};
+
+/* usb_otg_hs */
+static struct omap_hwmod_irq_info omap2430_usbhsotg_mpu_irqs[] = {
+
+	{ .name = "mc", .irq = 92 },
+	{ .name = "dma", .irq = 93 },
+};
+
+static struct omap_hwmod omap2430_usbhsotg_hwmod = {
+	.name		= "usb_otg_hs",
+	.mpu_irqs	= omap2430_usbhsotg_mpu_irqs,
+	.mpu_irqs_cnt	= ARRAY_SIZE(omap2430_usbhsotg_mpu_irqs),
+	.main_clk	= "usbhs_ick",
+	.prcm		= {
+		.omap2 = {
+			.prcm_reg_id = 1,
+			.module_bit = OMAP2430_EN_USBHS_MASK,
+			.module_offs = CORE_MOD,
+			.idlest_reg_id = 1,
+			.idlest_idle_bit = OMAP2430_ST_USBHS_SHIFT,
+		},
+	},
+	.masters	= omap2430_usbhsotg_masters,
+	.masters_cnt	= ARRAY_SIZE(omap2430_usbhsotg_masters),
+	.slaves		= omap2430_usbhsotg_slaves,
+	.slaves_cnt	= ARRAY_SIZE(omap2430_usbhsotg_slaves),
+	.class		= &usbotg_class,
+	/*
+	 * Erratum ID: i479  idle_req / idle_ack mechanism potentially
+	 * broken when autoidle is enabled
+	 * workaround is to disable the autoidle bit at module level.
+	 */
+	.flags		= HWMOD_NO_OCP_AUTOIDLE | HWMOD_SWSUP_SIDLE
+				| HWMOD_SWSUP_MSTANDBY,
+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP2430)
+};
+
 static __initdata struct omap_hwmod *omap2430_hwmods[] = {
 	&omap2430_l3_main_hwmod,
 	&omap2430_l4_core_hwmod,
@@ -428,6 +522,9 @@ static __initdata struct omap_hwmod *oma
 	&omap2430_uart1_hwmod,
 	&omap2430_uart2_hwmod,
 	&omap2430_uart3_hwmod,
+
+	/* usbotg class*/
+	&omap2430_usbhsotg_hwmod,
 	NULL,
 };
 
--
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] 19+ messages in thread

* [PATCH 2/5 v5] OMAP3xxx: hwmod data: Add USBOTG
       [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2010-12-10 14:35   ` [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG Hema HK
@ 2010-12-10 14:35   ` Hema HK
       [not found]     ` <1291991739-21705-3-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2010-12-10 14:35   ` [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG Hema HK
  2010-12-10 14:35   ` [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb Hema HK
  3 siblings, 1 reply; 19+ messages in thread
From: Hema HK @ 2010-12-10 14:35 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, Hema HK, Felipe Balbi,
	Tony Lindgren, Kevin Hilman, Cousson, Benoit, Paul Walmsley

OMAP3 hwmod data structures are populated for USBOTG with base address,
L3 and L4 interface clocks, IRQs and sysconfig register details.

As per OMAP USBOTG specification, need to configure the USBOTG
to smart idle/standby or no idle/standby during data transfer and
force idle/standby when not in use to support retention and offmode.
By setting HWMOD_SWSUP_SIDLE and HWMOD_SWSUP_MSTANDBY flags, framework
will take care of configuring to no idle/standby when module is enabled
and force idle/standby when idled.

Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  100 +++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)

Index: usb/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
===================================================================
--- usb.orig/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ usb/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -89,6 +89,15 @@ static struct omap_hwmod omap3xxx_uart1_
 static struct omap_hwmod omap3xxx_uart2_hwmod;
 static struct omap_hwmod omap3xxx_uart3_hwmod;
 static struct omap_hwmod omap3xxx_uart4_hwmod;
+static struct omap_hwmod omap3xxx_usbhsotg_hwmod;
+
+/* l3_core -> usbhsotg interface */
+static struct omap_hwmod_ocp_if omap3xxx_usbhsotg__l3 = {
+	.master		= &omap3xxx_usbhsotg_hwmod,
+	.slave		= &omap3xxx_l3_main_hwmod,
+	.clk		= "core_l3_ick",
+	.user		= OCP_USER_MPU,
+};
 
 /* L4_CORE -> L4_WKUP interface */
 static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = {
@@ -169,6 +178,36 @@ static struct omap_hwmod_ocp_if omap3_l4
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/*
+* usbhsotg interface data
+*/
+
+static struct omap_hwmod_addr_space omap3xxx_usbhsotg_addrs[] = {
+	{
+		.pa_start	= OMAP34XX_HSUSB_OTG_BASE,
+		.pa_end		= OMAP34XX_HSUSB_OTG_BASE + SZ_4K - 1,
+		.flags		= ADDR_TYPE_RT
+	},
+};
+
+/* l4_core -> usbhsotg  */
+static struct omap_hwmod_ocp_if omap3xxx_l4_core__usbhsotg = {
+	.master		= &omap3xxx_l4_core_hwmod,
+	.slave		= &omap3xxx_usbhsotg_hwmod,
+	.clk		= "l4_ick",
+	.addr		= omap3xxx_usbhsotg_addrs,
+	.addr_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_addrs),
+	.user		= OCP_USER_MPU,
+};
+
+static struct omap_hwmod_ocp_if *omap3xxx_usbhsotg_masters[] = {
+	&omap3xxx_usbhsotg__l3,
+};
+
+static struct omap_hwmod_ocp_if *omap3xxx_usbhsotg_slaves[] = {
+	&omap3xxx_l4_core__usbhsotg,
+};
+
 /* Slave interfaces on the L4_CORE interconnect */
 static struct omap_hwmod_ocp_if *omap3xxx_l4_core_slaves[] = {
 	&omap3xxx_l3_main__l4_core,
@@ -509,6 +548,64 @@ static struct omap_hwmod omap3xxx_uart4_
 	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP3630ES1),
 };
 
+/*
+ * usbhsotg
+ */
+static struct omap_hwmod_class_sysconfig omap3xxx_usbhsotg_sysc = {
+	.rev_offs	= 0x0400,
+	.sysc_offs	= 0x0404,
+	.syss_offs	= 0x0408,
+	.sysc_flags	= (SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE|
+			  SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
+			  SYSC_HAS_AUTOIDLE),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			  MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class usbotg_class = {
+	.name = "usbotg",
+	.sysc = &omap3xxx_usbhsotg_sysc,
+};
+
+/* usb_otg_hs */
+static struct omap_hwmod_irq_info omap3xxx_usbhsotg_mpu_irqs[] = {
+
+	{ .name = "mc", .irq = 92 },
+	{ .name = "dma", .irq = 93 },
+};
+
+static struct omap_hwmod omap3xxx_usbhsotg_hwmod = {
+	.name		= "usb_otg_hs",
+	.mpu_irqs	= omap3xxx_usbhsotg_mpu_irqs,
+	.mpu_irqs_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_mpu_irqs),
+	.main_clk	= "hsotgusb_ick",
+	.prcm		= {
+		.omap2 = {
+			.prcm_reg_id = 1,
+			.module_bit = OMAP3430_EN_HSOTGUSB_SHIFT,
+			.module_offs = CORE_MOD,
+			.idlest_reg_id = 1,
+			.idlest_idle_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT,
+			.idlest_stdby_bit = OMAP3430ES2_ST_HSOTGUSB_STDBY_SHIFT
+		},
+	},
+	.masters	= omap3xxx_usbhsotg_masters,
+	.masters_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_masters),
+	.slaves		= omap3xxx_usbhsotg_slaves,
+	.slaves_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_slaves),
+	.class		= &usbotg_class,
+
+	/*
+	 * Erratum ID: i479  idle_req / idle_ack mechanism potentially
+	 * broken when autoidle is enabled
+	 * workaround is to disable the autoidle bit at module level.
+	 */
+	.flags		= HWMOD_NO_OCP_AUTOIDLE | HWMOD_SWSUP_SIDLE
+				| HWMOD_SWSUP_MSTANDBY,
+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
+};
+
 static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
 	&omap3xxx_l3_main_hwmod,
 	&omap3xxx_l4_core_hwmod,
@@ -521,6 +618,9 @@ static __initdata struct omap_hwmod *oma
 	&omap3xxx_uart2_hwmod,
 	&omap3xxx_uart3_hwmod,
 	&omap3xxx_uart4_hwmod,
+
+	/* usbotg class */
+	&omap3xxx_usbhsotg_hwmod,
 	NULL,
 };
 
--
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] 19+ messages in thread

* [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG
       [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2010-12-10 14:35   ` [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG Hema HK
  2010-12-10 14:35   ` [PATCH 2/5 v5] OMAP3xxx: " Hema HK
@ 2010-12-10 14:35   ` Hema HK
  2011-02-03  5:55     ` Hema Kalliguddi
  2010-12-10 14:35   ` [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb Hema HK
  3 siblings, 1 reply; 19+ messages in thread
From: Hema HK @ 2010-12-10 14:35 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, Cousson, Benoit, Hema HK,
	Felipe Balbi, Tony Lindgren, Kevin Hilman, Paul Walmsley

From: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>

OMAP4 hwmod data structures are populated with base address, L3 and L4
interface clocks, IRQs and sysconfig register details.

As per OMAP USBOTG specification, need to configure the USBOTG
to smart idle/standby or no idle/standby during data transfer and
force idle/standby when not in use to support retention and offmode.
By setting HWMOD_SWSUP_SIDLE and HWMOD_SWSUP_MSTANDBY flags,framework
will take care of configuring to no idle/standby when module is enabled
and force idle/standby when idled.

Signed-off-by: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   94 +++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

Index: usb/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
===================================================================
--- usb.orig/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ usb/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -47,6 +47,7 @@ static struct omap_hwmod omap44xx_l4_per
 static struct omap_hwmod omap44xx_l4_wkup_hwmod;
 static struct omap_hwmod omap44xx_mpu_hwmod;
 static struct omap_hwmod omap44xx_mpu_private_hwmod;
+static struct omap_hwmod omap44xx_usb_otg_hs_hwmod;
 
 /*
  * Interconnects omap_hwmod structures
@@ -223,10 +224,19 @@ static struct omap_hwmod_ocp_if omap44xx
 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
 };
 
+/* usb_otg_hs -> l3_main_2 */
+static struct omap_hwmod_ocp_if omap44xx_usb_otg_hs__l3_main_2 = {
+	.master		= &omap44xx_usb_otg_hs_hwmod,
+	.slave		= &omap44xx_l3_main_2_hwmod,
+	.clk		= "l3_div_ck",
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
 /* l3_main_2 slave ports */
 static struct omap_hwmod_ocp_if *omap44xx_l3_main_2_slaves[] = {
 	&omap44xx_l3_main_1__l3_main_2,
 	&omap44xx_l4_cfg__l3_main_2,
+	&omap44xx_usb_otg_hs__l3_main_2,
 };
 
 static struct omap_hwmod omap44xx_l3_main_2_hwmod = {
@@ -811,6 +821,87 @@ static struct omap_hwmod omap44xx_uart4_
 	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
 };
 
+/*
+ * 'usb_otg_hs' class
+ * high-speed on-the-go universal serial bus (usb_otg_hs) controller
+ */
+
+static struct omap_hwmod_class_sysconfig omap44xx_usb_otg_hs_sysc = {
+	.rev_offs	= 0x0400,
+	.sysc_offs	= 0x0404,
+	.syss_offs	= 0x0408,
+	.sysc_flags	= (SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE|
+			  SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
+			  SYSC_HAS_AUTOIDLE),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			  MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART),
+	.sysc_fields	= &omap_hwmod_sysc_type1,
+};
+
+static struct omap_hwmod_class omap44xx_usb_otg_hs_hwmod_class = {
+	.name = "usb_otg_hs",
+	.sysc = &omap44xx_usb_otg_hs_sysc,
+};
+
+/* usb_otg_hs */
+static struct omap_hwmod_irq_info omap44xx_usb_otg_hs_irqs[] = {
+	{ .name = "mc", .irq = 92 + OMAP44XX_IRQ_GIC_START },
+	{ .name = "dma", .irq = 93 + OMAP44XX_IRQ_GIC_START },
+};
+
+/* usb_otg_hs master ports */
+static struct omap_hwmod_ocp_if *omap44xx_usb_otg_hs_masters[] = {
+	&omap44xx_usb_otg_hs__l3_main_2,
+};
+
+static struct omap_hwmod_addr_space omap44xx_usb_otg_hs_addrs[] = {
+	{
+		.pa_start	= OMAP44XX_HSUSB_OTG_BASE,
+		.pa_end		= OMAP44XX_HSUSB_OTG_BASE + SZ_4K - 1,
+		.flags		= ADDR_TYPE_RT
+	},
+};
+
+/* l4_cfg -> usb_otg_hs */
+static struct omap_hwmod_ocp_if omap44xx_l4_cfg__usb_otg_hs = {
+	.master		= &omap44xx_l4_cfg_hwmod,
+	.slave		= &omap44xx_usb_otg_hs_hwmod,
+	.clk		= "l4_div_ck",
+	.addr		= omap44xx_usb_otg_hs_addrs,
+	.addr_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_addrs),
+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+/* usb_otg_hs slave ports */
+static struct omap_hwmod_ocp_if *omap44xx_usb_otg_hs_slaves[] = {
+	&omap44xx_l4_cfg__usb_otg_hs,
+};
+
+static struct omap_hwmod_opt_clk usb_otg_hs_opt_clks[] = {
+	{ .role = "xclk", .clk = "otg_60m_gfclk_ck" },
+};
+
+static struct omap_hwmod omap44xx_usb_otg_hs_hwmod = {
+	.name		= "usb_otg_hs",
+	.class		= &omap44xx_usb_otg_hs_hwmod_class,
+	.mpu_irqs	= omap44xx_usb_otg_hs_irqs,
+	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_irqs),
+	.main_clk	= "usb_otg_hs_ick",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_reg = OMAP4430_CM_L3INIT_USB_OTG_CLKCTRL,
+		},
+	},
+	.opt_clks	= usb_otg_hs_opt_clks,
+	.opt_clks_cnt = ARRAY_SIZE(usb_otg_hs_opt_clks),
+	.slaves		= omap44xx_usb_otg_hs_slaves,
+	.slaves_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_slaves),
+	.masters	= omap44xx_usb_otg_hs_masters,
+	.masters_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_masters),
+	.flags		= HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
+};
+
 static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
 	/* dmm class */
 	&omap44xx_dmm_hwmod,
@@ -840,6 +931,9 @@ static __initdata struct omap_hwmod *oma
 	&omap44xx_uart2_hwmod,
 	&omap44xx_uart3_hwmod,
 	&omap44xx_uart4_hwmod,
+
+	/* hsusb otg class */
+	&omap44xx_usb_otg_hs_hwmod,
 	NULL,
 };
 
--
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] 19+ messages in thread

* [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
  2010-12-10 14:35 Subject: [PATCH 0/5 v5]usb: musb: hwmod and runtime pm support for musb Hema HK
@ 2010-12-10 14:35 ` Hema HK
  2011-02-03  5:56   ` Hema Kalliguddi
  2011-02-09  0:03   ` Kevin Hilman
       [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  1 sibling, 2 replies; 19+ messages in thread
From: Hema HK @ 2010-12-10 14:35 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-omap, Hema HK, Felipe Balbi, Tony Lindgren, Kevin Hilman,
	Cousson, Benoit, Paul Walmsley

Using omap_device_build API instead of platform_device_register for 
OMAP2430,OMAP34xx and OMAP4430 musb device registration.
The device specific resources defined in centralized
database will be used. 

Signed-off-by: Hema HK <hemahk@ti.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Cousson, Benoit <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/usb-musb.c |   76 +++++++++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 21 deletions(-)

Index: usb/arch/arm/mach-omap2/usb-musb.c
===================================================================
--- usb.orig/arch/arm/mach-omap2/usb-musb.c
+++ usb/arch/arm/mach-omap2/usb-musb.c
@@ -31,9 +31,12 @@
 #include <mach/am35xx.h>
 #include <plat/usb.h>
 #include "control.h"
+#include <plat/omap_device.h>
 
 #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined (CONFIG_USB_MUSB_AM35X)
 
+static const char name[] = "musb-omap2430";
+
 static void am35x_musb_reset(void)
 {
 	u32	regval;
@@ -170,7 +173,7 @@ static struct musb_hdrc_platform_data mu
 static u64 musb_dmamask = DMA_BIT_MASK(32);
 
 static struct platform_device musb_device = {
-	.name		= "musb-omap2430",
+	.name		= "musb-am35x",
 	.id		= -1,
 	.dev = {
 		.dma_mask		= &musb_dmamask,
@@ -181,26 +184,23 @@ static struct platform_device musb_devic
 	.resource	= musb_resources,
 };
 
+static struct omap_device_pm_latency omap_musb_latency[] = {
+	{
+		.deactivate_func = omap_device_idle_hwmods,
+		.activate_func   = omap_device_enable_hwmods,
+		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
+	},
+};
+
 void __init usb_musb_init(struct omap_musb_board_data *board_data)
 {
-	if (cpu_is_omap243x()) {
-		musb_resources[0].start = OMAP243X_HS_BASE;
-	} else if (cpu_is_omap3517() || cpu_is_omap3505()) {
-		musb_device.name = "musb-am35x";
-		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
-		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
-		board_data->set_phy_power = am35x_musb_phy_power;
-		board_data->clear_irq = am35x_musb_clear_irq;
-		board_data->set_mode = am35x_musb_set_mode;
-		board_data->reset = am35x_musb_reset;
-	} else if (cpu_is_omap34xx()) {
-		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
-	} else if (cpu_is_omap44xx()) {
-		musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
-		musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
-		musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
-	}
-	musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
+	struct omap_hwmod *oh;
+	struct omap_device *od;
+	struct platform_device *pdev;
+	struct device	*dev;
+	int bus_id = -1;
+	const char *oh_name = "usb_otg_hs";
+	struct musb_hdrc_platform_data *pdata;
 
 	/*
 	 * REVISIT: This line can be removed once all the platforms using
@@ -212,8 +212,42 @@ void __init usb_musb_init(struct omap_mu
 	musb_plat.mode = board_data->mode;
 	musb_plat.extvbus = board_data->extvbus;
 
-	if (platform_device_register(&musb_device) < 0)
-		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
+	if (cpu_is_omap3517() || cpu_is_omap3505()) {
+		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
+		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
+		board_data->set_phy_power = am35x_musb_phy_power;
+		board_data->clear_irq = am35x_musb_clear_irq;
+		board_data->set_mode = am35x_musb_set_mode;
+		board_data->reset = am35x_musb_reset;
+		musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
+
+		if (platform_device_register(&musb_device) < 0)
+			printk(KERN_ERR "Unable to register HS-USB \
+					(MUSB) device\n");
+	} else {
+		oh = omap_hwmod_lookup(oh_name);
+		if (!oh) {
+			pr_err("Could not look up %s\n", oh_name);
+			return;
+	 	}
+
+		pdata = &musb_plat;
+		od = omap_device_build(name, bus_id, oh, pdata,
+				       sizeof(*pdata), omap_musb_latency,
+				       ARRAY_SIZE(omap_musb_latency), false);
+		if (IS_ERR(od)) {
+			pr_err("Could not build omap_device for %s %s\n",
+							name, oh_name);
+			return;
+		}
+
+		pdev = &od->pdev;
+		dev = &pdev->dev;
+		get_device(dev);
+		dev->dma_mask = &musb_dmamask;
+		dev->coherent_dma_mask = musb_dmamask;
+		put_device(dev);
+	}
 }
 
 #else

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

* [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
       [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-12-10 14:35   ` [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG Hema HK
@ 2010-12-10 14:35   ` Hema HK
       [not found]     ` <1291991739-21705-6-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
  2011-02-09  0:08     ` Kevin Hilman
  3 siblings, 2 replies; 19+ messages in thread
From: Hema HK @ 2010-12-10 14:35 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, Hema HK, Felipe Balbi,
	Tony Lindgren, Kevin Hilman, Cousson, Benoit, Paul Walmsley

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

enable clock, configure no-idle/standby when active and configure force idle/standby
and disable clock when idled. This is taken care by the runtime framework when 
driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.
Need to configure MUSB into force standby and force idle mode when usb not used

Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
---

 drivers/usb/musb/musb_core.h |    2 -
 drivers/usb/musb/omap2430.c  |   80 +++++++++++--------------------------------
 2 files changed, 23 insertions(+), 59 deletions(-)

Index: usb/drivers/usb/musb/omap2430.c
===================================================================
--- usb.orig/drivers/usb/musb/omap2430.c
+++ usb/drivers/usb/musb/omap2430.c
@@ -33,6 +33,8 @@
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
+#include <linux/pm_runtime.h>
+#include <linux/err.h>
 
 #include "musb_core.h"
 #include "omap2430.h"
@@ -40,7 +42,6 @@
 struct omap2430_glue {
 	struct device		*dev;
 	struct platform_device	*musb;
-	struct clk		*clk;
 };
 #define glue_to_musb(g)		platform_get_drvdata(g->musb)
 
@@ -216,20 +217,12 @@ static inline void omap2430_low_level_ex
 	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
 	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);
 }
 
 static inline void omap2430_low_level_init(struct musb *musb)
 {
 	u32 l;
 
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
 	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
 	l &= ~ENABLEFORCE;	/* disable MSTANDBY */
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
@@ -307,21 +300,6 @@ static int omap2430_musb_init(struct mus
 
 	omap2430_low_level_init(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) {
@@ -384,7 +362,7 @@ static int __init omap2430_probe(struct 
 	struct musb_hdrc_platform_data	*pdata = pdev->dev.platform_data;
 	struct platform_device		*musb;
 	struct omap2430_glue		*glue;
-	struct clk			*clk;
+	int				status = 0;
 
 	int				ret = -ENOMEM;
 
@@ -400,26 +378,12 @@ static int __init omap2430_probe(struct 
 		goto err1;
 	}
 
-	clk = clk_get(&pdev->dev, "ick");
-	if (IS_ERR(clk)) {
-		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err2;
-	}
-
-	ret = clk_enable(clk);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to enable clock\n");
-		goto err3;
-	}
-
 	musb->dev.parent		= &pdev->dev;
 	musb->dev.dma_mask		= &omap2430_dmamask;
 	musb->dev.coherent_dma_mask	= omap2430_dmamask;
 
 	glue->dev			= &pdev->dev;
 	glue->musb			= musb;
-	glue->clk			= clk;
 
 	pdata->platform_ops		= &omap2430_ops;
 
@@ -429,28 +393,30 @@ static int __init omap2430_probe(struct 
 			pdev->num_resources);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add resources\n");
-		goto err4;
+		goto err2;
 	}
 
 	ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add platform_data\n");
-		goto err4;
+		goto err2;
 	}
 
 	ret = platform_device_add(musb);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register musb device\n");
-		goto err4;
+		goto err2;
 	}
 
-	return 0;
+	pm_runtime_enable(&pdev->dev);
+	if (pm_runtime_get_sync(&pdev->dev)) {
+		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
+		pm_runtime_disable(&pdev->dev);
+		goto err2;
+	}
 
-err4:
-	clk_disable(clk);
+	return 0;
 
-err3:
-	clk_put(clk);
 
 err2:
 	platform_device_put(musb);
@@ -468,8 +434,8 @@ static int __exit omap2430_remove(struct
 
 	platform_device_del(glue->musb);
 	platform_device_put(glue->musb);
-	clk_disable(glue->clk);
-	clk_put(glue->clk);
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	kfree(glue);
 
 	return 0;
@@ -478,13 +444,11 @@ static int __exit omap2430_remove(struct
 #ifdef CONFIG_PM
 static void omap2430_save_context(struct musb *musb)
 {
-	musb->context.otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
 	musb->context.otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
 }
 
 static void omap2430_restore_context(struct musb *musb)
 {
-	musb_writel(musb->mregs, OTG_SYSCONFIG, musb->context.otg_sysconfig);
 	musb_writel(musb->mregs, OTG_FORCESTDBY, musb->context.otg_forcestandby);
 }
 
@@ -496,8 +460,11 @@ static int omap2430_suspend(struct devic
 	omap2430_low_level_exit(musb);
 	otg_set_suspend(musb->xceiv, 1);
 	omap2430_save_context(musb);
-	clk_disable(glue->clk);
 
+	if (pm_runtime_put_sync(dev)) {
+		dev_err(dev, "pm_runtime_put_sync FAILED");
+		return -EINVAL;
+	}
 	return 0;
 }
 
@@ -505,14 +472,11 @@ static int omap2430_resume(struct device
 {
 	struct omap2430_glue		*glue = dev_get_drvdata(dev);
 	struct musb			*musb = glue_to_musb(glue);
-	int				ret;
 
-	ret = clk_enable(glue->clk);
-	if (ret) {
-		dev_err(dev, "faled to enable clock\n");
-		return ret;
+	if (pm_runtime_get_sync(dev)) {
+		dev_err(dev, "pm_runtime_get_sync FAILED");
+		return -EINVAL;
 	}

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

* Re: [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
       [not found]     ` <1291991739-21705-6-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
@ 2010-12-10 14:38       ` Felipe Balbi
  2010-12-11  2:58         ` Kalliguddi, Hema
  0 siblings, 1 reply; 19+ messages in thread
From: Felipe Balbi @ 2010-12-10 14:38 UTC (permalink / raw)
  To: Hema HK
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Felipe Balbi, Tony Lindgren,
	Kevin Hilman, Cousson, Benoit, Paul Walmsley

hi,

On Fri, Dec 10, 2010 at 08:05:39PM +0530, Hema HK wrote:
>Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync()
>for enabling/disabling the clocks, sysconfig settings.
>
>enable clock, configure no-idle/standby when active and configure force idle/standby
>and disable clock when idled. This is taken care by the runtime framework when
>driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.
>Need to configure MUSB into force standby and force idle mode when usb not used
>
>Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
>Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
>Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
>Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
>Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
>---
>
> drivers/usb/musb/musb_core.h |    2 -
> drivers/usb/musb/omap2430.c  |   80 +++++++++++--------------------------------
> 2 files changed, 23 insertions(+), 59 deletions(-)

Now I see you removed the runtime_resume and runtime_suspend calls from
musb_core. Won't we loose context in that case ?

-- 
balbi
--
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] 19+ messages in thread

* Re: [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
  2010-12-10 14:38       ` Felipe Balbi
@ 2010-12-11  2:58         ` Kalliguddi, Hema
  0 siblings, 0 replies; 19+ messages in thread
From: Kalliguddi, Hema @ 2010-12-11  2:58 UTC (permalink / raw)
  To: balbi
  Cc: linux-usb, linux-omap, Tony Lindgren, Kevin Hilman, Cousson,
	Benoit, Paul Walmsley

On Fri, Dec 10, 2010 at 8:08 PM, Felipe Balbi <balbi@ti.com> wrote:
> hi,
>
> On Fri, Dec 10, 2010 at 08:05:39PM +0530, Hema HK wrote:
>>
>> Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync()
>> for enabling/disabling the clocks, sysconfig settings.
>>
>> enable clock, configure no-idle/standby when active and configure force
>> idle/standby
>> and disable clock when idled. This is taken care by the runtime framework
>> when
>> driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.
>> Need to configure MUSB into force standby and force idle mode when usb not
>> used
>>
>> Signed-off-by: Hema HK <hemahk@ti.com>
>> Cc: Felipe Balbi <balbi@ti.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Kevin Hilman <khilman@deeprootsystems.com>
>> Cc: Cousson, Benoit <b-cousson@ti.com>
>> Cc: Paul Walmsley <paul@pwsan.com>
>> ---
>>
>> drivers/usb/musb/musb_core.h |    2 -
>> drivers/usb/musb/omap2430.c  |   80
>> +++++++++++--------------------------------
>> 2 files changed, 23 insertions(+), 59 deletions(-)
>
> Now I see you removed the runtime_resume and runtime_suspend calls from
> musb_core. Won't we loose context in that case ?
>
We need context save/restore  when .suspend/.resume are called. That
is done anyway in the musb_suspend/
musb_resume_noirq APIs.  Moreover we are calling runtime pm with
musb_omap2430 dev pointer, so
musb runtime_suspend/resume call backs will not be called.

Regards,
Hema
> --
> balbi
>
--
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] 19+ messages in thread

* RE: [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG
       [not found]     ` <1291991739-21705-2-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
@ 2011-02-03  5:54       ` Hema Kalliguddi
       [not found]         ` <3b6a23e346e75947e09f70dae78f2d88-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Hema Kalliguddi @ 2011-02-03  5:54 UTC (permalink / raw)
  To: Hema Kalliguddi, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, Felipe Balbi, Tony Lindgren,
	Kevin Hilman, Benoit Cousson, Paul Walmsley

Hi,

>-----Original Message-----
>From: Hema HK [mailto:hemahk-l0cyMroinI0@public.gmane.org]
>Sent: Friday, December 10, 2010 8:06 PM
>To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Hema HK; Felipe Balbi; Tony
>Lindgren; Kevin Hilman; Cousson, Benoit; Paul Walmsley
>Subject: [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG
>
>OMAP2430 hwmod data structures are populated with base
>address, L3 and L4
>interface clocks, IRQs and sysconfig register details.
>
>As per OMAP USBOTG specification, need to configure the USBOTG
>to smart idle/standby or no idle/standby during data transfer and
>force idle/standby when not in use to support retention and off-mode.
>By setting HWMOD_SWSUP_SIDLE and HWMOD_SWSUP_MSTANDBY flags, framework
>will take care of configuring to no idle/standby when module is enabled
>and force idle/standby when suspended.
>
>Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
>Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
>Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
>Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
>Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
>---
> arch/arm/mach-omap2/omap_hwmod_2430_data.c |   97
>+++++++++++++++++++++++++++++
> 1 file changed, 97 insertions(+)
>
>Index: usb/arch/arm/mach-omap2/omap_hwmod_2430_data.c
>===================================================================
>--- usb.orig/arch/arm/mach-omap2/omap_hwmod_2430_data.c
>+++ usb/arch/arm/mach-omap2/omap_hwmod_2430_data.c
>@@ -77,6 +77,15 @@ static struct omap_hwmod omap2430_l4_wku
> static struct omap_hwmod omap2430_uart1_hwmod;
> static struct omap_hwmod omap2430_uart2_hwmod;
> static struct omap_hwmod omap2430_uart3_hwmod;
>+static struct omap_hwmod omap2430_usbhsotg_hwmod;
>+
>+/* l3_core -> usbhsotg  interface */
>+static struct omap_hwmod_ocp_if omap2430_usbhsotg__l3 = {
>+	.master		= &omap2430_usbhsotg_hwmod,
>+	.slave		= &omap2430_l3_main_hwmod,
>+	.clk		= "core_l3_ck",
>+	.user		= OCP_USER_MPU,
>+};
>
> /* L4_CORE -> L4_WKUP interface */
> static struct omap_hwmod_ocp_if omap2430_l4_core__l4_wkup = {
>@@ -139,6 +148,35 @@ static struct omap_hwmod_ocp_if omap2_l4
> 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
> };
>
>+/*
>+* usbhsotg interface data
>+*/
>+static struct omap_hwmod_addr_space omap2430_usbhsotg_addrs[] = {
>+	{
>+		.pa_start	= OMAP243X_HS_BASE,
>+		.pa_end		= OMAP243X_HS_BASE + SZ_4K - 1,
>+		.flags		= ADDR_TYPE_RT
>+	},
>+};
>+
>+/*  l4_core ->usbhsotg  interface */
>+static struct omap_hwmod_ocp_if omap2430_l4_core__usbhsotg = {
>+	.master		= &omap2430_l4_core_hwmod,
>+	.slave		= &omap2430_usbhsotg_hwmod,
>+	.clk		= "usb_l4_ick",
>+	.addr		= omap2430_usbhsotg_addrs,
>+	.addr_cnt	= ARRAY_SIZE(omap2430_usbhsotg_addrs),
>+	.user		= OCP_USER_MPU,
>+};
>+
>+static struct omap_hwmod_ocp_if *omap2430_usbhsotg_masters[] = {
>+	&omap2430_usbhsotg__l3,
>+};
>+
>+static struct omap_hwmod_ocp_if *omap2430_usbhsotg_slaves[] = {
>+	&omap2430_l4_core__usbhsotg,
>+};
>+
> /* Slave interfaces on the L4_CORE interconnect */
> static struct omap_hwmod_ocp_if *omap2430_l4_core_slaves[] = {
> 	&omap2430_l3_main__l4_core,
>@@ -418,6 +456,62 @@ static struct omap_hwmod omap2430_uart3_
> 	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
> };
>
>+/*
>+ * usbhsotg
>+ */
>+static struct omap_hwmod_class_sysconfig omap2430_usbhsotg_sysc = {
>+	.rev_offs	= 0x0400,
>+	.sysc_offs	= 0x0404,
>+	.syss_offs	= 0x0408,
>+	.sysc_flags	= (SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE|
>+			  SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
>+			  SYSC_HAS_AUTOIDLE),
>+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
>+			  MSTANDBY_FORCE | MSTANDBY_NO |
>MSTANDBY_SMART),
>+	.sysc_fields	= &omap_hwmod_sysc_type1,
>+};
>+
>+static struct omap_hwmod_class usbotg_class = {
>+	.name = "usbotg",
>+	.sysc = &omap2430_usbhsotg_sysc,
>+};
>+
>+/* usb_otg_hs */
>+static struct omap_hwmod_irq_info omap2430_usbhsotg_mpu_irqs[] = {
>+
>+	{ .name = "mc", .irq = 92 },
>+	{ .name = "dma", .irq = 93 },
>+};
>+
>+static struct omap_hwmod omap2430_usbhsotg_hwmod = {
>+	.name		= "usb_otg_hs",
>+	.mpu_irqs	= omap2430_usbhsotg_mpu_irqs,
>+	.mpu_irqs_cnt	= ARRAY_SIZE(omap2430_usbhsotg_mpu_irqs),
>+	.main_clk	= "usbhs_ick",
>+	.prcm		= {
>+		.omap2 = {
>+			.prcm_reg_id = 1,
>+			.module_bit = OMAP2430_EN_USBHS_MASK,
>+			.module_offs = CORE_MOD,
>+			.idlest_reg_id = 1,
>+			.idlest_idle_bit = OMAP2430_ST_USBHS_SHIFT,
>+		},
>+	},
>+	.masters	= omap2430_usbhsotg_masters,
>+	.masters_cnt	= ARRAY_SIZE(omap2430_usbhsotg_masters),
>+	.slaves		= omap2430_usbhsotg_slaves,
>+	.slaves_cnt	= ARRAY_SIZE(omap2430_usbhsotg_slaves),
>+	.class		= &usbotg_class,
>+	/*
>+	 * Erratum ID: i479  idle_req / idle_ack mechanism potentially
>+	 * broken when autoidle is enabled
>+	 * workaround is to disable the autoidle bit at module level.
>+	 */
>+	.flags		= HWMOD_NO_OCP_AUTOIDLE | HWMOD_SWSUP_SIDLE
>+				| HWMOD_SWSUP_MSTANDBY,
>+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP2430)
>+};
>+
> static __initdata struct omap_hwmod *omap2430_hwmods[] = {
> 	&omap2430_l3_main_hwmod,
> 	&omap2430_l4_core_hwmod,
>@@ -428,6 +522,9 @@ static __initdata struct omap_hwmod *oma
> 	&omap2430_uart1_hwmod,
> 	&omap2430_uart2_hwmod,
> 	&omap2430_uart3_hwmod,
>+
>+	/* usbotg class*/
>+	&omap2430_usbhsotg_hwmod,
> 	NULL,
> };
>

Any comments?

Regards,
Hema
>
--
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] 19+ messages in thread

* RE: [PATCH 2/5 v5] OMAP3xxx: hwmod data: Add USBOTG
       [not found]     ` <1291991739-21705-3-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
@ 2011-02-03  5:55       ` Hema Kalliguddi
  0 siblings, 0 replies; 19+ messages in thread
From: Hema Kalliguddi @ 2011-02-03  5:55 UTC (permalink / raw)
  To: Hema Kalliguddi, linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA, Felipe Balbi, Tony Lindgren,
	Kevin Hilman, Benoit Cousson, Paul Walmsley

Hi,

>-----Original Message-----
>From: Hema HK [mailto:hemahk-l0cyMroinI0@public.gmane.org]
>Sent: Friday, December 10, 2010 8:06 PM
>To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Hema HK; Felipe Balbi; Tony
>Lindgren; Kevin Hilman; Cousson, Benoit; Paul Walmsley
>Subject: [PATCH 2/5 v5] OMAP3xxx: hwmod data: Add USBOTG
>
>OMAP3 hwmod data structures are populated for USBOTG with base address,
>L3 and L4 interface clocks, IRQs and sysconfig register details.
>
>As per OMAP USBOTG specification, need to configure the USBOTG
>to smart idle/standby or no idle/standby during data transfer and
>force idle/standby when not in use to support retention and offmode.
>By setting HWMOD_SWSUP_SIDLE and HWMOD_SWSUP_MSTANDBY flags, framework
>will take care of configuring to no idle/standby when module is enabled
>and force idle/standby when idled.
>
>Signed-off-by: Hema HK <hemahk-l0cyMroinI0@public.gmane.org>
>Cc: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
>Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
>Cc: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
>Cc: Cousson, Benoit <b-cousson-l0cyMroinI0@public.gmane.org>
>Cc: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
>---
> arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  100
>+++++++++++++++++++++++++++++
> 1 file changed, 100 insertions(+)
>
>Index: usb/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
>===================================================================
>--- usb.orig/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
>+++ usb/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
>@@ -89,6 +89,15 @@ static struct omap_hwmod omap3xxx_uart1_
> static struct omap_hwmod omap3xxx_uart2_hwmod;
> static struct omap_hwmod omap3xxx_uart3_hwmod;
> static struct omap_hwmod omap3xxx_uart4_hwmod;
>+static struct omap_hwmod omap3xxx_usbhsotg_hwmod;
>+
>+/* l3_core -> usbhsotg interface */
>+static struct omap_hwmod_ocp_if omap3xxx_usbhsotg__l3 = {
>+	.master		= &omap3xxx_usbhsotg_hwmod,
>+	.slave		= &omap3xxx_l3_main_hwmod,
>+	.clk		= "core_l3_ick",
>+	.user		= OCP_USER_MPU,
>+};
>
> /* L4_CORE -> L4_WKUP interface */
> static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = {
>@@ -169,6 +178,36 @@ static struct omap_hwmod_ocp_if omap3_l4
> 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
> };
>
>+/*
>+* usbhsotg interface data
>+*/
>+
>+static struct omap_hwmod_addr_space omap3xxx_usbhsotg_addrs[] = {
>+	{
>+		.pa_start	= OMAP34XX_HSUSB_OTG_BASE,
>+		.pa_end		= OMAP34XX_HSUSB_OTG_BASE + SZ_4K - 1,
>+		.flags		= ADDR_TYPE_RT
>+	},
>+};
>+
>+/* l4_core -> usbhsotg  */
>+static struct omap_hwmod_ocp_if omap3xxx_l4_core__usbhsotg = {
>+	.master		= &omap3xxx_l4_core_hwmod,
>+	.slave		= &omap3xxx_usbhsotg_hwmod,
>+	.clk		= "l4_ick",
>+	.addr		= omap3xxx_usbhsotg_addrs,
>+	.addr_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_addrs),
>+	.user		= OCP_USER_MPU,
>+};
>+
>+static struct omap_hwmod_ocp_if *omap3xxx_usbhsotg_masters[] = {
>+	&omap3xxx_usbhsotg__l3,
>+};
>+
>+static struct omap_hwmod_ocp_if *omap3xxx_usbhsotg_slaves[] = {
>+	&omap3xxx_l4_core__usbhsotg,
>+};
>+
> /* Slave interfaces on the L4_CORE interconnect */
> static struct omap_hwmod_ocp_if *omap3xxx_l4_core_slaves[] = {
> 	&omap3xxx_l3_main__l4_core,
>@@ -509,6 +548,64 @@ static struct omap_hwmod omap3xxx_uart4_
> 	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP3630ES1),
> };
>
>+/*
>+ * usbhsotg
>+ */
>+static struct omap_hwmod_class_sysconfig omap3xxx_usbhsotg_sysc = {
>+	.rev_offs	= 0x0400,
>+	.sysc_offs	= 0x0404,
>+	.syss_offs	= 0x0408,
>+	.sysc_flags	= (SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE|
>+			  SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
>+			  SYSC_HAS_AUTOIDLE),
>+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
>+			  MSTANDBY_FORCE | MSTANDBY_NO |
>MSTANDBY_SMART),
>+	.sysc_fields	= &omap_hwmod_sysc_type1,
>+};
>+
>+static struct omap_hwmod_class usbotg_class = {
>+	.name = "usbotg",
>+	.sysc = &omap3xxx_usbhsotg_sysc,
>+};
>+
>+/* usb_otg_hs */
>+static struct omap_hwmod_irq_info omap3xxx_usbhsotg_mpu_irqs[] = {
>+
>+	{ .name = "mc", .irq = 92 },
>+	{ .name = "dma", .irq = 93 },
>+};
>+
>+static struct omap_hwmod omap3xxx_usbhsotg_hwmod = {
>+	.name		= "usb_otg_hs",
>+	.mpu_irqs	= omap3xxx_usbhsotg_mpu_irqs,
>+	.mpu_irqs_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_mpu_irqs),
>+	.main_clk	= "hsotgusb_ick",
>+	.prcm		= {
>+		.omap2 = {
>+			.prcm_reg_id = 1,
>+			.module_bit = OMAP3430_EN_HSOTGUSB_SHIFT,
>+			.module_offs = CORE_MOD,
>+			.idlest_reg_id = 1,
>+			.idlest_idle_bit =
>OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT,
>+			.idlest_stdby_bit =
>OMAP3430ES2_ST_HSOTGUSB_STDBY_SHIFT
>+		},
>+	},
>+	.masters	= omap3xxx_usbhsotg_masters,
>+	.masters_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_masters),
>+	.slaves		= omap3xxx_usbhsotg_slaves,
>+	.slaves_cnt	= ARRAY_SIZE(omap3xxx_usbhsotg_slaves),
>+	.class		= &usbotg_class,
>+
>+	/*
>+	 * Erratum ID: i479  idle_req / idle_ack mechanism potentially
>+	 * broken when autoidle is enabled
>+	 * workaround is to disable the autoidle bit at module level.
>+	 */
>+	.flags		= HWMOD_NO_OCP_AUTOIDLE | HWMOD_SWSUP_SIDLE
>+				| HWMOD_SWSUP_MSTANDBY,
>+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
>+};
>+
> static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
> 	&omap3xxx_l3_main_hwmod,
> 	&omap3xxx_l4_core_hwmod,
>@@ -521,6 +618,9 @@ static __initdata struct omap_hwmod *oma
> 	&omap3xxx_uart2_hwmod,
> 	&omap3xxx_uart3_hwmod,
> 	&omap3xxx_uart4_hwmod,
>+
>+	/* usbotg class */
>+	&omap3xxx_usbhsotg_hwmod,
> 	NULL,
> };
>
>
Any comments?

Regards,
Hema
--
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] 19+ messages in thread

* RE: [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG
  2010-12-10 14:35   ` [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG Hema HK
@ 2011-02-03  5:55     ` Hema Kalliguddi
  0 siblings, 0 replies; 19+ messages in thread
From: Hema Kalliguddi @ 2011-02-03  5:55 UTC (permalink / raw)
  To: Hema Kalliguddi, linux-usb
  Cc: linux-omap, Benoit Cousson, Felipe Balbi, Tony Lindgren,
	Kevin Hilman, Paul Walmsley

Hi,

>-----Original Message-----
>From: Hema HK [mailto:hemahk@ti.com]
>Sent: Friday, December 10, 2010 8:06 PM
>To: linux-usb@vger.kernel.org
>Cc: linux-omap@vger.kernel.org; Cousson, Benoit; Hema HK;
>Felipe Balbi; Tony Lindgren; Kevin Hilman; Paul Walmsley
>Subject: [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG
>
>From: Cousson, Benoit <b-cousson@ti.com>
>
>OMAP4 hwmod data structures are populated with base address, L3 and L4
>interface clocks, IRQs and sysconfig register details.
>
>As per OMAP USBOTG specification, need to configure the USBOTG
>to smart idle/standby or no idle/standby during data transfer and
>force idle/standby when not in use to support retention and offmode.
>By setting HWMOD_SWSUP_SIDLE and HWMOD_SWSUP_MSTANDBY flags,framework
>will take care of configuring to no idle/standby when module is enabled
>and force idle/standby when idled.
>
>Signed-off-by: Cousson, Benoit <b-cousson@ti.com>
>Signed-off-by: Hema HK <hemahk@ti.com>
>Cc: Felipe Balbi <balbi@ti.com>
>Cc: Tony Lindgren <tony@atomide.com>
>Cc: Kevin Hilman <khilman@deeprootsystems.com>
>Cc: Cousson, Benoit <b-cousson@ti.com>
>Cc: Paul Walmsley <paul@pwsan.com>
>---
> arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   94
>+++++++++++++++++++++++++++++
> 1 file changed, 94 insertions(+)
>
>Index: usb/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
>===================================================================
>--- usb.orig/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
>+++ usb/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
>@@ -47,6 +47,7 @@ static struct omap_hwmod omap44xx_l4_per
> static struct omap_hwmod omap44xx_l4_wkup_hwmod;
> static struct omap_hwmod omap44xx_mpu_hwmod;
> static struct omap_hwmod omap44xx_mpu_private_hwmod;
>+static struct omap_hwmod omap44xx_usb_otg_hs_hwmod;
>
> /*
>  * Interconnects omap_hwmod structures
>@@ -223,10 +224,19 @@ static struct omap_hwmod_ocp_if omap44xx
> 	.user		= OCP_USER_MPU | OCP_USER_SDMA,
> };
>
>+/* usb_otg_hs -> l3_main_2 */
>+static struct omap_hwmod_ocp_if omap44xx_usb_otg_hs__l3_main_2 = {
>+	.master		= &omap44xx_usb_otg_hs_hwmod,
>+	.slave		= &omap44xx_l3_main_2_hwmod,
>+	.clk		= "l3_div_ck",
>+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
>+};
>+
> /* l3_main_2 slave ports */
> static struct omap_hwmod_ocp_if *omap44xx_l3_main_2_slaves[] = {
> 	&omap44xx_l3_main_1__l3_main_2,
> 	&omap44xx_l4_cfg__l3_main_2,
>+	&omap44xx_usb_otg_hs__l3_main_2,
> };
>
> static struct omap_hwmod omap44xx_l3_main_2_hwmod = {
>@@ -811,6 +821,87 @@ static struct omap_hwmod omap44xx_uart4_
> 	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
> };
>
>+/*
>+ * 'usb_otg_hs' class
>+ * high-speed on-the-go universal serial bus (usb_otg_hs) controller
>+ */
>+
>+static struct omap_hwmod_class_sysconfig omap44xx_usb_otg_hs_sysc = {
>+	.rev_offs	= 0x0400,
>+	.sysc_offs	= 0x0404,
>+	.syss_offs	= 0x0408,
>+	.sysc_flags	= (SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE|
>+			  SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
>+			  SYSC_HAS_AUTOIDLE),
>+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
>+			  MSTANDBY_FORCE | MSTANDBY_NO |
>MSTANDBY_SMART),
>+	.sysc_fields	= &omap_hwmod_sysc_type1,
>+};
>+
>+static struct omap_hwmod_class omap44xx_usb_otg_hs_hwmod_class = {
>+	.name = "usb_otg_hs",
>+	.sysc = &omap44xx_usb_otg_hs_sysc,
>+};
>+
>+/* usb_otg_hs */
>+static struct omap_hwmod_irq_info omap44xx_usb_otg_hs_irqs[] = {
>+	{ .name = "mc", .irq = 92 + OMAP44XX_IRQ_GIC_START },
>+	{ .name = "dma", .irq = 93 + OMAP44XX_IRQ_GIC_START },
>+};
>+
>+/* usb_otg_hs master ports */
>+static struct omap_hwmod_ocp_if *omap44xx_usb_otg_hs_masters[] = {
>+	&omap44xx_usb_otg_hs__l3_main_2,
>+};
>+
>+static struct omap_hwmod_addr_space omap44xx_usb_otg_hs_addrs[] = {
>+	{
>+		.pa_start	= OMAP44XX_HSUSB_OTG_BASE,
>+		.pa_end		= OMAP44XX_HSUSB_OTG_BASE + SZ_4K - 1,
>+		.flags		= ADDR_TYPE_RT
>+	},
>+};
>+
>+/* l4_cfg -> usb_otg_hs */
>+static struct omap_hwmod_ocp_if omap44xx_l4_cfg__usb_otg_hs = {
>+	.master		= &omap44xx_l4_cfg_hwmod,
>+	.slave		= &omap44xx_usb_otg_hs_hwmod,
>+	.clk		= "l4_div_ck",
>+	.addr		= omap44xx_usb_otg_hs_addrs,
>+	.addr_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_addrs),
>+	.user		= OCP_USER_MPU | OCP_USER_SDMA,
>+};
>+
>+/* usb_otg_hs slave ports */
>+static struct omap_hwmod_ocp_if *omap44xx_usb_otg_hs_slaves[] = {
>+	&omap44xx_l4_cfg__usb_otg_hs,
>+};
>+
>+static struct omap_hwmod_opt_clk usb_otg_hs_opt_clks[] = {
>+	{ .role = "xclk", .clk = "otg_60m_gfclk_ck" },
>+};
>+
>+static struct omap_hwmod omap44xx_usb_otg_hs_hwmod = {
>+	.name		= "usb_otg_hs",
>+	.class		= &omap44xx_usb_otg_hs_hwmod_class,
>+	.mpu_irqs	= omap44xx_usb_otg_hs_irqs,
>+	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_irqs),
>+	.main_clk	= "usb_otg_hs_ick",
>+	.prcm = {
>+		.omap4 = {
>+			.clkctrl_reg =
>OMAP4430_CM_L3INIT_USB_OTG_CLKCTRL,
>+		},
>+	},
>+	.opt_clks	= usb_otg_hs_opt_clks,
>+	.opt_clks_cnt = ARRAY_SIZE(usb_otg_hs_opt_clks),
>+	.slaves		= omap44xx_usb_otg_hs_slaves,
>+	.slaves_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_slaves),
>+	.masters	= omap44xx_usb_otg_hs_masters,
>+	.masters_cnt	= ARRAY_SIZE(omap44xx_usb_otg_hs_masters),
>+	.flags		= HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
>+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
>+};
>+
> static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
> 	/* dmm class */
> 	&omap44xx_dmm_hwmod,
>@@ -840,6 +931,9 @@ static __initdata struct omap_hwmod *oma
> 	&omap44xx_uart2_hwmod,
> 	&omap44xx_uart3_hwmod,
> 	&omap44xx_uart4_hwmod,
>+
>+	/* hsusb otg class */
>+	&omap44xx_usb_otg_hs_hwmod,
> 	NULL,
> };
>
>

Any comments?

Regards,
Hema

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

* RE: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
  2010-12-10 14:35 ` [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation " Hema HK
@ 2011-02-03  5:56   ` Hema Kalliguddi
  2011-02-09  0:03   ` Kevin Hilman
  1 sibling, 0 replies; 19+ messages in thread
From: Hema Kalliguddi @ 2011-02-03  5:56 UTC (permalink / raw)
  To: Hema Kalliguddi, linux-usb
  Cc: linux-omap, Felipe Balbi, Tony Lindgren, Kevin Hilman,
	Benoit Cousson, Paul Walmsley

Hi,

>-----Original Message-----
>From: Hema HK [mailto:hemahk@ti.com]
>Sent: Friday, December 10, 2010 8:06 PM
>To: linux-usb@vger.kernel.org
>Cc: linux-omap@vger.kernel.org; Hema HK; Felipe Balbi; Tony
>Lindgren; Kevin Hilman; Cousson, Benoit; Paul Walmsley
>Subject: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
>
>Using omap_device_build API instead of platform_device_register for
>OMAP2430,OMAP34xx and OMAP4430 musb device registration.
>The device specific resources defined in centralized
>database will be used.
>
>Signed-off-by: Hema HK <hemahk@ti.com>
>Cc: Felipe Balbi <balbi@ti.com>
>Cc: Tony Lindgren <tony@atomide.com>
>Cc: Kevin Hilman <khilman@deeprootsystems.com>
>Cc: Cousson, Benoit <b-cousson@ti.com>
>Cc: Paul Walmsley <paul@pwsan.com>
>---
> arch/arm/mach-omap2/usb-musb.c |   76
>+++++++++++++++++++++++++++++------------
> 1 file changed, 55 insertions(+), 21 deletions(-)
>
>Index: usb/arch/arm/mach-omap2/usb-musb.c
>===================================================================
>--- usb.orig/arch/arm/mach-omap2/usb-musb.c
>+++ usb/arch/arm/mach-omap2/usb-musb.c
>@@ -31,9 +31,12 @@
> #include <mach/am35xx.h>
> #include <plat/usb.h>
> #include "control.h"
>+#include <plat/omap_device.h>
>
> #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined
>(CONFIG_USB_MUSB_AM35X)
>
>+static const char name[] = "musb-omap2430";
>+
> static void am35x_musb_reset(void)
> {
> 	u32	regval;
>@@ -170,7 +173,7 @@ static struct musb_hdrc_platform_data mu
> static u64 musb_dmamask = DMA_BIT_MASK(32);
>
> static struct platform_device musb_device = {
>-	.name		= "musb-omap2430",
>+	.name		= "musb-am35x",
> 	.id		= -1,
> 	.dev = {
> 		.dma_mask		= &musb_dmamask,
>@@ -181,26 +184,23 @@ static struct platform_device musb_devic
> 	.resource	= musb_resources,
> };
>
>+static struct omap_device_pm_latency omap_musb_latency[] = {
>+	{
>+		.deactivate_func = omap_device_idle_hwmods,
>+		.activate_func   = omap_device_enable_hwmods,
>+		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
>+	},
>+};
>+
> void __init usb_musb_init(struct omap_musb_board_data *board_data)
> {
>-	if (cpu_is_omap243x()) {
>-		musb_resources[0].start = OMAP243X_HS_BASE;
>-	} else if (cpu_is_omap3517() || cpu_is_omap3505()) {
>-		musb_device.name = "musb-am35x";
>-		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
>-		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
>-		board_data->set_phy_power = am35x_musb_phy_power;
>-		board_data->clear_irq = am35x_musb_clear_irq;
>-		board_data->set_mode = am35x_musb_set_mode;
>-		board_data->reset = am35x_musb_reset;
>-	} else if (cpu_is_omap34xx()) {
>-		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
>-	} else if (cpu_is_omap44xx()) {
>-		musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
>-		musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
>-		musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
>-	}
>-	musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
>+	struct omap_hwmod *oh;
>+	struct omap_device *od;
>+	struct platform_device *pdev;
>+	struct device	*dev;
>+	int bus_id = -1;
>+	const char *oh_name = "usb_otg_hs";
>+	struct musb_hdrc_platform_data *pdata;
>
> 	/*
> 	 * REVISIT: This line can be removed once all the
>platforms using
>@@ -212,8 +212,42 @@ void __init usb_musb_init(struct omap_mu
> 	musb_plat.mode = board_data->mode;
> 	musb_plat.extvbus = board_data->extvbus;
>
>-	if (platform_device_register(&musb_device) < 0)
>-		printk(KERN_ERR "Unable to register HS-USB
>(MUSB) device\n");
>+	if (cpu_is_omap3517() || cpu_is_omap3505()) {
>+		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
>+		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
>+		board_data->set_phy_power = am35x_musb_phy_power;
>+		board_data->clear_irq = am35x_musb_clear_irq;
>+		board_data->set_mode = am35x_musb_set_mode;
>+		board_data->reset = am35x_musb_reset;
>+		musb_resources[0].end = musb_resources[0].start
>+ SZ_4K - 1;
>+
>+		if (platform_device_register(&musb_device) < 0)
>+			printk(KERN_ERR "Unable to register HS-USB \
>+					(MUSB) device\n");
>+	} else {
>+		oh = omap_hwmod_lookup(oh_name);
>+		if (!oh) {
>+			pr_err("Could not look up %s\n", oh_name);
>+			return;
>+	 	}
>+
>+		pdata = &musb_plat;
>+		od = omap_device_build(name, bus_id, oh, pdata,
>+				       sizeof(*pdata),
>omap_musb_latency,
>+				
>ARRAY_SIZE(omap_musb_latency), false);
>+		if (IS_ERR(od)) {
>+			pr_err("Could not build omap_device for
>%s %s\n",
>+							name, oh_name);
>+			return;
>+		}
>+
>+		pdev = &od->pdev;
>+		dev = &pdev->dev;
>+		get_device(dev);
>+		dev->dma_mask = &musb_dmamask;
>+		dev->coherent_dma_mask = musb_dmamask;
>+		put_device(dev);
>+	}
> }
>
> #else
>

Any comments?

Regards,
Hema

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

* Re: [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG
       [not found]         ` <3b6a23e346e75947e09f70dae78f2d88-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-02-03  9:25           ` Felipe Balbi
  2011-02-09  0:55             ` Kevin Hilman
  0 siblings, 1 reply; 19+ messages in thread
From: Felipe Balbi @ 2011-02-03  9:25 UTC (permalink / raw)
  To: Hema Kalliguddi
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Felipe Balbi, Tony Lindgren,
	Kevin Hilman, Benoit Cousson, Paul Walmsley

Hi,

On Thu, Feb 03, 2011 at 11:24:48AM +0530, Hema Kalliguddi wrote:
> Any comments?

For me these are ok, Tony/Kevin, do you want me to prepare a pull
request when we're closer to .39 merge window for one of you guys to
pull from and get this part in mainline ? pm_runtime parts (which only
touch drivers/usb/musb/omap2430.c) I can get in mainline through Greg,
but not this.

-- 
balbi
--
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] 19+ messages in thread

* Re: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
  2010-12-10 14:35 ` [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation " Hema HK
  2011-02-03  5:56   ` Hema Kalliguddi
@ 2011-02-09  0:03   ` Kevin Hilman
  2011-02-10 13:34     ` Hema Kalliguddi
  1 sibling, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-02-09  0:03 UTC (permalink / raw)
  To: Hema HK
  Cc: linux-usb, linux-omap, Felipe Balbi, Tony Lindgren, Cousson,
	Benoit, Paul Walmsley

On Fri, 2010-12-10 at 20:05 +0530, Hema HK wrote:
> Using omap_device_build API instead of platform_device_register for 
> OMAP2430,OMAP34xx and OMAP4430 musb device registration.
> The device specific resources defined in centralized
> database will be used. 
> 
> Signed-off-by: Hema HK <hemahk@ti.com>
> Cc: Felipe Balbi <balbi@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Kevin Hilman <khilman@deeprootsystems.com>
> Cc: Cousson, Benoit <b-cousson@ti.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> ---
>  arch/arm/mach-omap2/usb-musb.c |   76 +++++++++++++++++++++++++++++------------
>  1 file changed, 55 insertions(+), 21 deletions(-)
> 
> Index: usb/arch/arm/mach-omap2/usb-musb.c
> ===================================================================
> --- usb.orig/arch/arm/mach-omap2/usb-musb.c
> +++ usb/arch/arm/mach-omap2/usb-musb.c
> @@ -31,9 +31,12 @@
>  #include <mach/am35xx.h>
>  #include <plat/usb.h>
>  #include "control.h"
> +#include <plat/omap_device.h>
>  
>  #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined (CONFIG_USB_MUSB_AM35X)
>  
> +static const char name[] = "musb-omap2430";
> +
>  static void am35x_musb_reset(void)
>  {
>  	u32	regval;
> @@ -170,7 +173,7 @@ static struct musb_hdrc_platform_data mu
>  static u64 musb_dmamask = DMA_BIT_MASK(32);
>  
>  static struct platform_device musb_device = {
> -	.name		= "musb-omap2430",
> +	.name		= "musb-am35x",

Should be in AM35x specific code.

>  	.id		= -1,
>  	.dev = {
>  		.dma_mask		= &musb_dmamask,
> @@ -181,26 +184,23 @@ static struct platform_device musb_devic
>  	.resource	= musb_resources,
>  };
>  
> +static struct omap_device_pm_latency omap_musb_latency[] = {
> +	{
> +		.deactivate_func = omap_device_idle_hwmods,
> +		.activate_func   = omap_device_enable_hwmods,
> +		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
> +	},
> +};
> +
>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>  {
> -	if (cpu_is_omap243x()) {
> -		musb_resources[0].start = OMAP243X_HS_BASE;
> -	} else if (cpu_is_omap3517() || cpu_is_omap3505()) {
> -		musb_device.name = "musb-am35x";
> -		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
> -		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
> -		board_data->set_phy_power = am35x_musb_phy_power;
> -		board_data->clear_irq = am35x_musb_clear_irq;
> -		board_data->set_mode = am35x_musb_set_mode;
> -		board_data->reset = am35x_musb_reset;
> -	} else if (cpu_is_omap34xx()) {
> -		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
> -	} else if (cpu_is_omap44xx()) {
> -		musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
> -		musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
> -		musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
> -	}
> -	musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
> +	struct omap_hwmod *oh;
> +	struct omap_device *od;
> +	struct platform_device *pdev;
> +	struct device	*dev;
> +	int bus_id = -1;
> +	const char *oh_name = "usb_otg_hs";
> +	struct musb_hdrc_platform_data *pdata;
>  
>  	/*
>  	 * REVISIT: This line can be removed once all the platforms using
> @@ -212,8 +212,42 @@ void __init usb_musb_init(struct omap_mu
>  	musb_plat.mode = board_data->mode;
>  	musb_plat.extvbus = board_data->extvbus;
>  
> -	if (platform_device_register(&musb_device) < 0)
> -		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
> +	if (cpu_is_omap3517() || cpu_is_omap3505()) {
> +		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
> +		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
> +		board_data->set_phy_power = am35x_musb_phy_power;
> +		board_data->clear_irq = am35x_musb_clear_irq;
> +		board_data->set_mode = am35x_musb_set_mode;
> +		board_data->reset = am35x_musb_reset;
> +		musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
> +
> +		if (platform_device_register(&musb_device) < 0)
> +			printk(KERN_ERR "Unable to register HS-USB \
> +					(MUSB) device\n");

The need for  'if cpu_is_*' here should be a red flag indicating a
problem with this code.

The goal of hwmod was to be able to get rid of this kind of cpu_is_*
cruft.  At least the base and IRQ stuff should not be needed here.  What
is needed is hwmod data for AM35x where it is different from the
"normal" OMAP3.

I'm not exactly sure what the rest of these pdata function pointers are
doing here since there seems to be an AM35x specific version of the
driver in drivers/usb/musb, but that part isn't for me to decide.

Kevin


> +	} else {
> +		oh = omap_hwmod_lookup(oh_name);
> +		if (!oh) {
> +			pr_err("Could not look up %s\n", oh_name);
> +			return;
> +	 	}
> +
> +		pdata = &musb_plat;
> +		od = omap_device_build(name, bus_id, oh, pdata,
> +				       sizeof(*pdata), omap_musb_latency,
> +				       ARRAY_SIZE(omap_musb_latency), false);
> +		if (IS_ERR(od)) {
> +			pr_err("Could not build omap_device for %s %s\n",
> +							name, oh_name);
> +			return;
> +		}
> +
> +		pdev = &od->pdev;
> +		dev = &pdev->dev;
> +		get_device(dev);
> +		dev->dma_mask = &musb_dmamask;
> +		dev->coherent_dma_mask = musb_dmamask;
> +		put_device(dev);
> +	}
>  }
>  
>  #else



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

* Re: [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
  2010-12-10 14:35   ` [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb Hema HK
       [not found]     ` <1291991739-21705-6-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
@ 2011-02-09  0:08     ` Kevin Hilman
  2011-02-09  4:23       ` Hema Kalliguddi
  1 sibling, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-02-09  0:08 UTC (permalink / raw)
  To: Hema HK
  Cc: linux-usb, linux-omap, Felipe Balbi, Tony Lindgren, Cousson,
	Benoit, Paul Walmsley

On Fri, 2010-12-10 at 20:05 +0530, Hema HK wrote:
> Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync()
> for enabling/disabling the clocks, sysconfig settings.
> 
> enable clock, configure no-idle/standby when active and configure force idle/standby
> and disable clock when idled. This is taken care by the runtime framework when 
> driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.
> Need to configure MUSB into force standby and force idle mode when usb not used
> 
> Signed-off-by: Hema HK <hemahk@ti.com>
> Cc: Felipe Balbi <balbi@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Kevin Hilman <khilman@deeprootsystems.com>
> Cc: Cousson, Benoit <b-cousson@ti.com>
> Cc: Paul Walmsley <paul@pwsan.com>
> ---
> 
>  drivers/usb/musb/musb_core.h |    2 -
>  drivers/usb/musb/omap2430.c  |   80 +++++++++++--------------------------------
>  2 files changed, 23 insertions(+), 59 deletions(-)
> 
> Index: usb/drivers/usb/musb/omap2430.c
> ===================================================================
> --- usb.orig/drivers/usb/musb/omap2430.c
> +++ usb/drivers/usb/musb/omap2430.c
> @@ -33,6 +33,8 @@
>  #include <linux/io.h>
>  #include <linux/platform_device.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/err.h>
>  
>  #include "musb_core.h"
>  #include "omap2430.h"
> @@ -40,7 +42,6 @@
>  struct omap2430_glue {
>  	struct device		*dev;
>  	struct platform_device	*musb;
> -	struct clk		*clk;
>  };
>  #define glue_to_musb(g)		platform_get_drvdata(g->musb)
>  
> @@ -216,20 +217,12 @@ static inline void omap2430_low_level_ex
>  	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
>  	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);
>  }
>  
>  static inline void omap2430_low_level_init(struct musb *musb)
>  {
>  	u32 l;
>  
> -	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
> -	l &= ~ENABLEWAKEUP;	/* disable wakeup */
> -	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
> -
>  	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
>  	l &= ~ENABLEFORCE;	/* disable MSTANDBY */
>  	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
> @@ -307,21 +300,6 @@ static int omap2430_musb_init(struct mus
>  
>  	omap2430_low_level_init(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) {
> @@ -384,7 +362,7 @@ static int __init omap2430_probe(struct 
>  	struct musb_hdrc_platform_data	*pdata = pdev->dev.platform_data;
>  	struct platform_device		*musb;
>  	struct omap2430_glue		*glue;
> -	struct clk			*clk;
> +	int				status = 0;
>  
>  	int				ret = -ENOMEM;
>  
> @@ -400,26 +378,12 @@ static int __init omap2430_probe(struct 
>  		goto err1;
>  	}
>  
> -	clk = clk_get(&pdev->dev, "ick");
> -	if (IS_ERR(clk)) {
> -		dev_err(&pdev->dev, "failed to get clock\n");
> -		ret = PTR_ERR(clk);
> -		goto err2;
> -	}
> -
> -	ret = clk_enable(clk);
> -	if (ret) {
> -		dev_err(&pdev->dev, "failed to enable clock\n");
> -		goto err3;
> -	}
> -
>  	musb->dev.parent		= &pdev->dev;
>  	musb->dev.dma_mask		= &omap2430_dmamask;
>  	musb->dev.coherent_dma_mask	= omap2430_dmamask;
>  
>  	glue->dev			= &pdev->dev;
>  	glue->musb			= musb;
> -	glue->clk			= clk;
>  
>  	pdata->platform_ops		= &omap2430_ops;
>  
> @@ -429,28 +393,30 @@ static int __init omap2430_probe(struct 
>  			pdev->num_resources);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to add resources\n");
> -		goto err4;
> +		goto err2;
>  	}
>  
>  	ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to add platform_data\n");
> -		goto err4;
> +		goto err2;
>  	}
>  
>  	ret = platform_device_add(musb);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to register musb device\n");
> -		goto err4;
> +		goto err2;
>  	}
>  
> -	return 0;
> +	pm_runtime_enable(&pdev->dev);
> +	if (pm_runtime_get_sync(&pdev->dev)) {
> +		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
> +		pm_runtime_disable(&pdev->dev);
> +		goto err2;
> +	}
>  
> -err4:
> -	clk_disable(clk);
> +	return 0;
>  
> -err3:
> -	clk_put(clk);
>  
>  err2:
>  	platform_device_put(musb);
> @@ -468,8 +434,8 @@ static int __exit omap2430_remove(struct
>  
>  	platform_device_del(glue->musb);
>  	platform_device_put(glue->musb);
> -	clk_disable(glue->clk);
> -	clk_put(glue->clk);
> +	pm_runtime_put_sync(&pdev->dev);
> +	pm_runtime_disable(&pdev->dev);
>  	kfree(glue);
>  
>  	return 0;
> @@ -478,13 +444,11 @@ static int __exit omap2430_remove(struct
>  #ifdef CONFIG_PM
>  static void omap2430_save_context(struct musb *musb)
>  {
> -	musb->context.otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
>  	musb->context.otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
>  }
>  
>  static void omap2430_restore_context(struct musb *musb)
>  {
> -	musb_writel(musb->mregs, OTG_SYSCONFIG, musb->context.otg_sysconfig);
>  	musb_writel(musb->mregs, OTG_FORCESTDBY, musb->context.otg_forcestandby);
>  }
>  
> @@ -496,8 +460,11 @@ static int omap2430_suspend(struct devic
>  	omap2430_low_level_exit(musb);
>  	otg_set_suspend(musb->xceiv, 1);
>  	omap2430_save_context(musb);
> -	clk_disable(glue->clk);
>  
> +	if (pm_runtime_put_sync(dev)) {
> +		dev_err(dev, "pm_runtime_put_sync FAILED");
> +		return -EINVAL;
> +	}

runtime suspend transitions are disabled when system suspend/resume is
happening, so if the device is not already runtime suspended, this call
will have no effect, and the OTG block will be active during suspend
(preventing it's powerdomain from hitting retention/off.)

What is needed here is a direct call into the bus runtime methods.  See
the similar patch I did for i2c:

	http://marc.info/?l=linux-omap&m=129617401612954&w=2

Kevin



>  	return 0;
>  }
>  
> @@ -505,14 +472,11 @@ static int omap2430_resume(struct device
>  {
>  	struct omap2430_glue		*glue = dev_get_drvdata(dev);
>  	struct musb			*musb = glue_to_musb(glue);
> -	int				ret;
>  
> -	ret = clk_enable(glue->clk);
> -	if (ret) {
> -		dev_err(dev, "faled to enable clock\n");
> -		return ret;
> +	if (pm_runtime_get_sync(dev)) {
> +		dev_err(dev, "pm_runtime_get_sync FAILED");
> +		return -EINVAL;
>  	}
> -
>  	omap2430_low_level_init(musb);
>  	omap2430_restore_context(musb);
>  	otg_set_suspend(musb->xceiv, 0);
> Index: usb/drivers/usb/musb/musb_core.h
> ===================================================================
> --- usb.orig/drivers/usb/musb/musb_core.h
> +++ usb/drivers/usb/musb/musb_core.h
> @@ -360,7 +360,7 @@ struct musb_context_registers {
>  
>  #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
>      defined(CONFIG_ARCH_OMAP4)
> -	u32 otg_sysconfig, otg_forcestandby;
> +	u32 otg_forcestandby;
>  #endif
>  	u8 power;
>  	u16 intrtxe, intrrxe;



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

* Re: [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG
  2011-02-03  9:25           ` Felipe Balbi
@ 2011-02-09  0:55             ` Kevin Hilman
  0 siblings, 0 replies; 19+ messages in thread
From: Kevin Hilman @ 2011-02-09  0:55 UTC (permalink / raw)
  To: balbi
  Cc: Hema Kalliguddi, linux-usb, linux-omap, Tony Lindgren,
	Benoit Cousson, Paul Walmsley

Felipe Balbi <balbi@ti.com> writes:

> Hi,
>
> On Thu, Feb 03, 2011 at 11:24:48AM +0530, Hema Kalliguddi wrote:
>> Any comments?
>
> For me these are ok, Tony/Kevin, do you want me to prepare a pull
> request when we're closer to .39 merge window for one of you guys to
> pull from and get this part in mainline ? pm_runtime parts (which only
> touch drivers/usb/musb/omap2430.c) I can get in mainline through Greg,
> but not this.

I did not see a cover letter on this series to see on what platforms it
was tested.  Based on all the other omap_device/omap_hwmod conversions,
I recommend you ensure this has been tested on all relevant platforms
before merging.

That being said, you're the maintainer, so you can decide when you're OK
with it.

When you're OK with the driver/common code, Benoit will queue the hwmod
data changes.

Kevin




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

* RE: [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
  2011-02-09  0:08     ` Kevin Hilman
@ 2011-02-09  4:23       ` Hema Kalliguddi
  0 siblings, 0 replies; 19+ messages in thread
From: Hema Kalliguddi @ 2011-02-09  4:23 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: linux-usb, linux-omap, Felipe Balbi, Tony Lindgren,
	Benoit Cousson, Paul Walmsley

Kevin,

>-----Original Message-----
>From: Kevin Hilman [mailto:khilman@ti.com]
>Sent: Wednesday, February 09, 2011 5:38 AM
>To: Hema HK
>Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org;
>Felipe Balbi; Tony Lindgren; Cousson, Benoit; Paul Walmsley
>Subject: Re: [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb.
>
>On Fri, 2010-12-10 at 20:05 +0530, Hema HK wrote:
>> Calling runtime pm APIs pm_runtime_put_sync() and
>pm_runtime_get_sync()
>> for enabling/disabling the clocks, sysconfig settings.
>>
>> enable clock, configure no-idle/standby when active and
>configure force idle/standby
>> and disable clock when idled. This is taken care by the
>runtime framework when
>> driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.
>> Need to configure MUSB into force standby and force idle
>mode when usb not used
>>
>> Signed-off-by: Hema HK <hemahk@ti.com>
>> Cc: Felipe Balbi <balbi@ti.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Kevin Hilman <khilman@deeprootsystems.com>
>> Cc: Cousson, Benoit <b-cousson@ti.com>
>> Cc: Paul Walmsley <paul@pwsan.com>
>> ---
>>
>>  drivers/usb/musb/musb_core.h |    2 -
>>  drivers/usb/musb/omap2430.c  |   80
>+++++++++++--------------------------------
>>  2 files changed, 23 insertions(+), 59 deletions(-)
>>
>> Index: usb/drivers/usb/musb/omap2430.c
>> ===================================================================
>> --- usb.orig/drivers/usb/musb/omap2430.c
>> +++ usb/drivers/usb/musb/omap2430.c
>> @@ -33,6 +33,8 @@
>>  #include <linux/io.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/dma-mapping.h>
>> +#include <linux/pm_runtime.h>
>> +#include <linux/err.h>
>>
>>  #include "musb_core.h"
>>  #include "omap2430.h"
>> @@ -40,7 +42,6 @@
>>  struct omap2430_glue {
>>  	struct device		*dev;
>>  	struct platform_device	*musb;
>> -	struct clk		*clk;
>>  };
>>  #define glue_to_musb(g)		platform_get_drvdata(g->musb)
>>
>> @@ -216,20 +217,12 @@ static inline void omap2430_low_level_ex
>>  	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
>>  	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);
>>  }
>>
>>  static inline void omap2430_low_level_init(struct musb *musb)
>>  {
>>  	u32 l;
>>
>> -	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
>> -	l &= ~ENABLEWAKEUP;	/* disable wakeup */
>> -	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
>> -
>>  	l = musb_readl(musb->mregs, OTG_FORCESTDBY);
>>  	l &= ~ENABLEFORCE;	/* disable MSTANDBY */
>>  	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
>> @@ -307,21 +300,6 @@ static int omap2430_musb_init(struct mus
>>
>>  	omap2430_low_level_init(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) {
>> @@ -384,7 +362,7 @@ static int __init omap2430_probe(struct
>>  	struct musb_hdrc_platform_data	*pdata =
>pdev->dev.platform_data;
>>  	struct platform_device		*musb;
>>  	struct omap2430_glue		*glue;
>> -	struct clk			*clk;
>> +	int				status = 0;
>>
>>  	int				ret = -ENOMEM;
>>
>> @@ -400,26 +378,12 @@ static int __init omap2430_probe(struct
>>  		goto err1;
>>  	}
>>
>> -	clk = clk_get(&pdev->dev, "ick");
>> -	if (IS_ERR(clk)) {
>> -		dev_err(&pdev->dev, "failed to get clock\n");
>> -		ret = PTR_ERR(clk);
>> -		goto err2;
>> -	}
>> -
>> -	ret = clk_enable(clk);
>> -	if (ret) {
>> -		dev_err(&pdev->dev, "failed to enable clock\n");
>> -		goto err3;
>> -	}
>> -
>>  	musb->dev.parent		= &pdev->dev;
>>  	musb->dev.dma_mask		= &omap2430_dmamask;
>>  	musb->dev.coherent_dma_mask	= omap2430_dmamask;
>>
>>  	glue->dev			= &pdev->dev;
>>  	glue->musb			= musb;
>> -	glue->clk			= clk;
>>
>>  	pdata->platform_ops		= &omap2430_ops;
>>
>> @@ -429,28 +393,30 @@ static int __init omap2430_probe(struct
>>  			pdev->num_resources);
>>  	if (ret) {
>>  		dev_err(&pdev->dev, "failed to add resources\n");
>> -		goto err4;
>> +		goto err2;
>>  	}
>>
>>  	ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
>>  	if (ret) {
>>  		dev_err(&pdev->dev, "failed to add platform_data\n");
>> -		goto err4;
>> +		goto err2;
>>  	}
>>
>>  	ret = platform_device_add(musb);
>>  	if (ret) {
>>  		dev_err(&pdev->dev, "failed to register musb device\n");
>> -		goto err4;
>> +		goto err2;
>>  	}
>>
>> -	return 0;
>> +	pm_runtime_enable(&pdev->dev);
>> +	if (pm_runtime_get_sync(&pdev->dev)) {
>> +		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
>> +		pm_runtime_disable(&pdev->dev);
>> +		goto err2;
>> +	}
>>
>> -err4:
>> -	clk_disable(clk);
>> +	return 0;
>>
>> -err3:
>> -	clk_put(clk);
>>
>>  err2:
>>  	platform_device_put(musb);
>> @@ -468,8 +434,8 @@ static int __exit omap2430_remove(struct
>>
>>  	platform_device_del(glue->musb);
>>  	platform_device_put(glue->musb);
>> -	clk_disable(glue->clk);
>> -	clk_put(glue->clk);
>> +	pm_runtime_put_sync(&pdev->dev);
>> +	pm_runtime_disable(&pdev->dev);
>>  	kfree(glue);
>>
>>  	return 0;
>> @@ -478,13 +444,11 @@ static int __exit omap2430_remove(struct
>>  #ifdef CONFIG_PM
>>  static void omap2430_save_context(struct musb *musb)
>>  {
>> -	musb->context.otg_sysconfig = musb_readl(musb->mregs,
>OTG_SYSCONFIG);
>>  	musb->context.otg_forcestandby =
>musb_readl(musb->mregs, OTG_FORCESTDBY);
>>  }
>>
>>  static void omap2430_restore_context(struct musb *musb)
>>  {
>> -	musb_writel(musb->mregs, OTG_SYSCONFIG,
>musb->context.otg_sysconfig);
>>  	musb_writel(musb->mregs, OTG_FORCESTDBY,
>musb->context.otg_forcestandby);
>>  }
>>
>> @@ -496,8 +460,11 @@ static int omap2430_suspend(struct devic
>>  	omap2430_low_level_exit(musb);
>>  	otg_set_suspend(musb->xceiv, 1);
>>  	omap2430_save_context(musb);
>> -	clk_disable(glue->clk);
>>
>> +	if (pm_runtime_put_sync(dev)) {
>> +		dev_err(dev, "pm_runtime_put_sync FAILED");
>> +		return -EINVAL;
>> +	}
>
>runtime suspend transitions are disabled when system suspend/resume is
>happening, so if the device is not already runtime suspended, this call
>will have no effect, and the OTG block will be active during suspend
>(preventing it's powerdomain from hitting retention/off.)
>
>What is needed here is a direct call into the bus runtime methods.  See
>the similar patch I did for i2c:
>

Thanks for the info. Yesterday while testing the power management I
realized this.
And I changed it as per your I2C patch. I will send the new version
of patch soon on this.

Regards,
Hema
>	http://marc.info/?l=linux-omap&m=129617401612954&w=2
>
>Kevin
>
>
>
>>  	return 0;
>>  }
>>
>> @@ -505,14 +472,11 @@ static int omap2430_resume(struct device
>>  {
>>  	struct omap2430_glue		*glue = dev_get_drvdata(dev);
>>  	struct musb			*musb = glue_to_musb(glue);
>> -	int				ret;
>>
>> -	ret = clk_enable(glue->clk);
>> -	if (ret) {
>> -		dev_err(dev, "faled to enable clock\n");
>> -		return ret;
>> +	if (pm_runtime_get_sync(dev)) {
>> +		dev_err(dev, "pm_runtime_get_sync FAILED");
>> +		return -EINVAL;
>>  	}
>> -
>>  	omap2430_low_level_init(musb);
>>  	omap2430_restore_context(musb);
>>  	otg_set_suspend(musb->xceiv, 0);
>> Index: usb/drivers/usb/musb/musb_core.h
>> ===================================================================
>> --- usb.orig/drivers/usb/musb/musb_core.h
>> +++ usb/drivers/usb/musb/musb_core.h
>> @@ -360,7 +360,7 @@ struct musb_context_registers {
>>
>>  #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
>>      defined(CONFIG_ARCH_OMAP4)
>> -	u32 otg_sysconfig, otg_forcestandby;
>> +	u32 otg_forcestandby;
>>  #endif
>>  	u8 power;
>>  	u16 intrtxe, intrrxe;
>
>

Regards,
Hema
>

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

* RE: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
  2011-02-09  0:03   ` Kevin Hilman
@ 2011-02-10 13:34     ` Hema Kalliguddi
  2011-02-10 16:42       ` Kevin Hilman
  0 siblings, 1 reply; 19+ messages in thread
From: Hema Kalliguddi @ 2011-02-10 13:34 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: linux-usb, linux-omap, Felipe Balbi, Tony Lindgren,
	Benoit Cousson, Paul Walmsley

 Kevin,

>-----Original Message-----
>From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
>Sent: Wednesday, February 09, 2011 5:33 AM
>To: Hema HK
>Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org;
>Felipe Balbi; Tony Lindgren; Cousson, Benoit; Paul Walmsley
>Subject: Re: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
>
>On Fri, 2010-12-10 at 20:05 +0530, Hema HK wrote:
>> Using omap_device_build API instead of platform_device_register for
>> OMAP2430,OMAP34xx and OMAP4430 musb device registration.
>> The device specific resources defined in centralized
>> database will be used.
>>
>> Signed-off-by: Hema HK <hemahk@ti.com>
>> Cc: Felipe Balbi <balbi@ti.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Kevin Hilman <khilman@deeprootsystems.com>
>> Cc: Cousson, Benoit <b-cousson@ti.com>
>> Cc: Paul Walmsley <paul@pwsan.com>
>> ---
>>  arch/arm/mach-omap2/usb-musb.c |   76
>+++++++++++++++++++++++++++++------------
>>  1 file changed, 55 insertions(+), 21 deletions(-)
>>
>> Index: usb/arch/arm/mach-omap2/usb-musb.c
>> ===================================================================
>> --- usb.orig/arch/arm/mach-omap2/usb-musb.c
>> +++ usb/arch/arm/mach-omap2/usb-musb.c
>> @@ -31,9 +31,12 @@
>>  #include <mach/am35xx.h>
>>  #include <plat/usb.h>
>>  #include "control.h"
>> +#include <plat/omap_device.h>
>>
>>  #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined
>(CONFIG_USB_MUSB_AM35X)
>>
>> +static const char name[] = "musb-omap2430";
>> +
>>  static void am35x_musb_reset(void)
>>  {
>>  	u32	regval;
>> @@ -170,7 +173,7 @@ static struct musb_hdrc_platform_data mu
>>  static u64 musb_dmamask = DMA_BIT_MASK(32);
>>
>>  static struct platform_device musb_device = {
>> -	.name		= "musb-omap2430",
>> +	.name		= "musb-am35x",
>
>Should be in AM35x specific code.
>
>>  	.id		= -1,
>>  	.dev = {
>>  		.dma_mask		= &musb_dmamask,
>> @@ -181,26 +184,23 @@ static struct platform_device musb_devic
>>  	.resource	= musb_resources,
>>  };
>>
>> +static struct omap_device_pm_latency omap_musb_latency[] = {
>> +	{
>> +		.deactivate_func = omap_device_idle_hwmods,
>> +		.activate_func   = omap_device_enable_hwmods,
>> +		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
>> +	},
>> +};
>> +
>>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>  {
>> -	if (cpu_is_omap243x()) {
>> -		musb_resources[0].start = OMAP243X_HS_BASE;
>> -	} else if (cpu_is_omap3517() || cpu_is_omap3505()) {
>> -		musb_device.name = "musb-am35x";
>> -		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
>> -		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
>> -		board_data->set_phy_power = am35x_musb_phy_power;
>> -		board_data->clear_irq = am35x_musb_clear_irq;
>> -		board_data->set_mode = am35x_musb_set_mode;
>> -		board_data->reset = am35x_musb_reset;
>> -	} else if (cpu_is_omap34xx()) {
>> -		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
>> -	} else if (cpu_is_omap44xx()) {
>> -		musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
>> -		musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
>> -		musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
>> -	}
>> -	musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
>> +	struct omap_hwmod *oh;
>> +	struct omap_device *od;
>> +	struct platform_device *pdev;
>> +	struct device	*dev;
>> +	int bus_id = -1;
>> +	const char *oh_name = "usb_otg_hs";
>> +	struct musb_hdrc_platform_data *pdata;
>>
>>  	/*
>>  	 * REVISIT: This line can be removed once all the
>platforms using
>> @@ -212,8 +212,42 @@ void __init usb_musb_init(struct omap_mu
>>  	musb_plat.mode = board_data->mode;
>>  	musb_plat.extvbus = board_data->extvbus;
>>
>> -	if (platform_device_register(&musb_device) < 0)
>> -		printk(KERN_ERR "Unable to register HS-USB
>(MUSB) device\n");
>> +	if (cpu_is_omap3517() || cpu_is_omap3505()) {
>> +		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
>> +		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
>> +		board_data->set_phy_power = am35x_musb_phy_power;
>> +		board_data->clear_irq = am35x_musb_clear_irq;
>> +		board_data->set_mode = am35x_musb_set_mode;
>> +		board_data->reset = am35x_musb_reset;
>> +		musb_resources[0].end = musb_resources[0].start
>+ SZ_4K - 1;
>> +
>> +		if (platform_device_register(&musb_device) < 0)
>> +			printk(KERN_ERR "Unable to register HS-USB \
>> +					(MUSB) device\n");
>
>The need for  'if cpu_is_*' here should be a red flag indicating a
>problem with this code.
>
>The goal of hwmod was to be able to get rid of this kind of cpu_is_*
>cruft.  At least the base and IRQ stuff should not be needed
>here.  What
>is needed is hwmod data for AM35x where it is different from the
>"normal" OMAP3.

This file shared between the OMAP3 and AM35x.
Since there is no HWMOD adaptation done for AM35x we have to live this
till
that is done.

>
>I'm not exactly sure what the rest of these pdata function pointers are
>doing here since there seems to be an AM35x specific version of the
>driver in drivers/usb/musb, but that part isn't for me to decide.
>
There was discussion with Felipe and Benoit on this
and decided to go with cpu check till the HWMOD adaption is done for
AM35x.

Regards,
Hema

>Kevin
>
>
>> +	} else {
>> +		oh = omap_hwmod_lookup(oh_name);
>> +		if (!oh) {
>> +			pr_err("Could not look up %s\n", oh_name);
>> +			return;
>> +	 	}
>> +
>> +		pdata = &musb_plat;
>> +		od = omap_device_build(name, bus_id, oh, pdata,
>> +				       sizeof(*pdata),
>omap_musb_latency,
>> +				
>ARRAY_SIZE(omap_musb_latency), false);
>> +		if (IS_ERR(od)) {
>> +			pr_err("Could not build omap_device for
>%s %s\n",
>> +							name, oh_name);
>> +			return;
>> +		}
>> +
>> +		pdev = &od->pdev;
>> +		dev = &pdev->dev;
>> +		get_device(dev);
>> +		dev->dma_mask = &musb_dmamask;
>> +		dev->coherent_dma_mask = musb_dmamask;
>> +		put_device(dev);
>> +	}
>>  }
>>
>>  #else
>
>
>

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

* Re: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
  2011-02-10 13:34     ` Hema Kalliguddi
@ 2011-02-10 16:42       ` Kevin Hilman
  0 siblings, 0 replies; 19+ messages in thread
From: Kevin Hilman @ 2011-02-10 16:42 UTC (permalink / raw)
  To: Hema Kalliguddi
  Cc: linux-usb, linux-omap, Felipe Balbi, Tony Lindgren,
	Benoit Cousson, Paul Walmsley

Hema Kalliguddi <hemahk@ti.com> writes:

>  Kevin,
>
>>-----Original Message-----
>>From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
>>Sent: Wednesday, February 09, 2011 5:33 AM
>>To: Hema HK
>>Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org;
>>Felipe Balbi; Tony Lindgren; Cousson, Benoit; Paul Walmsley
>>Subject: Re: [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation for musb.
>>
>>On Fri, 2010-12-10 at 20:05 +0530, Hema HK wrote:
>>> Using omap_device_build API instead of platform_device_register for
>>> OMAP2430,OMAP34xx and OMAP4430 musb device registration.
>>> The device specific resources defined in centralized
>>> database will be used.
>>>
>>> Signed-off-by: Hema HK <hemahk@ti.com>
>>> Cc: Felipe Balbi <balbi@ti.com>
>>> Cc: Tony Lindgren <tony@atomide.com>
>>> Cc: Kevin Hilman <khilman@deeprootsystems.com>
>>> Cc: Cousson, Benoit <b-cousson@ti.com>
>>> Cc: Paul Walmsley <paul@pwsan.com>
>>> ---
>>>  arch/arm/mach-omap2/usb-musb.c |   76
>>+++++++++++++++++++++++++++++------------
>>>  1 file changed, 55 insertions(+), 21 deletions(-)
>>>
>>> Index: usb/arch/arm/mach-omap2/usb-musb.c
>>> ===================================================================
>>> --- usb.orig/arch/arm/mach-omap2/usb-musb.c
>>> +++ usb/arch/arm/mach-omap2/usb-musb.c
>>> @@ -31,9 +31,12 @@
>>>  #include <mach/am35xx.h>
>>>  #include <plat/usb.h>
>>>  #include "control.h"
>>> +#include <plat/omap_device.h>
>>>
>>>  #if defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined
>>(CONFIG_USB_MUSB_AM35X)
>>>
>>> +static const char name[] = "musb-omap2430";
>>> +
>>>  static void am35x_musb_reset(void)
>>>  {
>>>  	u32	regval;
>>> @@ -170,7 +173,7 @@ static struct musb_hdrc_platform_data mu
>>>  static u64 musb_dmamask = DMA_BIT_MASK(32);
>>>
>>>  static struct platform_device musb_device = {
>>> -	.name		= "musb-omap2430",
>>> +	.name		= "musb-am35x",
>>
>>Should be in AM35x specific code.
>>
>>>  	.id		= -1,
>>>  	.dev = {
>>>  		.dma_mask		= &musb_dmamask,
>>> @@ -181,26 +184,23 @@ static struct platform_device musb_devic
>>>  	.resource	= musb_resources,
>>>  };
>>>
>>> +static struct omap_device_pm_latency omap_musb_latency[] = {
>>> +	{
>>> +		.deactivate_func = omap_device_idle_hwmods,
>>> +		.activate_func   = omap_device_enable_hwmods,
>>> +		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
>>> +	},
>>> +};
>>> +
>>>  void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>>  {
>>> -	if (cpu_is_omap243x()) {
>>> -		musb_resources[0].start = OMAP243X_HS_BASE;
>>> -	} else if (cpu_is_omap3517() || cpu_is_omap3505()) {
>>> -		musb_device.name = "musb-am35x";
>>> -		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
>>> -		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
>>> -		board_data->set_phy_power = am35x_musb_phy_power;
>>> -		board_data->clear_irq = am35x_musb_clear_irq;
>>> -		board_data->set_mode = am35x_musb_set_mode;
>>> -		board_data->reset = am35x_musb_reset;
>>> -	} else if (cpu_is_omap34xx()) {
>>> -		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
>>> -	} else if (cpu_is_omap44xx()) {
>>> -		musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
>>> -		musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
>>> -		musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
>>> -	}
>>> -	musb_resources[0].end = musb_resources[0].start + SZ_4K - 1;
>>> +	struct omap_hwmod *oh;
>>> +	struct omap_device *od;
>>> +	struct platform_device *pdev;
>>> +	struct device	*dev;
>>> +	int bus_id = -1;
>>> +	const char *oh_name = "usb_otg_hs";
>>> +	struct musb_hdrc_platform_data *pdata;
>>>
>>>  	/*
>>>  	 * REVISIT: This line can be removed once all the
>>platforms using
>>> @@ -212,8 +212,42 @@ void __init usb_musb_init(struct omap_mu
>>>  	musb_plat.mode = board_data->mode;
>>>  	musb_plat.extvbus = board_data->extvbus;
>>>
>>> -	if (platform_device_register(&musb_device) < 0)
>>> -		printk(KERN_ERR "Unable to register HS-USB
>>(MUSB) device\n");
>>> +	if (cpu_is_omap3517() || cpu_is_omap3505()) {
>>> +		musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
>>> +		musb_resources[1].start = INT_35XX_USBOTG_IRQ;
>>> +		board_data->set_phy_power = am35x_musb_phy_power;
>>> +		board_data->clear_irq = am35x_musb_clear_irq;
>>> +		board_data->set_mode = am35x_musb_set_mode;
>>> +		board_data->reset = am35x_musb_reset;
>>> +		musb_resources[0].end = musb_resources[0].start
>>+ SZ_4K - 1;
>>> +
>>> +		if (platform_device_register(&musb_device) < 0)
>>> +			printk(KERN_ERR "Unable to register HS-USB \
>>> +					(MUSB) device\n");
>>
>>The need for  'if cpu_is_*' here should be a red flag indicating a
>>problem with this code.
>>
>>The goal of hwmod was to be able to get rid of this kind of cpu_is_*
>>cruft.  At least the base and IRQ stuff should not be needed
>>here.  What
>>is needed is hwmod data for AM35x where it is different from the
>>"normal" OMAP3.
>
> This file shared between the OMAP3 and AM35x.
> Since there is no HWMOD adaptation done for AM35x we have to live this
> till
> that is done.
>
>>
>>I'm not exactly sure what the rest of these pdata function pointers are
>>doing here since there seems to be an AM35x specific version of the
>>driver in drivers/usb/musb, but that part isn't for me to decide.
>>
> There was discussion with Felipe and Benoit on this
> and decided to go with cpu check till the HWMOD adaption is done for
> AM35x.

If we allow this now, then nobody will create a hwmod for AM35x.

Felipe will make the final decision, but my recommendation is to not
merge this as is.

Note that this series does not need to add omap_hwmod data entries for
all AM35x IPs that are different.  Just add one for the OTG block
Adding a hwmod entry for the OTG block on AM35x should be trivial, and
much preferred to this workaround.

Kevin

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

end of thread, other threads:[~2011-02-10 16:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-10 14:35 Subject: [PATCH 0/5 v5]usb: musb: hwmod and runtime pm support for musb Hema HK
2010-12-10 14:35 ` [PATCH 4/5 v5] OMAP2+: musb: HWMOD adaptation " Hema HK
2011-02-03  5:56   ` Hema Kalliguddi
2011-02-09  0:03   ` Kevin Hilman
2011-02-10 13:34     ` Hema Kalliguddi
2011-02-10 16:42       ` Kevin Hilman
     [not found] ` <1291991739-21705-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2010-12-10 14:35   ` [PATCH 1/5 v5] OMAP2430: hwmod data: Add USBOTG Hema HK
     [not found]     ` <1291991739-21705-2-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2011-02-03  5:54       ` Hema Kalliguddi
     [not found]         ` <3b6a23e346e75947e09f70dae78f2d88-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-03  9:25           ` Felipe Balbi
2011-02-09  0:55             ` Kevin Hilman
2010-12-10 14:35   ` [PATCH 2/5 v5] OMAP3xxx: " Hema HK
     [not found]     ` <1291991739-21705-3-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2011-02-03  5:55       ` Hema Kalliguddi
2010-12-10 14:35   ` [PATCH 3/5 v5] OMAP4430: hwmod data: Adding USBOTG Hema HK
2011-02-03  5:55     ` Hema Kalliguddi
2010-12-10 14:35   ` [PATCH 5/5 v5] usb: musb: Using runtime pm APIs for musb Hema HK
     [not found]     ` <1291991739-21705-6-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2010-12-10 14:38       ` Felipe Balbi
2010-12-11  2:58         ` Kalliguddi, Hema
2011-02-09  0:08     ` Kevin Hilman
2011-02-09  4:23       ` Hema Kalliguddi

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.