usb: otg: enable regulator only on cable/device connect
Subsystems (6)
PATCH v4 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 ++++++++++++---------------
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" );
--
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 v4 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 v4 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/musb_gadget.c | 4 +++ drivers/usb/musb/omap2430.c | 53 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 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 v4 2/7 usb: otg: Remove one unnecessary I2C read request.
In reply to Hema HKFrom: 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 ++-----
drivers/usb/otg/twl6030-usb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/usb/otg/twl6030-usb.c +2 -5
@@ -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 ); - -if (hw_state &STS_USB_ID ) +if (twl->linkstat ==USB_EVENT_ID ) pdata->phy_power (twl->dev,1 ,1 );else pdata->phy_power (twl->dev,0 ,1 );
@@ -290,6 +287,7 @@ static irqreturn_t twl6030_usbotg_irq(in status =USB_EVENT_ID ; twl->otg.default_a = true; twl->otg.state =OTG_STATE_A_IDLE ; + twl->linkstat = status;blocking_notifier_call_chain (&twl->otg.notifier, status, twl->otg.gadget); }else {
@@ -299,7 +297,6 @@ static irqreturn_t twl6030_usbotg_irq(in 0x1); }twl6030_writeb (twl,TWL_MODULE_USB ,USB_ID_INT_LATCH_CLR , status); - twl->linkstat = status;return IRQ_HANDLED ; }
PATCH v4 3/7 usb: otg: OMAP4430: Add phy_suspend function pointer to twl4030_usb_data
In reply to Hema HKFrom: Kalliguddi, Hema <[email protected]>
Declare the .phy_suspend function pointer to twl4030_usb_data structure. OMAP internal phy suspend function will be hooked though this function pointer to use in the transceiver driver.
--- include/linux/i2c/twl.h | 2 ++ 1 file changed, 2 insertions(+)
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 {
PATCH v4 4/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.
Pass the suspend function through board data for OMAP4430sdp and OMAP4panda. This will be used by the twl6030-usb transceiver driver.
---arch/arm/mach-omap2/omap_phy_internal.c | 22 +++++++++++++++-------
arch/arm/mach-omap2/board-4430sdp.c | 1 + arch/arm/mach-omap2/board-omap4panda.c | 1 + arch/arm/mach-omap2/omap_phy_internal.c | 22 +++++++++++++++------- arch/arm/plat-omap/include/plat/usb.h | 1 + 4 files changed, 18 insertions(+), 7 deletions(-)
arch/arm/mach-omap2/omap_phy_internal.c +15 -7
@@ -104,13 +104,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 +
@@ -126,10 +119,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
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[] = {
PATCH v4 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 ++++++++++++++++
drivers/usb/otg/twl6030-usb.c | 13 +++++++++++++ 1 file changed, 13 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" );
Quoted 5 lines · Hema HK
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.
Quoted 8 lines
Remove the configuration of
config_stateandconfig_transregister configuration as these registers are programmed when regulator enable/disable is called.Signed-off-by Hema HK <[email protected]>Cc Felipe Balbi <[email protected]>Cc Tony Lindgren <[email protected]>Cc Paul Walmsley <[email protected]>
Taken these 7. Tested and it works fine.
Signature · 1 line
balbi
Hi,
Quoted 10 lines · Felipe Balbi
Quoted 9 lines · Hema HK
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_stateandconfig_transregister configuration as these registers are programmed when regulator enable/disable is called.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Hema HK <[email protected]>Cc Felipe Balbi <[email protected]>Cc Tony Lindgren <[email protected]>Cc Paul Walmsley <[email protected]>Taken these 7. Tested and it works fine.
actually, this series adds:
drivers/usb/otg/twl6030-usb.c: In function 'twl6030_phy_suspend':drivers/usb/otg/twl6030-usb.c:183:2: warning: ISO C90 forbids mixed declarations and code drivers/usb/otg/twl6030-usb.c: At top level:drivers/usb/otg/twl6030-usb.c:135:12: warning: 'twl6030_set_phy_clk' defined but not used
care to fix and send an incremental diff mentioning which was the offending patch please.
Signature · 1 line
balbi
Quoted 1 line · Hema HK
From: Kalliguddi, Hema <[email protected]>
You name is twisted in all this series, this will make git log look weird:
Hema HK (1):
usb: musb: Using runtime pm APIs for musb.
Kalliguddi, Hema (7):
usb: otg: enable regulator only on cable/device connect
usb: otg: Remove one unnecessary I2C read request.
usb: otg: OMAP4430: Add phy_suspend function pointer to twl4030_usb_data
usb: otg: OMAP4430: Introducing suspend function for power management
usb: otg: TWL6030: Introduce the twl6030_phy_suspend function.
usb: otg: TWL6030 Save the last event in otg_transceiver
usb: musb: OMAP4430: Fix usb device detection if connected during boot
I'll fix myself this time, but check those details too from now on.
Signature · 1 line
balbi