All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] board: starfive: visionfive2: Order board detection logic to match config
@ 2025-04-27  6:02 E Shattow
  2025-04-27 13:52 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: E Shattow @ 2025-04-27  6:02 UTC (permalink / raw)
  To: Minda Chen, Hal Feng, Tom Rini; +Cc: E Shattow, u-boot

Fixup previous merge resolution of this series. Intent is to ease code
readability and logic to match ordering in CONFIG_OF_LIST

- Remove "starfive/" string math
- Remove redundant local cache of calls to get_*_from_eeprom()
- Match name before EEPROM product_id in board_fit_config_name_match()
- Remove single-consumer FDTFILE_* defines
- Do not set fdtfile for visionfive-2-* when unknown model revision

Fixes: 5a0a93a76848 ("Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-riscv")

Signed-off-by: E Shattow <e@freeshell.de>
---
 board/starfive/visionfive2/spl.c              | 33 +++-----------
 .../visionfive2/starfive_visionfive2.c        | 43 +++++++------------
 2 files changed, 21 insertions(+), 55 deletions(-)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index 353313b9e88..3dfa931b655 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -116,44 +116,23 @@ void board_init_f(ulong dummy)
 #if CONFIG_IS_ENABLED(LOAD_FIT)
 int board_fit_config_name_match(const char *name)
 {
-	const char *product_id;
-	u8 version;
-
-	product_id = get_product_id_from_eeprom();
-
-	/* Strip off prefix */
-	if (strncmp(name, "starfive/", 9))
-		return -EINVAL;
-	name += 9;
-	if (!strncmp(product_id, "FML13V01", 8) &&
-	    !strcmp(name, "jh7110-deepcomputing-fml13v01")) {
-		return 0;
-	} else if (!strncmp(product_id, "VF7110", 6)) {
-		version = get_pcb_revision_from_eeprom();
-		if ((version == 'b' || version == 'B') &&
-		    !strcmp(name, "jh7110-starfive-visionfive-2-v1.3b"))
-			return 0;
-
-		if ((version == 'a' || version == 'A') &&
-		    !strcmp(name, "jh7110-starfive-visionfive-2-v1.2a"))
-			return 0;
-	} else if (!strncmp(product_id, "MARS", 4) &&
-		   !strcmp(name, "jh7110-milkv-mars")) {
+	if (!strcmp(name, "starfive/jh7110-deepcomputing-fml13v01") &&
+		    !strncmp(get_product_id_from_eeprom(), "FML13V01", 8)) {
 		return 0;
 	} else if (!strcmp(name, "starfive/jh7110-milkv-mars") &&
-		   !strncmp(get_product_id_from_eeprom(), "MARS", 4)) {
+		    !strncmp(get_product_id_from_eeprom(), "MARS", 4)) {
 		return 0;
-	} else if ((!strcmp(name, "starfive/jh7110-pine64-star64")) &&
+	} else if (!strcmp(name, "starfive/jh7110-pine64-star64") &&
 		    !strncmp(get_product_id_from_eeprom(), "STAR64", 6)) {
 		return 0;
-	} else if ((!strcmp(name, "starfive/jh7110-starfive-visionfive-2-v1.2a")) &&
+	} else if (!strcmp(name, "starfive/jh7110-starfive-visionfive-2-v1.2a") &&
 		    !strncmp(get_product_id_from_eeprom(), "VF7110", 6)) {
 		switch (get_pcb_revision_from_eeprom()) {
 		case 'a':
 		case 'A':
 			return 0;
 		}
-	} else if ((!strcmp(name, "starfive/jh7110-starfive-visionfive-2-v1.2b")) &&
+	} else if (!strcmp(name, "starfive/jh7110-starfive-visionfive-2-v1.3b") &&
 		    !strncmp(get_product_id_from_eeprom(), "VF7110", 6)) {
 		switch (get_pcb_revision_from_eeprom()) {
 		case 'b':
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index 4b273e52e9a..bfbb11a2ee7 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -17,16 +17,6 @@
 DECLARE_GLOBAL_DATA_PTR;
 #define JH7110_L2_PREFETCHER_BASE_ADDR		0x2030000
 #define JH7110_L2_PREFETCHER_HART_OFFSET	0x2000
-#define FDTFILE_FML13V01 \
-	"starfive/jh7110-deepcomputing-fml13v01.dtb"
-#define FDTFILE_MILK_V_MARS \
-	"starfive/jh7110-milkv-mars.dtb"
-#define FDTFILE_VISIONFIVE2_1_2A \
-	"starfive/jh7110-starfive-visionfive-2-v1.2a.dtb"
-#define FDTFILE_VISIONFIVE2_1_3B \
-	"starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
-#define FDTFILE_PINE64_STAR64 \
-	"starfive/jh7110-pine64-star64.dtb"
 
 /* enable U74-mc hart1~hart4 prefetcher */
 static void enable_prefetcher(void)
@@ -48,44 +38,41 @@ static void enable_prefetcher(void)
 }
 
 /**
- * set_fdtfile() - set the $fdtfile variable based on the board revision
+ * set_fdtfile() - set the $fdtfile variable based on product data in EEPROM
  */
 static void set_fdtfile(void)
 {
-	u8 version;
 	const char *fdtfile;
-	const char *product_id;
 
 	fdtfile = env_get("fdtfile");
 	if (fdtfile)
 		return;
 
-	product_id = get_product_id_from_eeprom();
-	if (!product_id) {
+	if (!get_product_id_from_eeprom()) {
 		log_err("Can't read EEPROM\n");
 		return;
 	}
-	if (!strncmp(product_id, "FML13V01", 8)) {
-		fdtfile = FDTFILE_FML13V01;
-	} else if (!strncmp(product_id, "MARS", 4)) {
-		fdtfile = FDTFILE_MILK_V_MARS;
-	} else if (!strncmp(product_id, "VF7110", 6)) {
-		version = get_pcb_revision_from_eeprom();
 
-		switch (version) {
+	if (!strncmp(get_product_id_from_eeprom(), "FML13V01", 8)) {
+		fdtfile = "starfive/jh7110-deepcomputing-fml13v01.dtb";
+	} else if (!strncmp(get_product_id_from_eeprom(), "MARS", 4)) {
+		fdtfile = "starfive/jh7110-milkv-mars.dtb";
+	} else if (!strncmp(get_product_id_from_eeprom(), "STAR64", 6)) {
+		fdtfile = "starfive/jh7110-pine64-star64.dtb";
+	} else if (!strncmp(get_product_id_from_eeprom(), "VF7110", 6)) {
+		switch (get_pcb_revision_from_eeprom()) {
 		case 'a':
 		case 'A':
-			fdtfile = FDTFILE_VISIONFIVE2_1_2A;
+			fdtfile = "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb";
 			break;
-
 		case 'b':
 		case 'B':
-		default:
-			fdtfile = FDTFILE_VISIONFIVE2_1_3B;
+			fdtfile = "starfive/jh7110-starfive-visionfive-2-v1.3b.dtb";
 			break;
+		default:
+			log_err("Unknown revision\n");
+			return;
 		}
-	} else if (!strncmp(product_id, "STAR64", 6)) {
-		fdtfile = FDTFILE_PINE64_STAR64;
 	} else {
 		log_err("Unknown product\n");
 		return;

base-commit: 5a0a93a768487e55ebe50a34cc90d751bf99cc56
-- 
2.49.0


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

* Re: [PATCH v2] board: starfive: visionfive2: Order board detection logic to match config
  2025-04-27  6:02 [PATCH v2] board: starfive: visionfive2: Order board detection logic to match config E Shattow
@ 2025-04-27 13:52 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2025-04-27 13:52 UTC (permalink / raw)
  To: Minda Chen, Hal Feng, E Shattow; +Cc: u-boot

On Sat, 26 Apr 2025 23:02:52 -0700, E Shattow wrote:

> Fixup previous merge resolution of this series. Intent is to ease code
> readability and logic to match ordering in CONFIG_OF_LIST
> 
> - Remove "starfive/" string math
> - Remove redundant local cache of calls to get_*_from_eeprom()
> - Match name before EEPROM product_id in board_fit_config_name_match()
> - Remove single-consumer FDTFILE_* defines
> - Do not set fdtfile for visionfive-2-* when unknown model revision
> 
> [...]

Applied to u-boot/master, thanks!

[1/1] board: starfive: visionfive2: Order board detection logic to match config
      commit: 62ea9c329a0d013993bae538c55dfea06e4551bd
-- 
Tom



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

end of thread, other threads:[~2025-04-27 13:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-27  6:02 [PATCH v2] board: starfive: visionfive2: Order board detection logic to match config E Shattow
2025-04-27 13:52 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.