aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorMark Kettenis2022-04-19 21:06:33 +0200
committerMarek Vasut2022-05-20 09:41:33 +0200
commit6a6468f479a7e816fb656b3e1d8af30c7de837a4 (patch)
tree78f35a3ddb79df8e8cf38adb0197571f6e2ce246 /drivers/usb/host
parentf83bd23e2a0e9861969c9d43395299a14f25ddda (diff)
usb: xhci-dwc3: Support role switch default role
When the device tree indicates support for role switching through the "usb-role-switch" property, take the "role-switch-default-mode" property into account when deciding which role to put the controller into. This makes USB devices work on Apple M1 systems where the device tree may include a "dr_mode" property that is set to "otg", but where we need to put the controller into "host" mode to see devices connected to the type-C ports. Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/xhci-dwc3.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index bec0d980811..1dbd65dfaa3 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -209,6 +209,12 @@ static int xhci_dwc3_probe(struct udevice *dev)
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;