With commit 594632efbb9a ("usb: musb: Adding musb support for OMAP4430")
we were supposed to call otg_set_vbus() only if enabling session for a
A-device fails. But the conditional test was always true and at some point
commit 10770c5aa0fe ("usb: musb: omap2430.c delete unused variable.")
removed the check.

Looks like always calling otg_set_vbus() causes flakeyness enumerating when
droid4 is connected to a lapdock. In this case lapdock runs in USB carkit
type mode and feeds the VBUS.

Let's fix the issue by adding a flag to call otg_set_vbus() conditionally
only if A-device session fails that probably was the intention originally.

Signed-off-by: Tony Lindgren <t...@atomide.com>
---
 drivers/usb/musb/omap2430.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -52,6 +52,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int 
is_on)
 
        if (is_on) {
                if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
+                       bool need_otg_set_vbus = true;
                        int loops = 100;
                        /* start the session */
                        devctl |= MUSB_DEVCTL_SESSION;
@@ -72,9 +73,13 @@ static void omap2430_musb_set_vbus(struct musb *musb, int 
is_on)
                                        "configured as A device timeout");
                                        break;
                                }
+
+                               /* Session enabled as A-device, we have VBUS */
+                               need_otg_set_vbus = false;
                        }
 
-                       otg_set_vbus(otg, 1);
+                       if (need_otg_set_vbus)
+                               otg_set_vbus(otg, 1);
                } else {
                        musb->is_active = 1;
                        musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
-- 
2.23.0

Reply via email to