public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2] mach-snapdragon: Update fdtfile logic to work for RB1 and RB2
@ 2025-05-05 12:43 Sumit Garg
  2025-06-03 15:00 ` Casey Connolly
  0 siblings, 1 reply; 2+ messages in thread
From: Sumit Garg @ 2025-05-05 12:43 UTC (permalink / raw)
  To: casey.connolly, neil.armstrong
  Cc: u-boot-qcom, u-boot, trini, loic.minier, Sumit Garg

From: Sumit Garg <sumit.garg@oss.qualcomm.com>

RB1 and RB2 have three root compatibles where the last one can't be used
to decode fdtfile name (qcm* vs qrb*). So rather just rely on the first
compatible to retrieve the SoC name.

Signed-off-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
---
 arch/arm/mach-snapdragon/board.c | 63 ++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 27 deletions(-)

Changes in v2:
- Avoid redundant env_set() for SoC name.

diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index a3b39e3b4b3..5f241bafc85 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -417,52 +417,39 @@ static void configure_env(void)
 		return;
 	}
 
-	/* The last compatible is always the SoC compatible */
-	ret = ofnode_read_string_index(root, "compatible", compat_count - 1, &last_compat);
-	if (ret < 0) {
-		log_warning("Can't read second compatible\n");
-		return;
-	}
-
-	/* Copy the second compat (e.g. "qcom,sdm845") into buf */
-	strlcpy(buf, last_compat, sizeof(buf) - 1);
-	tmp = buf;
-
-	/* strsep() is destructive, it replaces the comma with a \0 */
-	if (!strsep(&tmp, ",")) {
-		log_warning("second compatible '%s' has no ','\n", buf);
-		return;
-	}
-
-	/* tmp now points to just the "sdm845" part of the string */
-	env_set("soc", tmp);
-
-	/* Now figure out the "board" part from the first compatible */
-	memset(buf, 0, sizeof(buf));
 	strlcpy(buf, first_compat, sizeof(buf) - 1);
 	tmp = buf;
 
 	/* The Qualcomm reference boards (RBx, HDK, etc)  */
 	if (!strncmp("qcom", buf, strlen("qcom"))) {
+		char *soc;
+
 		/*
 		 * They all have the first compatible as "qcom,<soc>-<board>"
 		 * (e.g. "qcom,qrb5165-rb5"). We extract just the part after
 		 * the dash.
 		 */
-		if (!strsep(&tmp, "-")) {
+		if (!strsep(&tmp, ",")) {
+			log_warning("compatible '%s' has no ','\n", buf);
+			return;
+		}
+		soc = strsep(&tmp, "-");
+		if (!soc) {
 			log_warning("compatible '%s' has no '-'\n", buf);
 			return;
 		}
-		/* tmp is now "rb5" */
+
+		env_set("soc", soc);
 		env_set("board", tmp);
 	} else {
 		if (!strsep(&tmp, ",")) {
 			log_warning("compatible '%s' has no ','\n", buf);
 			return;
 		}
-		/* for thundercomm we just want the bit after the comma (e.g. "db845c"),
-		 * for all other boards we replace the comma with a '-' and take both
-		 * (e.g. "oneplus-enchilada")
+		/*
+		 * For thundercomm we just want the bit after the comma
+		 * (e.g. "db845c"), for all other boards we replace the comma
+		 * with a '-' and take both (e.g. "oneplus-enchilada")
 		 */
 		if (!strncmp("thundercomm", buf, strlen("thundercomm"))) {
 			env_set("board", tmp);
@@ -470,6 +457,28 @@ static void configure_env(void)
 			*(tmp - 1) = '-';
 			env_set("board", buf);
 		}
+
+		/* The last compatible is always the SoC compatible */
+		ret = ofnode_read_string_index(root, "compatible",
+					       compat_count - 1, &last_compat);
+		if (ret < 0) {
+			log_warning("Can't read second compatible\n");
+			return;
+		}
+
+		/* Copy the last compat (e.g. "qcom,sdm845") into buf */
+		memset(buf, 0, sizeof(buf));
+		strlcpy(buf, last_compat, sizeof(buf) - 1);
+		tmp = buf;
+
+		/* strsep() is destructive, it replaces the comma with a \0 */
+		if (!strsep(&tmp, ",")) {
+			log_warning("second compatible '%s' has no ','\n", buf);
+			return;
+		}
+
+		/* tmp now points to just the "sdm845" part of the string */
+		env_set("soc", tmp);
 	}
 
 	/* Now build the full path name */
-- 
2.43.0


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

* Re: [PATCH v2] mach-snapdragon: Update fdtfile logic to work for RB1 and RB2
  2025-05-05 12:43 [PATCH v2] mach-snapdragon: Update fdtfile logic to work for RB1 and RB2 Sumit Garg
@ 2025-06-03 15:00 ` Casey Connolly
  0 siblings, 0 replies; 2+ messages in thread
From: Casey Connolly @ 2025-06-03 15:00 UTC (permalink / raw)
  To: neil.armstrong, Sumit Garg
  Cc: u-boot-qcom, u-boot, trini, loic.minier, Sumit Garg


On Mon, 05 May 2025 18:13:33 +0530, Sumit Garg wrote:
> RB1 and RB2 have three root compatibles where the last one can't be used
> to decode fdtfile name (qcm* vs qrb*). So rather just rely on the first
> compatible to retrieve the SoC name.
> 
> 

Applied, thanks!

[1/1] mach-snapdragon: Update fdtfile logic to work for RB1 and RB2
      https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/commit/14315b73a8e7

Best regards,
-- 
Casey Connolly <casey.connolly@linaro.org>


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

end of thread, other threads:[~2025-06-03 15:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-05 12:43 [PATCH v2] mach-snapdragon: Update fdtfile logic to work for RB1 and RB2 Sumit Garg
2025-06-03 15:00 ` Casey Connolly

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