usb: phy: remaining twl4030-usb/omap fixes
v3 cover usb: phy: remaining twl4030-usb/omap fixes
These are the last 3 patches of earlier twl4030-usb/omap fix series:
http://marc.info/?l=linux-usb&m=136354462519052&w=2
Changed since v2:
- simplified patch 5/7 (now 1/3) according to Felipe's suggestion
- changed vbus_supplied to be always set to true when VBUS_PRES is set, even when ID is grounded at the same time (like it was before the patch).
Grazvydas Ignotas (3):
usb: phy: twl4030-usb: check if vbus is driven by twl itself
usb: musb: omap2430: turn off vbus on cable disconnect
usb: musb: gadget: use platform callback to enable vbus
drivers/usb/musb/musb_gadget.c | 5 ++--- drivers/usb/musb/omap2430.c | 1 + drivers/usb/phy/phy-twl4030-usb.c | 31 ++++++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.9.5
A message that is not in the archive (sent off-list or not yet received): 1364139415-16695-1-git-send-email-notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v3 3/3 usb: musb: gadget: use platform callback to enable vbus
On some platform configurations (like OMAP3+twl4030) it's the platform code that enables VBUS, not OTG transceiver, so call vbus platform callback instead, it will then call the transceiver if needed.
This fixes a use case where USB cable is plugged first and gadget driver is loaded later after that.
--- drivers/usb/musb/musb_gadget.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_gadget.c +2 -3
@@ -1848,9 +1848,8 @@ static int musb_gadget_start(struct usb_gadget *g, goto err; } -if ((musb->xceiv->last_event ==USB_EVENT_ID ) - && otg->set_vbus) -otg_set_vbus (otg,1 ); +if (musb->xceiv->last_event ==USB_EVENT_ID ) +musb_platform_set_vbus (musb,1 ); hcd->self.uses_pio_for_control =1 ;
Signature · 6 lines
1.7.9.5 -- 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 1/3 usb: phy: twl4030-usb: check if vbus is driven by twl itself
In reply to Grazvydas IgnotasAt least on pandora, STS_VBUS gets set even when VBUS is driven by twl itself. Reporting VBUS in this case confuses OMAP musb glue and charger driver, so check if OTG VBUS charge pump is on before reporting VBUS event to avoid this problem.
--- drivers/usb/phy/phy-twl4030-usb.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
drivers/usb/phy/phy-twl4030-usb.c +28 -3
@@ -248,6 +248,25 @@ twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits)/*-------------------------------------------------------------------------*/ +static bool twl4030_is_driving_vbus (struct twl4030_usb *twl) +{ +int ret; + + ret =twl4030_usb_read (twl,PHY_CLK_CTRL_STS ); +if (ret <0 || !(ret &PHY_DPLL_CLK )) +/* +* if clocks are off, registers are not updated, +* but we can assume we don't drive VBUS in this case +*/ +return false; + + ret =twl4030_usb_read (twl,ULPI_OTG_CTRL ); +if (ret <0 ) +return false; + +return (ret & (ULPI_OTG_DRVVBUS |ULPI_OTG_CHRGVBUS )) ? true : false; +} +static enum omap_musb_vbus_id_status twl4030_usb_linkstat (struct twl4030_usb *twl) {
@@ -270,13 +289,19 @@ static enum omap_musb_vbus_id_statusif (status <0 )dev_err (twl->dev,"USB link status err %d\n" , status);else if (status & (BIT (7 ) |BIT (2 ))) { -if (status & (BIT (7 ))) - twl->vbus_supplied = true; +if (status &BIT (7 )) { +if (twl4030_is_driving_vbus (twl)) + status &= ~BIT (7 ); +else + twl->vbus_supplied = true; + }if (status &BIT (2 )) linkstat =OMAP_MUSB_ID_GROUND ; -else +else if (status &BIT (7 )) linkstat =OMAP_MUSB_VBUS_VALID ; +else + linkstat =OMAP_MUSB_VBUS_OFF ; }else {if (twl->linkstat !=OMAP_MUSB_UNKNOWN ) linkstat =OMAP_MUSB_VBUS_OFF ;
Signature · 1 line
1.7.9.5
PATCH v3 2/3 usb: musb: omap2430: turn off vbus on cable disconnect
In reply to Grazvydas IgnotasOn USB_EVENT_ID event the musb glue enables VBUS by calling omap2430_musb_set_vbus(musb, 1) that sets the session bit, but on USB_EVENT_NONE reverse action is never made, and that breaks PM.
Disable VBUS on USB_EVENT_NONE to be sure musb session is ended on cable unplug so that PM works.
--- drivers/usb/musb/omap2430.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/musb/omap2430.c +1 -0
@@ -291,6 +291,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) musb->xceiv->last_event =USB_EVENT_NONE ;if (musb->gadget_driver) { +omap2430_musb_set_vbus (musb,0 );pm_runtime_mark_last_busy (dev);pm_runtime_put_autosuspend (dev); }
Signature · 1 line
1.7.9.5