Re: Role Switch Driver on DWC3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shah, Nehal-bakulchandra <nehal-bakulchandra.shah@xxxxxxx>
于2020年7月8日周三 下午7:44写道:
>
> Hi,
>
> As per my understanding, role switch interface for DWC3 controller will be called in dwc3_drd_init.
>
> However, dwc3_drd_init is called only if mode is USB_DR_MODE_OTG. However for USB3 V3.3 and above the following code exists.
>
> /*
>          * 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->revision >= DWC3_REVISION_330A)
>             mode = USB_DR_MODE_PERIPHERAL;
>     }
>
> Hence, in this case role switch interface will never will be called.
>
>
> Please clear my understanding, and in such case how can i use the role switch driver?

This has been changed by below commit:

commit 8bb14308a86970a2321ac7d0e28ea0f1f1e744b0
Author: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>
Date:   Sun Mar 29 17:10:05 2020 -0700

    usb: dwc3: core: Use role-switch default dr_mode

    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@xxxxxxxxxxxx>
    Signed-off-by: Felipe Balbi <balbi@xxxxxxxxxx>

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7046c68..ab6323b 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;
        }

>
>
> Regards
>
> Nehal Shah
>
>




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux