diff mbox series

[2/2] usb: dwc3: core: Use role-switch default dr_mode

Message ID 8c861d467863a87202df2df37cd84e590a665bdf.1585526614.git.thinhn@synopsys.com (mailing list archive)
State Mainlined
Commit 8bb14308a86970a2321ac7d0e28ea0f1f1e744b0
Headers show
Series usb: dwc3: gadget: Default mode for DRD | expand

Commit Message

Thinh Nguyen March 30, 2020, 12:10 a.m. UTC
If the driver is configured to use DRD role-switch, let the drd code
path decide the default dr_mode.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/dwc3/core.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7046c681fece..ab6323b8e323 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -85,6 +85,8 @@  static int dwc3_get_dr_mode(struct dwc3 *dwc)
 		 * specified or set to OTG, then set the mode to peripheral.
 		 */
 		if (mode == USB_DR_MODE_OTG &&
+		    (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
+		     !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
 		    dwc->revision >= DWC3_REVISION_330A)
 			mode = USB_DR_MODE_PERIPHERAL;
 	}