public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node
@ 2026-01-14 13:57 Casey Connolly
  2026-01-14 14:39 ` Neil Armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Casey Connolly @ 2026-01-14 13:57 UTC (permalink / raw)
  To: Casey Connolly, Neil Armstrong, Rui Miguel Silva, Sumit Garg,
	Tom Rini
  Cc: u-boot-qcom, Sumit Garg, u-boot

Qualcomm DTs are being updated to use a new format where the dwc3 glue
node and controller are combined into a single DT node. Update the fixup
code to handle this case.

Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
---
 arch/arm/mach-snapdragon/of_fixup.c | 40 +++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-snapdragon/of_fixup.c b/arch/arm/mach-snapdragon/of_fixup.c
index eec2c0c757e0..5b6076ea8e57 100644
--- a/arch/arm/mach-snapdragon/of_fixup.c
+++ b/arch/arm/mach-snapdragon/of_fixup.c
@@ -31,31 +31,37 @@
  * USB controllers. Rather than requiring source level DT changes, we fix up
  * DT here. This improves compatibility with upstream DT and simplifies the
  * porting process for new devices.
  */
-static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np)
+static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np, bool flat)
 {
 	struct device_node *dwc3;
 	int ret, len, hsphy_idx = 1;
 	const __be32 *phandles;
 	const char *second_phy_name;
 
 	debug("Fixing up %s\n", glue_np->name);
 
+	/* New DT flattens the glue and controller into a single node. */
+	if (flat) {
+		dwc3 = glue_np;
+		debug("%s uses flat DT\n", glue_np->name);
+	} else {
+		/* Find the DWC3 node itself */
+		dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
+		if (!dwc3) {
+			log_err("Failed to find dwc3 node\n");
+			return -ENOENT;
+		}
+	}
+
 	/* Tell the glue driver to configure the wrapper for high-speed only operation */
 	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
 	if (ret) {
 		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
 		return ret;
 	}
 
-	/* Find the DWC3 node itself */
-	dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
-	if (!dwc3) {
-		log_err("Failed to find dwc3 node\n");
-		return -ENOENT;
-	}
-
 	phandles = of_get_property(dwc3, "phys", &len);
 	len /= sizeof(*phandles);
 	if (len == 1) {
 		log_debug("Only one phy, not a superspeed controller\n");
@@ -103,15 +109,27 @@ static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np
 }
 
 static void fixup_usb_nodes(struct device_node *root)
 {
-	struct device_node *glue_np = root;
+	struct device_node *glue_np = root, *tmp;
 	int ret;
+	bool flat;
+
+	while (true) {
+		flat = false;
+		/* First check for the old DT format with glue node then the new flattened format */
+		tmp = of_find_compatible_node(glue_np, NULL, "qcom,dwc3");
+		if (!tmp) {
+			tmp = of_find_compatible_node(glue_np, NULL, "qcom,snps-dwc3");
+			flat = !!tmp;
+		}
+		if (!tmp)
+			break;
+		glue_np = tmp;
 
-	while ((glue_np = of_find_compatible_node(glue_np, NULL, "qcom,dwc3"))) {
 		if (!of_device_is_available(glue_np))
 			continue;
-		ret = fixup_qcom_dwc3(root, glue_np);
+		ret = fixup_qcom_dwc3(root, glue_np, flat);
 		if (ret)
 			log_warning("Failed to fixup node %s: %d\n", glue_np->name, ret);
 	}
 }
-- 
2.51.0


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

* Re: [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node
  2026-01-14 13:57 [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node Casey Connolly
@ 2026-01-14 14:39 ` Neil Armstrong
  2026-01-16  9:42 ` Sumit Garg
  2026-01-16 18:03 ` Casey Connolly
  2 siblings, 0 replies; 4+ messages in thread
From: Neil Armstrong @ 2026-01-14 14:39 UTC (permalink / raw)
  To: Casey Connolly, Rui Miguel Silva, Sumit Garg, Tom Rini
  Cc: u-boot-qcom, Sumit Garg, u-boot

On 1/14/26 14:57, Casey Connolly wrote:
> Qualcomm DTs are being updated to use a new format where the dwc3 glue
> node and controller are combined into a single DT node. Update the fixup
> code to handle this case.
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>   arch/arm/mach-snapdragon/of_fixup.c | 40 +++++++++++++++++++++--------
>   1 file changed, 29 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/mach-snapdragon/of_fixup.c b/arch/arm/mach-snapdragon/of_fixup.c
> index eec2c0c757e0..5b6076ea8e57 100644
> --- a/arch/arm/mach-snapdragon/of_fixup.c
> +++ b/arch/arm/mach-snapdragon/of_fixup.c
> @@ -31,31 +31,37 @@
>    * USB controllers. Rather than requiring source level DT changes, we fix up
>    * DT here. This improves compatibility with upstream DT and simplifies the
>    * porting process for new devices.
>    */
> -static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np)
> +static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np, bool flat)
>   {
>   	struct device_node *dwc3;
>   	int ret, len, hsphy_idx = 1;
>   	const __be32 *phandles;
>   	const char *second_phy_name;
>   
>   	debug("Fixing up %s\n", glue_np->name);
>   
> +	/* New DT flattens the glue and controller into a single node. */
> +	if (flat) {
> +		dwc3 = glue_np;
> +		debug("%s uses flat DT\n", glue_np->name);
> +	} else {
> +		/* Find the DWC3 node itself */
> +		dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
> +		if (!dwc3) {
> +			log_err("Failed to find dwc3 node\n");
> +			return -ENOENT;
> +		}
> +	}
> +
>   	/* Tell the glue driver to configure the wrapper for high-speed only operation */
>   	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
>   	if (ret) {
>   		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
>   		return ret;
>   	}
>   
> -	/* Find the DWC3 node itself */
> -	dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
> -	if (!dwc3) {
> -		log_err("Failed to find dwc3 node\n");
> -		return -ENOENT;
> -	}
> -
>   	phandles = of_get_property(dwc3, "phys", &len);
>   	len /= sizeof(*phandles);
>   	if (len == 1) {
>   		log_debug("Only one phy, not a superspeed controller\n");
> @@ -103,15 +109,27 @@ static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np
>   }
>   
>   static void fixup_usb_nodes(struct device_node *root)
>   {
> -	struct device_node *glue_np = root;
> +	struct device_node *glue_np = root, *tmp;
>   	int ret;
> +	bool flat;
> +
> +	while (true) {
> +		flat = false;
> +		/* First check for the old DT format with glue node then the new flattened format */
> +		tmp = of_find_compatible_node(glue_np, NULL, "qcom,dwc3");
> +		if (!tmp) {
> +			tmp = of_find_compatible_node(glue_np, NULL, "qcom,snps-dwc3");
> +			flat = !!tmp;
> +		}
> +		if (!tmp)
> +			break;
> +		glue_np = tmp;
>   
> -	while ((glue_np = of_find_compatible_node(glue_np, NULL, "qcom,dwc3"))) {
>   		if (!of_device_is_available(glue_np))
>   			continue;
> -		ret = fixup_qcom_dwc3(root, glue_np);
> +		ret = fixup_qcom_dwc3(root, glue_np, flat);
>   		if (ret)
>   			log_warning("Failed to fixup node %s: %d\n", glue_np->name, ret);
>   	}
>   }

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

Thanks,
Neil

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

* Re: [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node
  2026-01-14 13:57 [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node Casey Connolly
  2026-01-14 14:39 ` Neil Armstrong
@ 2026-01-16  9:42 ` Sumit Garg
  2026-01-16 18:03 ` Casey Connolly
  2 siblings, 0 replies; 4+ messages in thread
From: Sumit Garg @ 2026-01-16  9:42 UTC (permalink / raw)
  To: Casey Connolly
  Cc: Neil Armstrong, Rui Miguel Silva, Tom Rini, u-boot-qcom,
	Sumit Garg, u-boot

On Wed, Jan 14, 2026 at 02:57:32PM +0100, Casey Connolly wrote:
> Qualcomm DTs are being updated to use a new format where the dwc3 glue
> node and controller are combined into a single DT node. Update the fixup
> code to handle this case.
> 
> Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
> ---
>  arch/arm/mach-snapdragon/of_fixup.c | 40 +++++++++++++++++++++--------
>  1 file changed, 29 insertions(+), 11 deletions(-)

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

-Sumit

> 
> diff --git a/arch/arm/mach-snapdragon/of_fixup.c b/arch/arm/mach-snapdragon/of_fixup.c
> index eec2c0c757e0..5b6076ea8e57 100644
> --- a/arch/arm/mach-snapdragon/of_fixup.c
> +++ b/arch/arm/mach-snapdragon/of_fixup.c
> @@ -31,31 +31,37 @@
>   * USB controllers. Rather than requiring source level DT changes, we fix up
>   * DT here. This improves compatibility with upstream DT and simplifies the
>   * porting process for new devices.
>   */
> -static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np)
> +static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np, bool flat)
>  {
>  	struct device_node *dwc3;
>  	int ret, len, hsphy_idx = 1;
>  	const __be32 *phandles;
>  	const char *second_phy_name;
>  
>  	debug("Fixing up %s\n", glue_np->name);
>  
> +	/* New DT flattens the glue and controller into a single node. */
> +	if (flat) {
> +		dwc3 = glue_np;
> +		debug("%s uses flat DT\n", glue_np->name);
> +	} else {
> +		/* Find the DWC3 node itself */
> +		dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
> +		if (!dwc3) {
> +			log_err("Failed to find dwc3 node\n");
> +			return -ENOENT;
> +		}
> +	}
> +
>  	/* Tell the glue driver to configure the wrapper for high-speed only operation */
>  	ret = of_write_prop(glue_np, "qcom,select-utmi-as-pipe-clk", 0, NULL);
>  	if (ret) {
>  		log_err("Failed to add property 'qcom,select-utmi-as-pipe-clk': %d\n", ret);
>  		return ret;
>  	}
>  
> -	/* Find the DWC3 node itself */
> -	dwc3 = of_find_compatible_node(glue_np, NULL, "snps,dwc3");
> -	if (!dwc3) {
> -		log_err("Failed to find dwc3 node\n");
> -		return -ENOENT;
> -	}
> -
>  	phandles = of_get_property(dwc3, "phys", &len);
>  	len /= sizeof(*phandles);
>  	if (len == 1) {
>  		log_debug("Only one phy, not a superspeed controller\n");
> @@ -103,15 +109,27 @@ static int fixup_qcom_dwc3(struct device_node *root, struct device_node *glue_np
>  }
>  
>  static void fixup_usb_nodes(struct device_node *root)
>  {
> -	struct device_node *glue_np = root;
> +	struct device_node *glue_np = root, *tmp;
>  	int ret;
> +	bool flat;
> +
> +	while (true) {
> +		flat = false;
> +		/* First check for the old DT format with glue node then the new flattened format */
> +		tmp = of_find_compatible_node(glue_np, NULL, "qcom,dwc3");
> +		if (!tmp) {
> +			tmp = of_find_compatible_node(glue_np, NULL, "qcom,snps-dwc3");
> +			flat = !!tmp;
> +		}
> +		if (!tmp)
> +			break;
> +		glue_np = tmp;
>  
> -	while ((glue_np = of_find_compatible_node(glue_np, NULL, "qcom,dwc3"))) {
>  		if (!of_device_is_available(glue_np))
>  			continue;
> -		ret = fixup_qcom_dwc3(root, glue_np);
> +		ret = fixup_qcom_dwc3(root, glue_np, flat);
>  		if (ret)
>  			log_warning("Failed to fixup node %s: %d\n", glue_np->name, ret);
>  	}
>  }
> -- 
> 2.51.0
> 

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

* Re: [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node
  2026-01-14 13:57 [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node Casey Connolly
  2026-01-14 14:39 ` Neil Armstrong
  2026-01-16  9:42 ` Sumit Garg
@ 2026-01-16 18:03 ` Casey Connolly
  2 siblings, 0 replies; 4+ messages in thread
From: Casey Connolly @ 2026-01-16 18:03 UTC (permalink / raw)
  To: Neil Armstrong, Rui Miguel Silva, Sumit Garg, Tom Rini,
	Casey Connolly
  Cc: u-boot-qcom, Sumit Garg, u-boot


On Wed, 14 Jan 2026 14:57:32 +0100, Casey Connolly wrote:
> Qualcomm DTs are being updated to use a new format where the dwc3 glue
> node and controller are combined into a single DT node. Update the fixup
> code to handle this case.
> 
> 

Applied, thanks!

[1/1] mach-snapdragon: of_fixup: support new flat dwc3 node
      https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/9be4f2f5f4d0

Best regards,
-- 
// Casey (she/they)



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

end of thread, other threads:[~2026-01-16 18:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-14 13:57 [PATCH] mach-snapdragon: of_fixup: support new flat dwc3 node Casey Connolly
2026-01-14 14:39 ` Neil Armstrong
2026-01-16  9:42 ` Sumit Garg
2026-01-16 18:03 ` Casey Connolly

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