usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch
[platform/kernel/linux-starfive.git] / drivers / usb / dwc2 / gadget.c
index fe2a58c..8b15742 100644 (file)
@@ -3594,7 +3594,8 @@ void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)
 void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg)
 {
        /* remove the soft-disconnect and let's go */
-       dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON);
+       if (!hsotg->role_sw || (dwc2_readl(hsotg, GOTGCTL) & GOTGCTL_BSESVLD))
+               dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON);
 }
 
 /**