diff mbox series

[1/3] usb: common: default dr_mode to OTG when not set

Message ID 20260114-casey-usb-role-switch-v1-1-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
DT bindings dictate that dr_mode being unset on a DRD capable USB
controller means we should default to OTG mode. Adjust usb_get_dr_mode()
to reflect this.

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

Comments

Neil Armstrong Jan. 14, 2026, 2:35 p.m. UTC | #1
On 1/14/26 15:13, Casey Connolly wrote:
> DT bindings dictate that dr_mode being unset on a DRD capable USB
> controller means we should default to OTG mode. Adjust usb_get_dr_mode()
> to reflect this.
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>   drivers/usb/common/common.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index 13e9a61072a9..e3bd7339e68e 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -29,9 +29,10 @@ enum usb_dr_mode usb_get_dr_mode(ofnode node)
>   
>   	dr_mode = ofnode_read_string(node, "dr_mode");
>   	if (!dr_mode) {
>   		pr_debug("usb dr_mode not found\n");
> -		return USB_DR_MODE_UNKNOWN;
> +		/* Default to OTG mode as per DT bindings */
> +		return USB_DR_MODE_OTG;
>   	}
>   
>   	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
>   		if (!strcmp(dr_mode, usb_dr_modes[i]))
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil
Mattijs Korpershoek Jan. 15, 2026, 9:17 a.m. UTC | #2
Hi Casey,

Thank you for the patch.

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

> DT bindings dictate that dr_mode being unset on a DRD capable USB

For the curious, this is defined in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/usb-drd.yaml#n23

> controller means we should default to OTG mode. Adjust usb_get_dr_mode()
> to reflect this.
>
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>  drivers/usb/common/common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index 13e9a61072a9..e3bd7339e68e 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -29,9 +29,10 @@ enum usb_dr_mode usb_get_dr_mode(ofnode node)
>  
>  	dr_mode = ofnode_read_string(node, "dr_mode");
>  	if (!dr_mode) {
>  		pr_debug("usb dr_mode not found\n");
> -		return USB_DR_MODE_UNKNOWN;
> +		/* Default to OTG mode as per DT bindings */

Nitpick: can we change the comment to:
/* Default to OTG mode as per devicetree/bindings/usb/usb-drd.yaml */

This tells the same but is more precise and is imho, a more helpful
comment.

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


> +		return USB_DR_MODE_OTG;
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
>  		if (!strcmp(dr_mode, usb_dr_modes[i]))
>
> -- 
> 2.51.0
Mattijs Korpershoek Jan. 16, 2026, 12:30 p.m. UTC | #3
On Thu, Jan 15, 2026 at 10:17, Mattijs Korpershoek <mkorpershoek@kernel.org> wrote:

> Hi Casey,
>
> Thank you for the patch.
>
> On Wed, Jan 14, 2026 at 15:13, Casey Connolly <casey.connolly@linaro.org> wrote:
>
>> DT bindings dictate that dr_mode being unset on a DRD capable USB
>
> For the curious, this is defined in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/usb-drd.yaml#n23
>
>> controller means we should default to OTG mode. Adjust usb_get_dr_mode()
>> to reflect this.
>>
>> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
>> ---
>>  drivers/usb/common/common.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
>> index 13e9a61072a9..e3bd7339e68e 100644
>> --- a/drivers/usb/common/common.c
>> +++ b/drivers/usb/common/common.c
>> @@ -29,9 +29,10 @@ enum usb_dr_mode usb_get_dr_mode(ofnode node)
>>  
>>  	dr_mode = ofnode_read_string(node, "dr_mode");
>>  	if (!dr_mode) {
>>  		pr_debug("usb dr_mode not found\n");
>> -		return USB_DR_MODE_UNKNOWN;
>> +		/* Default to OTG mode as per DT bindings */
>
> Nitpick: can we change the comment to:
> /* Default to OTG mode as per devicetree/bindings/usb/usb-drd.yaml */
>
> This tells the same but is more precise and is imho, a more helpful
> comment.
>
> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

Also, I just noticed, but there is another similar change here:
https://lore.kernel.org/all/20260108-usb-dwc3-exynos7870-v3-1-343fa1e81e48@disroot.org/

Casey, can you see if the above is useful to you?

>
>
>> +		return USB_DR_MODE_OTG;
>>  	}
>>  
>>  	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
>>  		if (!strcmp(dr_mode, usb_dr_modes[i]))
>>
>> -- 
>> 2.51.0
Casey Connolly Jan. 16, 2026, 5:05 p.m. UTC | #4
On 1/16/26 13:30, Mattijs Korpershoek wrote:
> On Thu, Jan 15, 2026 at 10:17, Mattijs Korpershoek <mkorpershoek@kernel.org> wrote:
> 
>> Hi Casey,
>>
>> Thank you for the patch.
>>
>> On Wed, Jan 14, 2026 at 15:13, Casey Connolly <casey.connolly@linaro.org> wrote:
>>
>>> DT bindings dictate that dr_mode being unset on a DRD capable USB
>>
>> For the curious, this is defined in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/usb-drd.yaml#n23
>>
>>> controller means we should default to OTG mode. Adjust usb_get_dr_mode()
>>> to reflect this.
>>>
>>> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
>>> ---
>>>   drivers/usb/common/common.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
>>> index 13e9a61072a9..e3bd7339e68e 100644
>>> --- a/drivers/usb/common/common.c
>>> +++ b/drivers/usb/common/common.c
>>> @@ -29,9 +29,10 @@ enum usb_dr_mode usb_get_dr_mode(ofnode node)
>>>   
>>>   	dr_mode = ofnode_read_string(node, "dr_mode");
>>>   	if (!dr_mode) {
>>>   		pr_debug("usb dr_mode not found\n");
>>> -		return USB_DR_MODE_UNKNOWN;
>>> +		/* Default to OTG mode as per DT bindings */
>>
>> Nitpick: can we change the comment to:
>> /* Default to OTG mode as per devicetree/bindings/usb/usb-drd.yaml */
>>
>> This tells the same but is more precise and is imho, a more helpful
>> comment.
>>
>> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> 
> Also, I just noticed, but there is another similar change here:
> https://lore.kernel.org/all/20260108-usb-dwc3-exynos7870-v3-1-343fa1e81e48@disroot.org/
> 
> Casey, can you see if the above is useful to you?

Oh yep, same patch basically. I'll drop my version in the next revision.

> 
>>
>>
>>> +		return USB_DR_MODE_OTG;
>>>   	}
>>>   
>>>   	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
>>>   		if (!strcmp(dr_mode, usb_dr_modes[i]))
>>>
>>> -- 
>>> 2.51.0
diff mbox series

Patch

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 13e9a61072a9..e3bd7339e68e 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -29,9 +29,10 @@  enum usb_dr_mode usb_get_dr_mode(ofnode node)
 
 	dr_mode = ofnode_read_string(node, "dr_mode");
 	if (!dr_mode) {
 		pr_debug("usb dr_mode not found\n");
-		return USB_DR_MODE_UNKNOWN;
+		/* Default to OTG mode as per DT bindings */
+		return USB_DR_MODE_OTG;
 	}
 
 	for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
 		if (!strcmp(dr_mode, usb_dr_modes[i]))