All of lore.kernel.org
 help / color / mirror / Atom feed
* Role Switch Driver on DWC3
@ 2020-07-08 11:41 Shah, Nehal-bakulchandra
  2020-07-08 12:44 ` Jun Li
  0 siblings, 1 reply; 2+ messages in thread
From: Shah, Nehal-bakulchandra @ 2020-07-08 11:41 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb, Heikki Krogerus

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?


Regards

Nehal Shah



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Role Switch Driver on DWC3
  2020-07-08 11:41 Role Switch Driver on DWC3 Shah, Nehal-bakulchandra
@ 2020-07-08 12:44 ` Jun Li
  0 siblings, 0 replies; 2+ messages in thread
From: Jun Li @ 2020-07-08 12:44 UTC (permalink / raw)
  To: Shah, Nehal-bakulchandra; +Cc: Felipe Balbi, Linux USB List, Heikki Krogerus

Shah, Nehal-bakulchandra <nehal-bakulchandra.shah@amd.com>
于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@synopsys.com>
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@synopsys.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>

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
>
>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-08 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 11:41 Role Switch Driver on DWC3 Shah, Nehal-bakulchandra
2020-07-08 12:44 ` Jun Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.