public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: dwc3-generic: improve DT parsing and support qcom flat DT
@ 2026-01-14 14:13 Casey Connolly
  2026-01-14 14:13 ` [PATCH 1/3] usb: common: default dr_mode to OTG when not set Casey Connolly
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Casey Connolly @ 2026-01-14 14:13 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

Add support for the new flat DT format being adopted by Qualcomm boards,
this merges the dwc3 and glue nodes together.

Correctly default dr_mode to OTG when it isn't set explicitly, and
support the usb-role-switch and role-switch-default-mode properties so
that boards can express a preference when OTG is supported.

---
Casey Connolly (3):
      usb: common: default dr_mode to OTG when not set
      usb: dwc3-generic: support Qualcomm flattened DT
      usb: dwc3-generic: respect role-switch-default-mode

 drivers/usb/common/common.c     |  3 ++-
 drivers/usb/dwc3/dwc3-generic.c | 26 ++++++++++++++++++++------
 2 files changed, 22 insertions(+), 7 deletions(-)
---
base-commit: 03c01c69806d4265070f14e7a7cbf617fcbb8f6a

// Casey (she/they)


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

* [PATCH 1/3] usb: common: default dr_mode to OTG when not set
  2026-01-14 14:13 [PATCH 0/3] usb: dwc3-generic: improve DT parsing and support qcom flat DT Casey Connolly
@ 2026-01-14 14:13 ` Casey Connolly
  2026-01-14 14:35   ` Neil Armstrong
  2026-01-15  9:17   ` Mattijs Korpershoek
  2026-01-14 14:13 ` [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT Casey Connolly
  2026-01-14 14:13 ` [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode Casey Connolly
  2 siblings, 2 replies; 15+ messages in thread
From: Casey Connolly @ 2026-01-14 14:13 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

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

-- 
2.51.0


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

* [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT
  2026-01-14 14:13 [PATCH 0/3] usb: dwc3-generic: improve DT parsing and support qcom flat DT Casey Connolly
  2026-01-14 14:13 ` [PATCH 1/3] usb: common: default dr_mode to OTG when not set Casey Connolly
@ 2026-01-14 14:13 ` Casey Connolly
  2026-01-14 14:36   ` Neil Armstrong
  2026-01-15  9:21   ` Mattijs Korpershoek
  2026-01-14 14:13 ` [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode Casey Connolly
  2 siblings, 2 replies; 15+ messages in thread
From: Casey Connolly @ 2026-01-14 14:13 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

Qualcomm devicetrees are moving away from having a glue node with dwc3
as a subnode and now may just have a single flattened node.

Rockchip already have a glue_get_ctrl_dev op which returns the node for
the glue device itself, commonise this and reuse it for the new Qualcomm
node.

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

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 02c02b1d80e4..7044696ced0c 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -6,8 +6,10 @@
  *
  * Based on dwc3-omap.c.
  */
 
+#define LOG_DEBUG
+
 #include <dm.h>
 #include <reset.h>
 #include <asm/gpio.h>
 #include <dm/device_compat.h>
@@ -488,23 +490,29 @@ static void dwc3_qcom_glue_configure(struct udevice *dev, int index,
 	if (mode != USB_DR_MODE_HOST)
 		dwc3_qcom_vbus_override_enable(qscratch_base, true);
 }
 
-struct dwc3_glue_ops qcom_ops = {
-	.glue_configure = dwc3_qcom_glue_configure,
-};
-
-static int dwc3_rk_glue_get_ctrl_dev(struct udevice *dev, ofnode *node)
+/* In cases where there is no dwc3 node and it's flattened into the glue node */
+static int dwc3_flat_dt_get_ctrl_dev(struct udevice *dev, ofnode *node)
 {
 	*node = dev_ofnode(dev);
 	if (!ofnode_valid(*node))
 		return -EINVAL;
 
 	return 0;
 }
 
+struct dwc3_glue_ops qcom_ops = {
+	.glue_configure = dwc3_qcom_glue_configure,
+};
+
+struct dwc3_glue_ops qcom_flat_dt_ops = {
+	.glue_configure = dwc3_qcom_glue_configure,
+	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
+};
+
 struct dwc3_glue_ops rk_ops = {
-	.glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev,
+	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
 };
 
 static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
 {
@@ -711,8 +719,9 @@ static const struct udevice_id dwc3_glue_ids[] = {
 	{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "rockchip,rk3576-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
 	{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
+	{ .compatible = "qcom,snps-dwc3", .data = (ulong)&qcom_flat_dt_ops },
 	{ .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops },
 	{ .compatible = "fsl,imx8mq-dwc3" },
 	{ .compatible = "intel,tangier-dwc3" },
 	{ .compatible = "samsung,exynos7870-dwusb3" },

-- 
2.51.0


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

* [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode
  2026-01-14 14:13 [PATCH 0/3] usb: dwc3-generic: improve DT parsing and support qcom flat DT Casey Connolly
  2026-01-14 14:13 ` [PATCH 1/3] usb: common: default dr_mode to OTG when not set Casey Connolly
  2026-01-14 14:13 ` [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT Casey Connolly
@ 2026-01-14 14:13 ` Casey Connolly
  2026-01-14 14:39   ` Neil Armstrong
  2026-01-15  9:27   ` Mattijs Korpershoek
  2 siblings, 2 replies; 15+ messages in thread
From: Casey Connolly @ 2026-01-14 14:13 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

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;
 

-- 
2.51.0


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

* Re: [PATCH 1/3] usb: common: default dr_mode to OTG when not set
  2026-01-14 14:13 ` [PATCH 1/3] usb: common: default dr_mode to OTG when not set Casey Connolly
@ 2026-01-14 14:35   ` Neil Armstrong
  2026-01-15  9:17   ` Mattijs Korpershoek
  1 sibling, 0 replies; 15+ messages in thread
From: Neil Armstrong @ 2026-01-14 14:35 UTC (permalink / raw)
  To: Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Kaustabh Chakraborty,
	Jonas Karlman, Sam Protsenko, Balaji Selvanathan, Patrice Chotard

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

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

* Re: [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT
  2026-01-14 14:13 ` [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT Casey Connolly
@ 2026-01-14 14:36   ` Neil Armstrong
  2026-01-15  9:21   ` Mattijs Korpershoek
  1 sibling, 0 replies; 15+ messages in thread
From: Neil Armstrong @ 2026-01-14 14:36 UTC (permalink / raw)
  To: Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Kaustabh Chakraborty,
	Jonas Karlman, Sam Protsenko, Balaji Selvanathan, Patrice Chotard

On 1/14/26 15:13, Casey Connolly wrote:
> Qualcomm devicetrees are moving away from having a glue node with dwc3
> as a subnode and now may just have a single flattened node.
> 
> Rockchip already have a glue_get_ctrl_dev op which returns the node for
> the glue device itself, commonise this and reuse it for the new Qualcomm
> node.
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>   drivers/usb/dwc3/dwc3-generic.c | 21 +++++++++++++++------
>   1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 02c02b1d80e4..7044696ced0c 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -6,8 +6,10 @@
>    *
>    * Based on dwc3-omap.c.
>    */
>   
> +#define LOG_DEBUG

You should drop this

> +
>   #include <dm.h>
>   #include <reset.h>
>   #include <asm/gpio.h>
>   #include <dm/device_compat.h>
> @@ -488,23 +490,29 @@ static void dwc3_qcom_glue_configure(struct udevice *dev, int index,
>   	if (mode != USB_DR_MODE_HOST)
>   		dwc3_qcom_vbus_override_enable(qscratch_base, true);
>   }
>   
> -struct dwc3_glue_ops qcom_ops = {
> -	.glue_configure = dwc3_qcom_glue_configure,
> -};
> -
> -static int dwc3_rk_glue_get_ctrl_dev(struct udevice *dev, ofnode *node)
> +/* In cases where there is no dwc3 node and it's flattened into the glue node */
> +static int dwc3_flat_dt_get_ctrl_dev(struct udevice *dev, ofnode *node)
>   {
>   	*node = dev_ofnode(dev);
>   	if (!ofnode_valid(*node))
>   		return -EINVAL;
>   
>   	return 0;
>   }
>   
> +struct dwc3_glue_ops qcom_ops = {
> +	.glue_configure = dwc3_qcom_glue_configure,
> +};
> +
> +struct dwc3_glue_ops qcom_flat_dt_ops = {
> +	.glue_configure = dwc3_qcom_glue_configure,
> +	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
> +};
> +
>   struct dwc3_glue_ops rk_ops = {
> -	.glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev,
> +	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
>   };
>   
>   static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
>   {
> @@ -711,8 +719,9 @@ static const struct udevice_id dwc3_glue_ids[] = {
>   	{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
>   	{ .compatible = "rockchip,rk3576-dwc3", .data = (ulong)&rk_ops },
>   	{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
>   	{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
> +	{ .compatible = "qcom,snps-dwc3", .data = (ulong)&qcom_flat_dt_ops },
>   	{ .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops },
>   	{ .compatible = "fsl,imx8mq-dwc3" },
>   	{ .compatible = "intel,tangier-dwc3" },
>   	{ .compatible = "samsung,exynos7870-dwusb3" },
> 

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


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

* Re: [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode
  2026-01-14 14:13 ` [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode Casey Connolly
@ 2026-01-14 14:39   ` Neil Armstrong
  2026-01-14 14:42     ` Casey Connolly
  2026-01-15  9:27   ` Mattijs Korpershoek
  1 sibling, 1 reply; 15+ messages in thread
From: Neil Armstrong @ 2026-01-14 14:39 UTC (permalink / raw)
  To: Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Kaustabh Chakraborty,
	Jonas Karlman, Sam Protsenko, Balaji Selvanathan, Patrice Chotard

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

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

* Re: [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode
  2026-01-14 14:39   ` Neil Armstrong
@ 2026-01-14 14:42     ` Casey Connolly
  0 siblings, 0 replies; 15+ messages in thread
From: Casey Connolly @ 2026-01-14 14:42 UTC (permalink / raw)
  To: Neil Armstrong, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Kaustabh Chakraborty,
	Jonas Karlman, Sam Protsenko, Balaji Selvanathan, Patrice Chotard



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

-- 
// Casey (she/her)


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

* Re: [PATCH 1/3] usb: common: default dr_mode to OTG when not set
  2026-01-14 14:13 ` [PATCH 1/3] usb: common: default dr_mode to OTG when not set Casey Connolly
  2026-01-14 14:35   ` Neil Armstrong
@ 2026-01-15  9:17   ` Mattijs Korpershoek
  2026-01-16 12:30     ` Mattijs Korpershoek
  1 sibling, 1 reply; 15+ messages in thread
From: Mattijs Korpershoek @ 2026-01-15  9:17 UTC (permalink / raw)
  To: Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

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

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

* Re: [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT
  2026-01-14 14:13 ` [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT Casey Connolly
  2026-01-14 14:36   ` Neil Armstrong
@ 2026-01-15  9:21   ` Mattijs Korpershoek
  2026-01-16 17:54     ` Casey Connolly
  1 sibling, 1 reply; 15+ messages in thread
From: Mattijs Korpershoek @ 2026-01-15  9:21 UTC (permalink / raw)
  To: Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

Hi Casey,

Thank you for the patch.

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

> Qualcomm devicetrees are moving away from having a glue node with dwc3
> as a subnode and now may just have a single flattened node.

In the commit message, could you provide a link to an example dt who has
this single flattened node?

>
> Rockchip already have a glue_get_ctrl_dev op which returns the node for
> the glue device itself, commonise this and reuse it for the new Qualcomm
> node.
>
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>  drivers/usb/dwc3/dwc3-generic.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 02c02b1d80e4..7044696ced0c 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -6,8 +6,10 @@
>   *
>   * Based on dwc3-omap.c.
>   */
>  
> +#define LOG_DEBUG
> +

Debug leftover? Please drop for v2.

>  #include <dm.h>
>  #include <reset.h>
>  #include <asm/gpio.h>
>  #include <dm/device_compat.h>
> @@ -488,23 +490,29 @@ static void dwc3_qcom_glue_configure(struct udevice *dev, int index,
>  	if (mode != USB_DR_MODE_HOST)
>  		dwc3_qcom_vbus_override_enable(qscratch_base, true);
>  }
>  
> -struct dwc3_glue_ops qcom_ops = {
> -	.glue_configure = dwc3_qcom_glue_configure,
> -};
> -
> -static int dwc3_rk_glue_get_ctrl_dev(struct udevice *dev, ofnode *node)
> +/* In cases where there is no dwc3 node and it's flattened into the glue node */
> +static int dwc3_flat_dt_get_ctrl_dev(struct udevice *dev, ofnode *node)
>  {
>  	*node = dev_ofnode(dev);
>  	if (!ofnode_valid(*node))
>  		return -EINVAL;
>  
>  	return 0;
>  }
>  
> +struct dwc3_glue_ops qcom_ops = {
> +	.glue_configure = dwc3_qcom_glue_configure,
> +};
> +
> +struct dwc3_glue_ops qcom_flat_dt_ops = {
> +	.glue_configure = dwc3_qcom_glue_configure,
> +	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
> +};
> +
>  struct dwc3_glue_ops rk_ops = {
> -	.glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev,
> +	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
>  };
>  
>  static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
>  {
> @@ -711,8 +719,9 @@ static const struct udevice_id dwc3_glue_ids[] = {
>  	{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
>  	{ .compatible = "rockchip,rk3576-dwc3", .data = (ulong)&rk_ops },
>  	{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
>  	{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
> +	{ .compatible = "qcom,snps-dwc3", .data = (ulong)&qcom_flat_dt_ops },
>  	{ .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops },
>  	{ .compatible = "fsl,imx8mq-dwc3" },
>  	{ .compatible = "intel,tangier-dwc3" },
>  	{ .compatible = "samsung,exynos7870-dwusb3" },
>
> -- 
> 2.51.0

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

* Re: [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode
  2026-01-14 14:13 ` [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode Casey Connolly
  2026-01-14 14:39   ` Neil Armstrong
@ 2026-01-15  9:27   ` Mattijs Korpershoek
  1 sibling, 0 replies; 15+ messages in thread
From: Mattijs Korpershoek @ 2026-01-15  9:27 UTC (permalink / raw)
  To: Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

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(+)
>

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

* Re: [PATCH 1/3] usb: common: default dr_mode to OTG when not set
  2026-01-15  9:17   ` Mattijs Korpershoek
@ 2026-01-16 12:30     ` Mattijs Korpershoek
  2026-01-16 17:05       ` Casey Connolly
  0 siblings, 1 reply; 15+ messages in thread
From: Mattijs Korpershoek @ 2026-01-16 12:30 UTC (permalink / raw)
  To: Mattijs Korpershoek, Casey Connolly, u-boot
  Cc: Marek Vasut, Tom Rini, Mattijs Korpershoek, Casey Connolly,
	Kaustabh Chakraborty, Jonas Karlman, Sam Protsenko,
	Balaji Selvanathan, Patrice Chotard

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

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

* Re: [PATCH 1/3] usb: common: default dr_mode to OTG when not set
  2026-01-16 12:30     ` Mattijs Korpershoek
@ 2026-01-16 17:05       ` Casey Connolly
  0 siblings, 0 replies; 15+ messages in thread
From: Casey Connolly @ 2026-01-16 17:05 UTC (permalink / raw)
  To: Mattijs Korpershoek, u-boot
  Cc: Marek Vasut, Tom Rini, Kaustabh Chakraborty, Jonas Karlman,
	Sam Protsenko, Balaji Selvanathan, Patrice Chotard



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


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

* Re: [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT
  2026-01-15  9:21   ` Mattijs Korpershoek
@ 2026-01-16 17:54     ` Casey Connolly
  2026-01-19 12:23       ` Mattijs Korpershoek
  0 siblings, 1 reply; 15+ messages in thread
From: Casey Connolly @ 2026-01-16 17:54 UTC (permalink / raw)
  To: Mattijs Korpershoek, u-boot
  Cc: Marek Vasut, Tom Rini, Kaustabh Chakraborty, Jonas Karlman,
	Sam Protsenko, Balaji Selvanathan, Patrice Chotard

Hi Mattijs,

On 1/15/26 10:21, Mattijs Korpershoek wrote:
> Hi Casey,
> 
> Thank you for the patch.
> 
> On Wed, Jan 14, 2026 at 15:13, Casey Connolly <casey.connolly@linaro.org> wrote:
> 
>> Qualcomm devicetrees are moving away from having a glue node with dwc3
>> as a subnode and now may just have a single flattened node.
> 
> In the commit message, could you provide a link to an example dt who has
> this single flattened node?

Sorry I just saw this after posting v2... You can grep for the new 
compatible string in upstream DT, sc7280, sm8650 and a few other 
platforms are already switched over, eventually all the used/maintained 
platforms will get switched over I suspect.

> 
>>
>> Rockchip already have a glue_get_ctrl_dev op which returns the node for
>> the glue device itself, commonise this and reuse it for the new Qualcomm
>> node.
>>
>> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
>> ---
>>   drivers/usb/dwc3/dwc3-generic.c | 21 +++++++++++++++------
>>   1 file changed, 15 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
>> index 02c02b1d80e4..7044696ced0c 100644
>> --- a/drivers/usb/dwc3/dwc3-generic.c
>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>> @@ -6,8 +6,10 @@
>>    *
>>    * Based on dwc3-omap.c.
>>    */
>>   
>> +#define LOG_DEBUG
>> +
> 
> Debug leftover? Please drop for v2.
> 
>>   #include <dm.h>
>>   #include <reset.h>
>>   #include <asm/gpio.h>
>>   #include <dm/device_compat.h>
>> @@ -488,23 +490,29 @@ static void dwc3_qcom_glue_configure(struct udevice *dev, int index,
>>   	if (mode != USB_DR_MODE_HOST)
>>   		dwc3_qcom_vbus_override_enable(qscratch_base, true);
>>   }
>>   
>> -struct dwc3_glue_ops qcom_ops = {
>> -	.glue_configure = dwc3_qcom_glue_configure,
>> -};
>> -
>> -static int dwc3_rk_glue_get_ctrl_dev(struct udevice *dev, ofnode *node)
>> +/* In cases where there is no dwc3 node and it's flattened into the glue node */
>> +static int dwc3_flat_dt_get_ctrl_dev(struct udevice *dev, ofnode *node)
>>   {
>>   	*node = dev_ofnode(dev);
>>   	if (!ofnode_valid(*node))
>>   		return -EINVAL;
>>   
>>   	return 0;
>>   }
>>   
>> +struct dwc3_glue_ops qcom_ops = {
>> +	.glue_configure = dwc3_qcom_glue_configure,
>> +};
>> +
>> +struct dwc3_glue_ops qcom_flat_dt_ops = {
>> +	.glue_configure = dwc3_qcom_glue_configure,
>> +	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
>> +};
>> +
>>   struct dwc3_glue_ops rk_ops = {
>> -	.glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev,
>> +	.glue_get_ctrl_dev = dwc3_flat_dt_get_ctrl_dev,
>>   };
>>   
>>   static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
>>   {
>> @@ -711,8 +719,9 @@ static const struct udevice_id dwc3_glue_ids[] = {
>>   	{ .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops },
>>   	{ .compatible = "rockchip,rk3576-dwc3", .data = (ulong)&rk_ops },
>>   	{ .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops },
>>   	{ .compatible = "qcom,dwc3", .data = (ulong)&qcom_ops },
>> +	{ .compatible = "qcom,snps-dwc3", .data = (ulong)&qcom_flat_dt_ops },
>>   	{ .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops },
>>   	{ .compatible = "fsl,imx8mq-dwc3" },
>>   	{ .compatible = "intel,tangier-dwc3" },
>>   	{ .compatible = "samsung,exynos7870-dwusb3" },
>>
>> -- 
>> 2.51.0


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

* Re: [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT
  2026-01-16 17:54     ` Casey Connolly
@ 2026-01-19 12:23       ` Mattijs Korpershoek
  0 siblings, 0 replies; 15+ messages in thread
From: Mattijs Korpershoek @ 2026-01-19 12:23 UTC (permalink / raw)
  To: Casey Connolly, Mattijs Korpershoek, u-boot
  Cc: Marek Vasut, Tom Rini, Kaustabh Chakraborty, Jonas Karlman,
	Sam Protsenko, Balaji Selvanathan, Patrice Chotard


On Fri, Jan 16, 2026 at 18:54, Casey Connolly <casey.connolly@linaro.org> wrote:

> Hi Mattijs,
>
> On 1/15/26 10:21, Mattijs Korpershoek wrote:
>> Hi Casey,
>> 
>> Thank you for the patch.
>> 
>> On Wed, Jan 14, 2026 at 15:13, Casey Connolly <casey.connolly@linaro.org> wrote:
>> 
>>> Qualcomm devicetrees are moving away from having a glue node with dwc3
>>> as a subnode and now may just have a single flattened node.
>> 
>> In the commit message, could you provide a link to an example dt who has
>> this single flattened node?
>
> Sorry I just saw this after posting v2... You can grep for the new 

No worries.

> compatible string in upstream DT, sc7280, sm8650 and a few other 
> platforms are already switched over, eventually all the used/maintained 
> platforms will get switched over I suspect.

Thanks for the hints. That's good enough for me!

>
>> 
>>>

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

end of thread, other threads:[~2026-01-19 12:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14 14:13 [PATCH 0/3] usb: dwc3-generic: improve DT parsing and support qcom flat DT Casey Connolly
2026-01-14 14:13 ` [PATCH 1/3] usb: common: default dr_mode to OTG when not set Casey Connolly
2026-01-14 14:35   ` Neil Armstrong
2026-01-15  9:17   ` Mattijs Korpershoek
2026-01-16 12:30     ` Mattijs Korpershoek
2026-01-16 17:05       ` Casey Connolly
2026-01-14 14:13 ` [PATCH 2/3] usb: dwc3-generic: support Qualcomm flattened DT Casey Connolly
2026-01-14 14:36   ` Neil Armstrong
2026-01-15  9:21   ` Mattijs Korpershoek
2026-01-16 17:54     ` Casey Connolly
2026-01-19 12:23       ` Mattijs Korpershoek
2026-01-14 14:13 ` [PATCH 3/3] usb: dwc3-generic: respect role-switch-default-mode Casey Connolly
2026-01-14 14:39   ` Neil Armstrong
2026-01-14 14:42     ` Casey Connolly
2026-01-15  9:27   ` Mattijs Korpershoek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox