usb: dwc3-generic: support host mode if dr_mode is otg

The Rockchip DWC3 controller only support DRD mode (Dual Role
Device), but not support OTG mode. So if the dr_mode in DTS is
configured to OTG, then we force it to Host mode. This patch
does not affect the device function of OTG, such as rockusb.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I806623aa9b0bb8b595417755db7d9c6b6c4f38f1
This commit is contained in:
William Wu 2021-01-28 10:11:51 +08:00 committed by Jianhong Chen
parent 3a711d9c62
commit 631619a42f
1 changed files with 10 additions and 1 deletions

View File

@ -120,6 +120,10 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
pr_err("Invalid usb mode setup\n");
return -ENODEV;
} else if (plat->dr_mode != USB_DR_MODE_HOST &&
!strcmp(dev->driver->name, "dwc3-generic-host")) {
pr_info("Set dr_mode to HOST\n");
plat->dr_mode = USB_DR_MODE_HOST;
}
return 0;
@ -310,8 +314,13 @@ static int dwc3_glue_bind(struct udevice *parent)
dr_mode = usb_get_dr_mode(node);
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
case USB_DR_MODE_OTG:
#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_USB_XHCI_HCD)
debug("%s: dr_mode: force to HOST\n", __func__);
driver = "dwc3-generic-host";
break;
#endif
case USB_DR_MODE_PERIPHERAL:
#if CONFIG_IS_ENABLED(DM_USB_GADGET)
debug("%s: dr_mode: OTG or Peripheral\n", __func__);
driver = "dwc3-generic-peripheral";