diff mbox series

[3/3] usb: dwc3-generic: respect role-switch-default-mode

Message ID 20260114-casey-usb-role-switch-v1-3-fb7a626466b9@linaro.org
State New
Delegated to: Marek Vasut
Headers show
Series usb: dwc3-generic: improve DT parsing and support qcom flat DT | expand

Commit Message

Casey Connolly Jan. 14, 2026, 2:13 p.m. UTC
Respect the default mode configured in DT if it is set and dr_mode is
OTG. This allows the board to prefer host mode even on a DRD capable
controller.

Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
---
 drivers/usb/dwc3/dwc3-generic.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Neil Armstrong Jan. 14, 2026, 2:39 p.m. UTC | #1
On 1/14/26 15:13, Casey Connolly wrote:
> Respect the default mode configured in DT if it is set and dr_mode is
> OTG. This allows the board to prefer host mode even on a DRD capable
> controller.
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>   drivers/usb/dwc3/dwc3-generic.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 7044696ced0c..1aa9fc933282 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -528,8 +528,13 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
>   	dr_mode = usb_get_dr_mode(dev_ofnode(parent));
>   	if (!dr_mode)
>   		dr_mode = usb_get_dr_mode(node);
>   
> +	/* check default role for DRD controllers */
> +	if ((dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_UNKNOWN) &&
> +	    ofnode_read_bool(node, "usb-role-switch"))
> +		dr_mode = usb_get_role_switch_default_mode(node);
> +
>   	/* usb mode must fallback to peripheral if not known */
>   	if (dr_mode == USB_DR_MODE_UNKNOWN)
>   		dr_mode = USB_DR_MODE_OTG;
>   
> 

So it means that,on phone platforms, the controller will default to host ?

Neil
Casey Connolly Jan. 14, 2026, 2:42 p.m. UTC | #2
On 14/01/2026 15:39, Neil Armstrong wrote:
> On 1/14/26 15:13, Casey Connolly wrote:
>> Respect the default mode configured in DT if it is set and dr_mode is
>> OTG. This allows the board to prefer host mode even on a DRD capable
>> controller.
>>
>> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
>> ---
>>   drivers/usb/dwc3/dwc3-generic.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-
>> generic.c
>> index 7044696ced0c..1aa9fc933282 100644
>> --- a/drivers/usb/dwc3/dwc3-generic.c
>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>> @@ -528,8 +528,13 @@ static int dwc3_glue_bind_common(struct udevice
>> *parent, ofnode node)
>>       dr_mode = usb_get_dr_mode(dev_ofnode(parent));
>>       if (!dr_mode)
>>           dr_mode = usb_get_dr_mode(node);
>>   +    /* check default role for DRD controllers */
>> +    if ((dr_mode == USB_DR_MODE_OTG || dr_mode ==
>> USB_DR_MODE_UNKNOWN) &&
>> +        ofnode_read_bool(node, "usb-role-switch"))
>> +        dr_mode = usb_get_role_switch_default_mode(node);
>> +
>>       /* usb mode must fallback to peripheral if not known */
>>       if (dr_mode == USB_DR_MODE_UNKNOWN)
>>           dr_mode = USB_DR_MODE_OTG;
>>  
> 
> So it means that,on phone platforms, the controller will default to host ?

No, it will default to whatever role-switch-default-mode is if it's set,
phones will have this set to peripheral if it's set at all.

> 
> Neil
Mattijs Korpershoek Jan. 15, 2026, 9:27 a.m. UTC | #3
Hi Casey,

Thank you for the patch.

On Wed, Jan 14, 2026 at 15:13, Casey Connolly <casey.connolly@linaro.org> wrote:

> Respect the default mode configured in DT if it is set and dr_mode is
> OTG. This allows the board to prefer host mode even on a DRD capable
> controller.
>
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>  drivers/usb/dwc3/dwc3-generic.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 7044696ced0c..1aa9fc933282 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -528,8 +528,13 @@  static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
 	dr_mode = usb_get_dr_mode(dev_ofnode(parent));
 	if (!dr_mode)
 		dr_mode = usb_get_dr_mode(node);
 
+	/* check default role for DRD controllers */
+	if ((dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_UNKNOWN) &&
+	    ofnode_read_bool(node, "usb-role-switch"))
+		dr_mode = usb_get_role_switch_default_mode(node);
+
 	/* usb mode must fallback to peripheral if not known */
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		dr_mode = USB_DR_MODE_OTG;