Merge https://source.denx.de/u-boot/custodians/u-boot-usb
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index ee0c064..cff86a5 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -40,6 +40,22 @@
 	return USB_DR_MODE_UNKNOWN;
 }
 
+enum usb_dr_mode usb_get_role_switch_default_mode(ofnode node)
+{
+	const char *dr_mode;
+	int i;
+
+	dr_mode = ofnode_read_string(node, "role-switch-default-mode");
+	if (!dr_mode)
+		return USB_DR_MODE_UNKNOWN;
+
+	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
+		if (!strcmp(dr_mode, usb_dr_modes[i]))
+			return i;
+
+	return USB_DR_MODE_UNKNOWN;
+}
+
 static const char *const speed_names[] = {
 	[USB_SPEED_UNKNOWN] = "UNKNOWN",
 	[USB_SPEED_LOW] = "low-speed",
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 6e1a1d0..c5310e4 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -468,9 +468,11 @@
 		ret = generic_phy_init(&phy);
 		if (ret)
 			return ret;
-	} else if (ret != -ENOENT) {
+	} else if (ret != -ENOENT && ret != -ENODATA) {
 		debug("could not get phy (err %d)\n", ret);
 		return ret;
+	} else {
+		phy.dev = NULL;
 	}
 
 	glue->regs = dev_read_addr(dev);
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index bec0d98..1dbd65d 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -209,6 +209,12 @@
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
 	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+	if (dr_mode == USB_DR_MODE_OTG &&
+	    dev_read_bool(dev, "usb-role-switch")) {
+		dr_mode = usb_get_role_switch_default_mode(dev_ofnode(dev));
+		if (dr_mode == USB_DR_MODE_UNKNOWN)
+			dr_mode = USB_DR_MODE_OTG;
+	}
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
 		dr_mode = USB_DR_MODE_HOST;
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index c19b916..5d0dac9 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -28,6 +28,16 @@
 enum usb_dr_mode usb_get_dr_mode(ofnode node);
 
 /**
+ * usb_get_dr_mode() - Get dual role mode for given device
+ * @node: ofnode of the given device
+ *
+ * The function gets phy interface string from property
+ * 'role-switch-defaulr-mode', and returns the correspondig enum
+ * usb_dr_mode
+ */
+enum usb_dr_mode usb_get_role_switch_default_mode(ofnode node);
+
+/**
  * usb_get_maximum_speed() - Get maximum speed for given device
  * @node: ofnode of the given device
  *