usb: otg: enable regulator only on cable/device connect
Subsystems (6)
PATCH v3 1/7 usb: otg: enable regulator only on cable/device connect
From: Kalliguddi, Hema <[email protected]>
Remove the regulator enable while driver loading and enable it only when the cable/device is connected and disable it when disconnected.
Remove the configuration of config_state and config_trans register configuration as these registers are programmed when regulator enable/disable is called.
---drivers/usb/otg/twl6030-usb.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
drivers/usb/otg/twl6030-usb.c +12 -15
@@ -158,8 +158,6 @@ static int twl6030_phy_init(struct otg_t dev = twl->dev; pdata = dev->platform_data; -regulator_enable (twl->usb3v3); - hw_state =twl6030_readb (twl,TWL6030_MODULE_ID0 ,STS_HW_CONDITIONS );if (hw_state &STS_USB_ID )
@@ -180,7 +178,6 @@ static void twl6030_phy_shutdown(struct dev = twl->dev; pdata = dev->platform_data; pdata->phy_power (twl->dev,0 ,0 ); -regulator_disable (twl->usb3v3); }static int twl6030_usb_ldo_init (struct twl6030_usb *twl)
@@ -199,16 +196,6 @@ static int twl6030_usb_ldo_init(struct tif (IS_ERR (twl->usb3v3))return -ENODEV ; -regulator_enable (twl->usb3v3); - -/* Program the VUSB_CFG_TRANS for ACTIVE state. */ -twl6030_writeb (twl,TWL_MODULE_PM_RECEIVER ,0x3F , -VUSB_CFG_TRANS ); - -/* Program the VUSB_CFG_STATE register to ON on all groups. */ -twl6030_writeb (twl,TWL_MODULE_PM_RECEIVER ,0xE1 , -VUSB_CFG_STATE ); -/* Program the USB_VBUS_CTRL_SET and set VBUS_ACT_COMP bit */ twl6030_writeb (twl,TWL_MODULE_USB ,0x4 ,USB_VBUS_CTRL_SET );
@@ -261,16 +248,23 @@ static irqreturn_t twl6030_usb_irq(int i CONTROLLER_STAT1);if (!(hw_state &STS_USB_ID )) {if (vbus_state &VBUS_DET ) { +regulator_enable (twl->usb3v3); + twl->asleep =1 ; status =USB_EVENT_VBUS ; twl->otg.default_a = false; twl->otg.state =OTG_STATE_B_IDLE ; + twl->linkstat = status; +blocking_notifier_call_chain (&twl->otg.notifier, + status, twl->otg.gadget); }else { status =USB_EVENT_NONE ; - } -if (status >=0 ) { twl->linkstat = status;blocking_notifier_call_chain (&twl->otg.notifier, status, twl->otg.gadget); +if (twl->asleep) { +regulator_disable (twl->usb3v3); + twl->asleep =0 ; + } } }sysfs_notify (&twl->dev->kobj,NULL ,"vbus" );
@@ -288,6 +282,8 @@ static irqreturn_t twl6030_usbotg_irq(inif (hw_state &STS_USB_ID ) { +regulator_enable (twl->usb3v3); + twl->asleep =1 ;twl6030_writeb (twl,TWL_MODULE_USB ,USB_ID_INT_EN_HI_CLR ,0x1 );twl6030_writeb (twl,TWL_MODULE_USB ,USB_ID_INT_EN_HI_SET ,0x10 );
@@ -437,6 +433,7 @@ static int __devinit twl6030_usb_probe(sreturn status; } + twl->asleep =0 ; pdata->phy_init (dev);twl6030_enable_irq (&twl->otg);dev_info (&pdev->dev,"Initialized TWL6030 USB module\n" );
A message that is not in the archive (sent off-list or not yet received): 1297857049-27367-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org
PATCH v3 2/7 usb: otg: Remove one unnecessary I2C read request.
From: Kalliguddi, Hema <[email protected]>
To get the ID status there was an I2C read transfer. Removed this I2C read transfer as this info can be used from existing variable(linkstat).
---drivers/usb/otg/twl6030-usb.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/otg/twl6030-usb.c +0 -2
@@ -149,7 +149,6 @@ static int twl6030_set_phy_clk(struct otstatic int twl6030_phy_init (struct otg_transceiver *x) { -u8 hw_state;struct twl6030_usb *twl;struct device *dev;struct twl4030_usb_data *pdata;
@@ -158,9 +157,7 @@ static int twl6030_phy_init(struct otg_t dev = twl->dev; pdata = dev->platform_data; - hw_state =twl6030_readb (twl,TWL6030_MODULE_ID0 ,STS_HW_CONDITIONS );
PATCH v3 6/7 usb: otg: TWL6030 Save the last event in otg_transceiver
In reply to a message not in the archiveFrom: Kalliguddi, Hema <[email protected]>
Save the last event in the otg_transceiver so that it can used in the musb driver and gadget driver to configure the musb and enable the vbus for host mode and OTG mode, if the device is connected during boot.
---
[Reusing some part of the patch[1] posted by Arnaud Mandy]
[1] http://permalink.gmane.org/gmane.linux.usb.general/37123
--- drivers/usb/otg/twl6030-usb.c | 3 +++ include/linux/usb/otg.h | 1 + 2 files changed, 4 insertions(+)
drivers/usb/otg/twl6030-usb.c +3 -0
@@ -262,11 +262,13 @@ static irqreturn_t twl6030_usb_irq(int i twl->otg.default_a = false; twl->otg.state =OTG_STATE_B_IDLE ; twl->linkstat = status; + twl->otg.last_event = status;blocking_notifier_call_chain (&twl->otg.notifier, status, twl->otg.gadget); }else { status =USB_EVENT_NONE ; twl->linkstat = status; + twl->otg.last_event = status;blocking_notifier_call_chain (&twl->otg.notifier, status, twl->otg.gadget);if (twl->asleep) {
@@ -299,6 +301,7 @@ static irqreturn_t twl6030_usbotg_irq(in twl->otg.default_a = true; twl->otg.state =OTG_STATE_A_IDLE ; twl->linkstat = status; + twl->otg.last_event = status;blocking_notifier_call_chain (&twl->otg.notifier, status, twl->otg.gadget); }else {
include/linux/usb/otg.h +1 -0
@@ -66,6 +66,7 @@ struct otg_transceiver {u8 default_a;enum usb_otg_state state; +enum usb_xceiv_events last_event;struct usb_bus *host;struct usb_gadget *gadget;
--
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
PATCH v3 7/7 usb: musb: OMAP4430: Fix usb device detection if connected during boot
In reply to a message not in the archiveFrom: Kalliguddi, Hema <[email protected]>
OMAP4430 is embedded with UTMI PHY. This PHY does not support the OTG features like ID pin detection and VBUS detection. This function is exported to an external companion chip TWL6030. Software must retrieve the OTG HNP and SRP status from the TWL6030 and configure the bits inside the control module that drive the related USBOTGHS UTMI interface signals. It must also read back the UTMI signals needed to configure the TWL6030 OTG module.
Can find more details in the TRM[1]. [1]:http://focus.ti.com/pdfs/wtbu/OMAP4430_ES2.0_Public_TRM_vJ.pdf
In OMAP4430 musb driver VBUS and ID notifications are received from the transceiver driver. If the cable/device is connected during boot, notifications from transceiver driver will be missed till musb driver is loaded.
Patch to configure the transceiver in the platform_enable/disable functions and enable the vbus in the gadget driver based on the last_event of the otg_transceiver.
---drivers/usb/musb/musb_gadget.c | 4 +++
drivers/usb/musb/omap2430.c | 49 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 5 deletions(-)
drivers/usb/musb/musb_gadget.c +4 -0
@@ -1855,6 +1855,10 @@ int usb_gadget_probe_driver(struct usb_g }else { hcd->self.uses_pio_for_control =1 ; } + +if ((musb->xceiv->last_event ==USB_EVENT_ID ) + && musb->xceiv->set_vbus) +otg_set_vbus (musb->xceiv,1 ); } }
drivers/usb/musb/omap2430.c +48 -5
70 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
PATCH v3 3/7 usb: otg: OMAP4430: Introducing suspend function for power management
In reply to Hema HKFrom: Kalliguddi, Hema <[email protected]>
Introduced the suspend/resume function for the OMAP4430 internal PHY. This will be used by the twl6030-usb transceiver driver. Moved the clock enable/disable function calls and power on/off of the PHY code from power on/off functions to suspend/resume function.
---arch/arm/mach-omap2/omap_phy_internal.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +15 -7
@@ -103,13 +103,6 @@ int omap4430_phy_set_clk(struct device *int omap4430_phy_power (struct device *dev,int ID ,int on) {if (on) { -/* enabled the clocks */ -omap4430_phy_set_clk (dev,1 ); -/* power on the phy */ -if (__raw_readl (ctrl_base +CONTROL_DEV_CONF ) &PHY_PD ) { -__raw_writel (~PHY_PD , ctrl_base +CONTROL_DEV_CONF ); -mdelay (200 ); - }if (ID )/* enable VBUS valid, IDDIG groung */ __raw_writel(AVALID | VBUSVALID, ctrl_base +
@@ -125,10 +118,25 @@ int omap4430_phy_power(struct device *de/* Enable session END and IDIG to high impedence. */ __raw_writel (SESSEND |IDDIG , ctrl_base +USBOTGHS_CONTROL ); + } +return 0 ; +} + +int omap4430_phy_suspend (struct device *dev,int suspend) +{ +if (suspend) {/* Disable the clocks */ omap4430_phy_set_clk (dev,0 );/* Power down the phy */ __raw_writel (PHY_PD , ctrl_base +CONTROL_DEV_CONF ); + }else { +/* Enable the internel phy clcoks */ +omap4430_phy_set_clk (dev,1 ); +/* power on the phy */ +if (__raw_readl (ctrl_base +CONTROL_DEV_CONF ) &PHY_PD ) { +__raw_writel (~PHY_PD , ctrl_base +CONTROL_DEV_CONF ); +mdelay (200 ); + } }return 0 ;
arch/arm/plat-omap/include/plat/usb.h +1 -0
@@ -88,6 +88,7 @@ extern int omap4430_phy_power(struct devextern int omap4430_phy_set_clk (struct device *dev,int on);extern int omap4430_phy_init (struct device *dev);extern int omap4430_phy_exit (struct device *dev); +extern int omap4430_phy_suspend (struct device *dev,int suspend);#endif
PATCH v3 4/7 usb: otg: OMAP4430: Add phy_suspend function pointer to twl4030_usb_data
In reply to Hema HKFrom: Kalliguddi, Hema <[email protected]>
Introduce the .phy_suspend function pointer to twl4030_usb_data structure. assign the function to it for both sdp board and panda boards. This will be used by the twl6030-usb transceiver driver.
---arch/arm/mach-omap2/board-4430sdp.c | 1 +
arch/arm/mach-omap2/board-omap4panda.c | 1 + arch/arm/plat-omap/include/plat/usb.h | 1 + include/linux/i2c/twl.h | 2 ++ 4 files changed, 5 insertions(+)
arch/arm/mach-omap2/board-4430sdp.c +1 -0
@@ -272,6 +272,7 @@ static struct twl4030_usb_data omap4_usb .phy_exit = omap4430_phy_exit, .phy_power = omap4430_phy_power, .phy_set_clock = omap4430_phy_set_clk, + .phy_suspend = omap4430_phy_suspend, };static struct omap2_hsmmc_info mmc[] = {
arch/arm/mach-omap2/board-omap4panda.c +1 -0
@@ -153,6 +153,7 @@ static struct twl4030_usb_data omap4_usb .phy_exit = omap4430_phy_exit, .phy_power = omap4430_phy_power, .phy_set_clock = omap4430_phy_set_clk, + .phy_suspend = omap4430_phy_suspend, };static struct omap2_hsmmc_info mmc[] = {
include/linux/i2c/twl.h +2 -0
@@ -600,6 +600,8 @@ struct twl4030_usb_data {int (*phy_power)(struct device *dev,int iD,int on);/* enable/disable phy clocks */ int (*phy_set_clock)(struct device *dev,int on); +/* suspend/resume of phy */ +int (*phy_suspend)(struct device *dev,int suspend); };struct twl4030_ins {
A message that is not in the archive (sent off-list or not yet received): 1297857049-27367-4-git-send-email-hemahk-l0cyMroinI0@public.gmane.org
Re: [4/7 v3] usb: otg: OMAP4430: Add phy_suspend function pointer to twl4030_usb_data
Quoted 46 lines · Hema HK
From: Kalliguddi, Hema<[email protected]>
Introduce the .phy_suspend function pointer to
twl4030_usb_datastructure. assign the function to it for both sdp board and panda boards. This will be used by the twl6030-usb transceiver driver.Signed-off-by Hema HK<[email protected]>Cc Felipe Balbi<[email protected]>Cc Tony Lindgren<[email protected]>---
arch/arm/mach-omap2/board-4430sdp.c| 1 +arch/arm/mach-omap2/board-omap4panda.c | 1 + arch/arm/plat-omap/include/plat/usb.h | 1 + include/linux/i2c/twl.h | 2 ++ 4 files changed, 5 insertions(+)Index:
linux-2.6/arch/arm/mach-omap2/board-4430sdp.c
===================================================================arch/arm/mach-omap2/board-4430sdp.c +1
-0@@ -272,6 +272,7 @@ static struct twl4030_usb_data omap4_usb .phy_exit = omap4430_phy_exit, .phy_power = omap4430_phy_power, .phy_set_clock = omap4430_phy_set_clk, + .phy_suspend = omap4430_phy_suspend, };static struct omap2_hsmmc_info mmc[] = {Index:
linux-2.6/arch/arm/mach-omap2/board-omap4panda.c
===================================================================arch/arm/mach-omap2/board-omap4panda.c +1
-0@@ -153,6 +153,7 @@ static struct twl4030_usb_data omap4_usb .phy_exit = omap4430_phy_exit, .phy_power = omap4430_phy_power, .phy_set_clock = omap4430_phy_set_clk, + .phy_suspend = omap4430_phy_suspend, };static struct omap2_hsmmc_info mmc[] = {Index:
linux-2.6/include/linux/i2c/twl.h
===================================================================
include/linux/i2c/twl.h struct twl4030_usb_data { · line 607
Quoted 8 lines
include/linux/i2c/twl.h +2
-0@@ -600,6 +600,8 @@ struct twl4030_usb_data {int (*phy_power)(struct device *dev,int iD,int on);/* enable/disable phy clocks */ int (*phy_set_clock)(struct device *dev,int on); +/* suspend/resume of phy */ +int (*phy_suspend)(struct device *dev,int suspend); };struct twl4030_ins {
You're still doing things backwards. Sigh...
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 5/7 usb: otg: TWL6030: Introduce the twl6030_phy_suspend function.
In reply to Hema HKFrom: Kalliguddi, Hema <[email protected]>
Introduce the twl6030_phy_suspend function and assign to otg.set_suspend function pointer.
This function is used by the musb-omap2430 platform driver during suspend/resume.
---drivers/usb/otg/twl6030-usb.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
drivers/usb/otg/twl6030-usb.c +13 -0
@@ -177,6 +177,17 @@ static void twl6030_phy_shutdown(struct pdata->phy_power (twl->dev,0 ,0 ); } +static int twl6030_phy_suspend (struct otg_transceiver *x,int suspend) +{ +struct twl6030_usb *twl =xceiv_to_twl (x); +struct device *dev = twl->dev; +struct twl4030_usb_data *pdata = dev->platform_data; + + pdata->phy_suspend (dev, suspend); + +return 0 ; +} +static int twl6030_usb_ldo_init (struct twl6030_usb *twl) {
@@ -388,6 +399,7 @@ static int __devinit twl6030_usb_probe(s twl->otg.set_vbus = twl6030_set_vbus; twl->otg.init = twl6030_phy_init; twl->otg.shutdown = twl6030_phy_shutdown; + twl->otg.set_suspend = twl6030_phy_suspend;/* init spinlock for workqueue */ spin_lock_init (&twl->lock);
@@ -432,6 +444,7 @@ static int __devinit twl6030_usb_probe(s twl->asleep =0 ; pdata->phy_init (dev); +twl6030_phy_suspend (&twl->otg,0 );twl6030_enable_irq (&twl->otg);dev_info (&pdev->dev,"Initialized TWL6030 USB module\n" );