From: Eric Chung <eric.chung@riscstar.com>
To: u-boot-spacemit@groups.io, u-boot@lists.u-boot-project.org,
Yao Zi <me@ziyao.cc>,
u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>, Tim Ouyang <tim609@andestech.com>,
Leo Liang <leo.liang@sifive.com>, Wei Fu <wefu@redhat.com>,
Scott Bambrough <scott@riscstar.com>,
Huan Zhou <pericycle.cc@gmail.com>,
Eric Chung <eric.chung@riscstar.com>,
Raymond Mao <raymond.mao@riscstar.com>,
Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Anshul Dalal <anshuld@ti.com>, Siu Ming Tong <smtong@axiado.com>,
Johan Jonker <jbx6244@gmail.com>
Subject: [PATCH v13 7/7] spacemit: k1: fix product name detection and DTB matching in SPL
Date: Sat, 12 Sep 2026 20:37:00 +0800 [thread overview]
Message-ID: <20260912-m4-v13-7-71043b29630f@riscstar.com> (raw)
In-Reply-To: <20260912-m4-v13-0-71043b29630f@riscstar.com>
Use a table to handle DTB matching.
Signed-off-by: Eric Chung <eric.chung@riscstar.com>
---
v7:
- Abandon to load product name from ENV.
v6:
- Rebased onto latest upstream. Cleaned up board_fit_config_name_match()
to maintain consistentcy with v5.
---
board/spacemit/k1/spl.c | 50 +++++++++++++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
index 374922573c98..ef23db62d6cc 100644
--- a/board/spacemit/k1/spl.c
+++ b/board/spacemit/k1/spl.c
@@ -141,6 +141,15 @@ static void i2c_early_init(void)
}
}
+static const struct {
+ const char *eeprom_name;
+ const char *fit_name;
+} k1_board_map[] = {
+ { "k1-x_MUSE-Pi-Pro", "spacemit/k1-musepi-pro" },
+ { "k1-x_deb1", "spacemit/k1-bananapi-f3" },
+ { "k1-x_milkv-jupiter", "spacemit/k1-milkv-jupiter" },
+};
+
int read_product_name(char *name, int size)
{
u8 eeprom_data[TLV_TOTAL_LEN_MAX], *p;
@@ -174,6 +183,27 @@ int read_product_name(char *name, int size)
return -ENOENT;
}
+static void fixup_product_name(void)
+{
+ char fdt_name[I2C_BUF_SIZE];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(k1_board_map); i++) {
+ memset(fdt_name, 0, I2C_BUF_SIZE);
+ if (!strncmp(product_name, k1_board_map[i].eeprom_name,
+ strlen(k1_board_map[i].eeprom_name))) {
+ snprintf(fdt_name, I2C_BUF_SIZE, "%s",
+ k1_board_map[i].fit_name);
+ break;
+ }
+ }
+ if (fdt_name[0] == '\0') {
+ /* set default board name */
+ sprintf(fdt_name, CONFIG_DEFAULT_DEVICE_TREE);
+ }
+ memcpy(product_name, fdt_name, I2C_BUF_SIZE);
+}
+
static void clk_early_init(void)
{
struct udevice *dev;
@@ -417,6 +447,7 @@ void board_init_f(ulong dummy)
log_info("Fail to detect board:%d\n", ret);
else
log_info("Get board name:%s\n", product_name);
+ fixup_product_name();
pmic_init();
ddr_early_init();
@@ -459,24 +490,7 @@ void spl_board_init(void)
int board_fit_config_name_match(const char *name)
{
- char fdt_name[I2C_BUF_SIZE];
- int i;
-
- memset(fdt_name, 0, I2C_BUF_SIZE);
- if (!strncmp(product_name, "k1-x_", 5)) {
- snprintf(fdt_name, I2C_BUF_SIZE, "%s-%s", "k1",
- &product_name[5]);
- }
- if (fdt_name[0] == '\0') {
- /* set default board name */
- sprintf(fdt_name, "k1-musepi-pro");
- }
- for (i = 0; i < I2C_BUF_SIZE; i++) {
- if (fdt_name[i] == '\0')
- break;
- fdt_name[i] = tolower(fdt_name[i]);
- }
- if (!strcmp(name, fdt_name))
+ if (!strcmp(name, product_name))
return 0;
return -ENOENT;
}
--
2.51.0
next prev parent reply other threads:[~2026-09-12 12:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 12:36 [PATCH v13 0/7] spacemit mmc driver Eric Chung
2026-09-12 12:36 ` [PATCH v13 1/7] spacemit: k1: select boot device via config registers Eric Chung
2026-09-12 12:36 ` [PATCH v13 2/7] mmc: k1: add sdhci platform driver Eric Chung
2026-09-16 12:40 ` Yixun Lan
2026-09-23 13:23 ` Yixun Lan
2026-09-12 12:36 ` [PATCH v13 3/7] dts: k1: enable mmc devices in SPL Eric Chung
2026-09-12 12:36 ` [PATCH v13 4/7] configs: k1: enable SD and eMMC support Eric Chung
2026-09-12 12:36 ` [PATCH v13 5/7] MAINTAINER: update Spacemit K1 entry Eric Chung
2026-09-12 12:36 ` [PATCH v13 6/7] doc: spacemit: flash on K1 SoC based boards Eric Chung
2026-09-12 12:37 ` Eric Chung [this message]
2026-10-02 12:58 ` [PATCH v13 7/7] spacemit: k1: fix product name detection and DTB matching in SPL Andre Heider
2026-10-05 4:01 ` Eric Chung
2026-10-05 7:23 ` Andre Heider
2026-10-05 15:34 ` Eric Chung
2026-10-05 21:33 ` E Shattow
2026-10-06 6:57 ` Andre Heider
2026-09-16 12:27 ` [PATCH v13 0/7] spacemit mmc driver Yixun Lan
2026-09-29 10:14 ` Yixun Lan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260912-m4-v13-7-71043b29630f@riscstar.com \
--to=eric.chung@riscstar.com \
--cc=anshuld@ti.com \
--cc=bastien.curutchet@bootlin.com \
--cc=jbx6244@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=leo.liang@sifive.com \
--cc=me@ziyao.cc \
--cc=peng.fan@nxp.com \
--cc=pericycle.cc@gmail.com \
--cc=raymond.mao@riscstar.com \
--cc=scott@riscstar.com \
--cc=smtong@axiado.com \
--cc=tim609@andestech.com \
--cc=trini@konsulko.com \
--cc=u-boot-spacemit@groups.io \
--cc=u-boot@lists.u-boot-project.org \
--cc=wefu@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.