Skip to content

Commit

Permalink
usb: dwc3: otg: Enable OTG support in dwc3-core driver
Browse files Browse the repository at this point in the history
The Linux v5.4 and later version Kernel does not support OTG feature in
the DWC3 USB driver. Also, the upstream kernel defaulting the mode to
peipheral if otg is specified in device tree and if usb role switch is
not specified either in DT or through Kconfig. To support the OTG mode
for Xilinx platforms, this check needs to removed.

Added the kernel config 'CONFIG_USB_DWC3_OTG' check-in dwc3 driver to
make OTG work for Xilinx platforms.

Signed-off-by: Piyush Mehta <piyush.mehta@amd.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
State: not-upstreamable
  • Loading branch information
PiyushXilinx authored and michalsimek committed Apr 21, 2023
1 parent 122a2f4 commit cb1f2db
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,19 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
mode = USB_DR_MODE_PERIPHERAL;

if (!IS_ENABLED(CONFIG_USB_DWC3_OTG)) {
/*
* DWC_usb31 and DWC_usb3 v3.30a and higher do not support OTG
* mode. If the controller supports DRD but the dr_mode is not
* specified or set to OTG, then set the mode to peripheral.
*/
if (mode == USB_DR_MODE_OTG && !dwc->edev &&
(!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
!device_property_read_bool(dwc->dev, "usb-role-switch")) &&
!DWC3_VER_IS_PRIOR(DWC3, 330A))
mode = USB_DR_MODE_PERIPHERAL;
if (mode == USB_DR_MODE_OTG && !dwc->edev &&
(!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
!device_property_read_bool(dwc->dev,
"usb-role-switch")) &&
!DWC3_VER_IS_PRIOR(DWC3, 330A))
mode = USB_DR_MODE_PERIPHERAL;
}
}

if (mode != dwc->dr_mode) {
Expand Down

0 comments on commit cb1f2db

Please sign in to comment.