Skip to contentSkip to conversation

Subject: [PATCH 0/5 v6]usb: musb: hwmod and runtime pm support for musb

PATCH Superseded Hema HK 5 participants 15 messages Feb 10, 2011 – Feb 16, 2011 5 messages not in the archive

Subsystems (7)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Hema HK

author
#0 lore raw

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.38-rc4 + [1] +[2]

[1] https://patchwork.kernel.org/patch/513461
[2] http://www.spinics.net/lists/linux-usb/msg40575.html

with this patch series tested musb functionality like testusb, masstorage OMAP4430SDP, OMAP3430SDP, and OMAP3630 zoom3.

Tested global suspend resume for offmode and retention on OMAP3630Zoom3. Idle path retention and offmode validation is not done with these patch series.

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

Version V6

Calling runtime_pm_suspend in the pm_ops function was not effective. So using the bus runtime methods directly in the pm_ops suspend/resume functions.

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/[email protected]/msg35488.html
http://www.mail-archive.com/[email protected]/msg33201.html
http://www.mail-archive.com/[email protected]/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/[email protected]/msg34068.html
http://www.mail-archive.com/[email protected]/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/[email protected]/msg32973.html

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>

---

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 |   98 +++++++++++++++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  101 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   93 +++++++++++++++++++++++++
 arch/arm/mach-omap2/usb-musb.c             |   76 +++++++++++++++------
 drivers/usb/musb/musb_core.h               |    2 +-
 drivers/usb/musb/omap2430.c                |   79 ++++++----------------
 6 files changed, 369 insertions(+), 80 deletions(-)

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

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

author
#2 lore raw

PATCH v6 1/5 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.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   98 +++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
arch/arm/mach-omap2/omap_hwmod_2430_data.c +98 -0
Index: linux-2.6/arch/arm/mach-omap2/omap_hwmod_2430_data.c
===================================================================
@@ -89,6 +89,16 @@ static struct omap_hwmod omap2430_uart3_
 static struct omap_hwmod omap2430_i2c1_hwmod;
 static struct omap_hwmod omap2430_i2c2_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,
+};
+
 /* I2C IP block address space length (in bytes) */
 #define OMAP2_I2C_AS_LEN		128
 
@@ -189,6 +199,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,
@@ -919,6 +958,62 @@ static struct omap_hwmod omap2430_dma_sy
 	.flags		= HWMOD_NO_IDLEST,
 };
 
+/*
+ * 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,
@@ -941,6 +1036,9 @@ static __initdata struct omap_hwmod *oma
 
 	/* dma_system class*/
 	&omap2430_dma_system_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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

PATCH v6 4/5 OMAP2+: musb: HWMOD adaptation for musb. registration

In reply to a message not in the archive

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.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/usb-musb.c |   76 +++++++++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 21 deletions(-)
arch/arm/mach-omap2/usb-musb.c +55 -21
Index: linux-2.6/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

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

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

#5 lore raw

Re: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for musb. registration

Quoted 4 lines · Hema HK

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.

Except for AM35x.

NACK, for same reasons as previous version of this patch.

Kevin

Quoted 124 lines
Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/usb-musb.c |   76 +++++++++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 21 deletions(-)

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

arch/arm/mach-omap2/usb-musb.c +55 -22
@@ -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
--
Quoted 3 lines

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

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

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

#7 lore raw

RE: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for musb. registration

Kevin,

Quoted 11 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 5:45 AM
To: Hema HK
Cc: [email protected]; [email protected]; Felipe Balbi; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for
musb. registration

Hema HK <[email protected]> writes:

Quoted 9 lines
Quoted 4 lines

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.

Except for AM35x.

NACK, for same reasons as previous version of this patch.

AM35x boot is already broken with existing HWmod changes done for V2.6.38 release.
I think Ajay's team is debugging this issue.
Since there is no separate CHIP revision for AM35x compared to OMAP3430 today,
there will be conflict to add OMAP3 usbotg and AM35x usbotg together.

I think we should go for OMAP3 HWmod independent of the AM35x. If required we should have 2 separate platform file as there is very less shared code in usb-musb.c file between the OMAP2+ and AM35x.

Ajay/Felipe,

Any comments on this?

Regards,
Hema

Quoted 132 lines

Kevin

Quoted 8 lines
Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/usb-musb.c |   76

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

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

Quoted 13 lines
 1 file changed, 55 insertions(+), 21 deletions(-)

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

arch/arm/mach-omap2/usb-musb.c +1 -0
@@ -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)

Quoted 47 lines
arch/arm/mach-omap2/usb-musb.c +11 -19
+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;

arch/arm/mach-omap2/usb-musb.c static struct platform_device musb_devic · line 206

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +7 -0
+	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

arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 216

Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +0 -2
@@ -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");

arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu

Quoted 8 lines
arch/arm/mach-omap2/usb-musb.c +8 -0
+	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;

Quoted 4 lines
arch/arm/mach-omap2/usb-musb.c +4 -0
+
+		if (platform_device_register(&musb_device) < 0)
+			printk(KERN_ERR "Unable to register HS-USB \
+					(MUSB) device\n");

arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu

Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +10 -0
+	} 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,

arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 237

Quoted 1 line
arch/arm/mach-omap2/usb-musb.c +1 -0
+				

ARRAY_SIZE(omap_musb_latency), false);

arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 239

Quoted 2 lines
arch/arm/mach-omap2/usb-musb.c +2 -0
+		if (IS_ERR(od)) {
+			pr_err("Could not build omap_device for

%s %s\n",

Quoted 13 lines
arch/arm/mach-omap2/usb-musb.c +11 -0
+							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);
+	}
 }
 
Quoted 7 lines
Quoted 3 lines
arch/arm/mach-omap2/usb-musb.c +0 -1
 #else
--

To unsubscribe from this list: send the line "unsubscribe

linux-omap" in

Quoted 2 lines

the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

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

#8 lore raw

Re: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for musb. registration

In reply to Kevin Hilman
Quoted 10 lines · Kevin Hilman
Quoted 4 lines · Hema HK

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.

Except for AM35x.

NACK, for same reasons as previous version of this patch.

Does it really make sense to hold on omap2plus HWMOD conversion because of AM35x ? I mean, I understand it would be better to get all fixed up, but loose another merge window for that ?

Can we get omap2plus in and AM35x on the next merge window ? At least omap2plus would have been converted to hwmod and would be using pm_runtime as we want.

Signature · 1 line
balbi
#9 lore raw

Re: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for musb. registration

Hi Felipe,

Quoted 12 lines · Felipe Balbi
Quoted 10 lines · Kevin Hilman
Quoted 4 lines · Hema HK

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.

Except for AM35x.

NACK, for same reasons as previous version of this patch.

Quoted 7 lines

Does it really make sense to hold on omap2plus HWMOD conversion because of AM35x ? I mean, I understand it would be better to get all fixed up, but loose another merge window for that ?

Can we get omap2plus in and AM35x on the next merge window ? At least omap2plus would have been converted to hwmod and would be using pm_runtime as we want.

Well, you get to decide as you're the maintainer of this stuff. ;)

If you merge it, I suggest at least fixing the changelog to make it clear that not all devices are using hwmod.

That being said, how difficult is it to add the hwmod data for the AM35x
OTG block? Just added it to the exising OMAP3 data using CHIP_IS* to
marke it as AM35x, and you can at least get rid of the base address and IRQ number hacks for AM35x in this code.

Separating out the pdata function pointer hooks is a different matter which is also ugly, but I don't feel as strongly about.

Kevin

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

#11 lore raw

RE: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for musb. registration

Hi,

Quoted 33 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, February 15, 2011 9:42 PM
To: [email protected]
Cc: Hema HK; [email protected]; [email protected]; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 4/5 v6] OMAP2+: musb: HWMOD adaptation for
musb. registration

Hi Felipe,

Quoted 4 lines · Felipe Balbi
Quoted 3 lines · Kevin Hilman
Quoted 1 line · Hema HK

Using omap_device_build API instead of

platform_device_register for

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

OMAP2430,OMAP34xx and OMAP4430 musb device registration. The device specific resources defined in centralized database will be used.

Except for AM35x.

NACK, for same reasons as previous version of this patch.

Does it really make sense to hold on omap2plus HWMOD

conversion because

Quoted 1 line

of AM35x ? I mean, I understand it would be better to get

all fixed up,

Quoted 2 lines

but loose another merge window for that ?

Quoted 9 lines
Quoted 3 lines

Can we get omap2plus in and AM35x on the next merge window ? At least omap2plus would have been converted to hwmod and would be using pm_runtime as we want.

Well, you get to decide as you're the maintainer of this stuff. ;)

If you merge it, I suggest at least fixing the changelog to make it clear that not all devices are using hwmod.

I have a patch ready for adding hwmod for AM35x. But there is one issue with
co-existance of omap3 musb hwmod and am35x. I think this is already a problem
with current mainline with smart reflex hwmod changes.

For AM35x there is no separate CHIP_IS_*. So anything added in the omap3 hwmod database with CHIP_IS_OMAP3430 is considered for AM35x and if that module soes not exists there will be crash.

I think for this issue Sanjeev Premi has send a mail on the list.

Quoted 5 lines

That being said, how difficult is it to add the hwmod data for the AM35x
OTG block? Just added it to the exising OMAP3 data using CHIP_IS* to
marke it as AM35x, and you can at least get rid of the base address and IRQ number hacks for AM35x in this code.

This can be done. I will be posting the patch for AM35x hwmod also.

Quoted 3 lines

Separating out the pdata function pointer hooks is a different matter which is also ugly, but I don't feel as strongly about.

I have another patch to move all the board specific internal PHY functions to another file and pass them through board data instead of defining and assigning here in the shared file.

Regards,
Hema

Quoted 7 lines

Kevin

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

author
#12 lore raw

PATCH v6 5/5 usb: musb: Using runtime pm APIs for musb.

In reply to a message not in the archive

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

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 drivers/usb/musb/musb_core.h |    2 -
 drivers/usb/musb/omap2430.c  |   79 +++++++++++--------------------------------
 2 files changed, 22 insertions(+), 59 deletions(-)
drivers/usb/musb/musb_core.h +1 -1
Index: linux-2.6/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;
drivers/usb/musb/omap2430.c +21 -58

178 lines not on this page · raw message

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

#13 lore raw

Re: [PATCH 5/5 v6] usb: musb: Using runtime pm APIs for musb.

Hi,

Quoted 6 lines · Hema HK

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.

does it have to be the _sync() ??

Quoted 49 lines

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

drivers/usb/musb/omap2430.c +2 -12
@@ -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);
@@ -309,21 +302,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 */

drivers/usb/musb/omap2430.c static int omap2430_musb_init(struct mus · line 324

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

is this taken care somewhere else ?

Quoted 15 lines
drivers/usb/musb/omap2430.c +2 -2
@@ -431,28 +395,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;
 	}
 

drivers/usb/musb/omap2430.c static int __init omap2430_probe(struct · line 414

Quoted 10 lines
drivers/usb/musb/omap2430.c +3 -2
 	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) < 0) {

you have the status variable, so how about:

status = pm_runtime_get_sync(&pdev->dev);
if (status < 0) {

??

drivers/usb/musb/omap2430.c static int __init omap2430_probe(struct · line 416

Quoted 2 lines
drivers/usb/musb/omap2430.c +2 -0
+		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
+		pm_runtime_disable(&pdev->dev);

move the pm_runtime_disable() to err3, maybe. Then just call goto err3 here.

Signature · 1 line
balbi
#14 lore raw

RE: [PATCH 5/5 v6] usb: musb: Using runtime pm APIs for musb.

Hi,

Quoted 16 lines

-----Original Message-----
From: Felipe Balbi [mailto:[email protected]]
Sent: Thursday, February 10, 2011 7:56 PM
To: Hema HK
Cc: [email protected]; [email protected]; Felipe Balbi; Tony Lindgren; Kevin Hilman; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 5/5 v6] usb: musb: Using runtime pm APIs for musb.

Hi,

Quoted 1 line · Hema HK

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 2 lines

for enabling/disabling the clocks, sysconfig settings.

Quoted 7 lines
Quoted 1 line

Enable clock, configure no-idle/standby when active and

configure force idle/standby

Quoted 1 line

and disable clock when idled. This is taken care by the

runtime framework when

Quoted 1 line

driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.

does it have to be the _sync() ??

Yes. Because immediately after this I access the registers.

Quoted 47 lines
Quoted 47 lines

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

drivers/usb/musb/omap2430.c +2 -9
@@ -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);
@@ -309,21 +302,6 @@ static int omap2430_musb_init(struct mus
 
 	omap2430_low_level_init(musb);
 
Quoted 15 lines

drivers/usb/musb/omap2430.c static int omap2430_musb_init(struct mus · line 324

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

is this taken care somewhere else ?

Yes. In HWMOD data structure, there is a flag defined.

Quoted 29 lines
Quoted 16 lines
drivers/usb/musb/omap2430.c +2 -2
@@ -431,28 +395,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;
 	}
 

drivers/usb/musb/omap2430.c static int __init omap2430_probe(struct · line 414

Quoted 10 lines
drivers/usb/musb/omap2430.c +3 -2
 	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) < 0) {

you have the status variable, so how about:

Quoted 6 lines

status = pm_runtime_get_sync(&pdev->dev);
if (status < 0) {

??

Can be done.

Quoted 5 lines

drivers/usb/musb/omap2430.c static int __init omap2430_probe(struct · line 416

Quoted 2 lines
drivers/usb/musb/omap2430.c +2 -0
+		dev_err(&pdev->dev, "pm_runtime_get_sync FAILED");
+		pm_runtime_disable(&pdev->dev);

move the pm_runtime_disable() to err3, maybe. Then just call goto err3 here.

Yes.

Regards,
Hema

Quoted 4 lines

--
balbi

#15 lore raw

Re: [PATCH 5/5 v6] usb: musb: Using runtime pm APIs for musb.

Hema Kalliguddi <[email protected]> writes:

[...]

Quoted 5 lines
Quoted 5 lines · Hema HK
Quoted 1 line

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 2 lines

for enabling/disabling the clocks, sysconfig settings.

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

Enable clock, configure no-idle/standby when active and

configure force idle/standby

Quoted 1 line

and disable clock when idled. This is taken care by the

runtime framework when

Quoted 1 line

driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.

does it have to be the _sync() ??

Yes. Because immediately after this I access the registers.

What about the put?

Kevin

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

#17 lore raw

Re: [PATCH 5/5 v6] usb: musb: Using runtime pm APIs for musb.

Quoted 12 lines · Kevin Hilman

Hema Kalliguddi <[email protected]> writes:

[...]

Quoted 8 lines
Quoted 8 lines · Hema HK
Quoted 1 line

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines

for enabling/disabling the clocks, sysconfig settings.

Enable clock, configure no-idle/standby when active and

configure force idle/standby

Quoted 1 line

and disable clock when idled. This is taken care by the

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

runtime framework when

Quoted 1 line

driver calls the pm_runtime_get_sync and pm_runtime_put_sync APIs.

does it have to be the _sync() ??

Yes. Because immediately after this I access the registers.

What about the put?

Put can be async. I will send the patch with changes.

Regards,
Hema

Quoted 4 lines

Kevin

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

#18 lore raw

PATCH v6 2/5 OMAP3xxx: hwmod data: Add USBOTG

In reply to Hema HK

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.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  101 +++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +101 -0
Index: linux-2.6/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
===================================================================
@@ -107,6 +107,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 = {
@@ -301,6 +310,36 @@ static struct omap_hwmod_ocp_if omap3_l4
 	.user		= OCP_USER_MPU,
 };
 
+/*
+* 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,
@@ -1356,6 +1395,64 @@ static struct omap_hwmod omap36xx_sr2_hw
 	.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,
@@ -1387,6 +1484,10 @@ static __initdata struct omap_hwmod *oma
 
 	/* dma_system class*/
 	&omap3xxx_dma_system_hwmod,
+
+	/* usbotg class */
+	&omap3xxx_usbhsotg_hwmod,
+
 	NULL,
 };
 
#19 lore raw

PATCH v6 3/5 OMAP4430: hwmod data: Adding USBOTG

In reply to Hema HK

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.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   93 +++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +93 -0
Index: linux-2.6/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
===================================================================
@@ -55,6 +55,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
@@ -286,12 +287,21 @@ 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_dma_system__l3_main_2,
 	&omap44xx_iva__l3_main_2,
 	&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 = {
@@ -2001,6 +2011,87 @@ static struct omap_hwmod omap44xx_wd_tim
 	.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 */
@@ -2068,6 +2159,8 @@ static __initdata struct omap_hwmod *oma
 	&omap44xx_wd_timer2_hwmod,
 	&omap44xx_wd_timer3_hwmod,
 
+	/* hsusb otg class */
+	&omap44xx_usb_otg_hs_hwmod,
 	NULL,
 };