Skip to contentSkip to conversation

spacemit mmc driver

PATCH Superseded Eric Chung 3 participants 15 messages Sep 6 – Sep 8

Subsystems (3)

v12 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Eric Chung

author
#0 lore raw

v12 cover spacemit mmc driver

This series adds MMC support for the SpacemiT K1: an SDHCI platform driver, the SD card device-tree overlay, defconfig options, and SPL boot-device selection from the SoC strap/config registers. The SDHCI driver is usable in both SPL and U-Boot proper.

A flashing guide (doc/board/spacemit/k1-flash.rst) describes how to write images to eMMC.

---
Changes in v12:
- dts: Drop all upstreamed DTS patches since they're merged now.
- Link to v11: https://patch.msgid.link/[email protected]

Changes in v11:
- spl: Fix the read_boot_mode() that returns both boot mode and boot device.
- Link to v10: https://patch.msgid.link/[email protected]

Changes in v10:
- pinctrl: Move all pinctrl patches into a new patch set.
- Link to v9: https://patch.msgid.link/[email protected]

Changes in v9:
- spl: Enhance detection on booting from SD.
- dts: Synched upstream DTS files for K1.
- doc: Create SD card image from scratch.
- mmc: Avoid to use CMD18 on SD card in SPL.
- pinctrl: Drop "fix drive strength configuration".
- Link to v8: https://patch.msgid.link/[email protected]

Changes in v8:
- doc: Remove SD card.
- Link to v7: https://patch.msgid.link/[email protected]

Changes in v7:
- env: Drop env support on the mmc series.
- dts: Sync upstream DTS files for spacemit.
- pinctrl: Simply clrsetbits_le32() on pull-up/pull-down configuration.
- spl: Fix DTB matching.
- Link to v6: https://patch.msgid.link/[email protected]

Changes in v6:
- pinctrl: Fix drive strength configuration.
- pinctrl: Fix pull-up/pull-down configuration.
- pinctrl: Use dev_read_phandle_with_args() to fetch "spacemit,syscon" instead.
- spacemit: rebase on latest upstream branch.
- Link to v5: https://patch.msgid.link/[email protected]

Changes in v5:
- mmc: Split CMD23 support out.
- mmc: Use read_poll_timeout().
- mmc: Set pinctrl state based on selected timing mode.
- mmc: Remove the condition based on quirks.
- pinctrl: Fix power source argument.
- dts: Add missing power source on mmc pins.
- Link to v4: https://patch.msgid.link/[email protected]

Changes in v4:
- mmc: Add CMD23 for write.
- mmc: Fix CMD23 only for CMD18.
- mmc: Update bulk release operations on reset and clocks for spacemit platform driver.
- MAINTAINER: update the maintainer of Spacemit K1.
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- pinctrl: Fix "fast" by "uhs".
- pinctrl: Add syscon dependency.
- mmc: Fix quick by capability.
- doc: Add SD boot support.
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/T/#m2aba875a2696a7bb9b704618d22ae2fd7f7f5acc

Changes in v2:
- cmd: drop patches on eminfo & tlv_eeprom.
- configs: Enable ADMA and SYSCON support.
- dts: Use vmmc-supply as vqmmc-supply on the SD card node.
- mmc: k1: Enable ADMA mode support, use CMD23 for multi-block
read/write, correct pinctrl state from "fast" to "uhs".
- mmc: sdhci: Add new quirk patch to enable CMD23 for multi-block
transfers.
- pinctrl: k1: Add new IO power domain configuration support for
dual-voltage GPIO banks.
- spacemit: k1: Use FIELD_GET() to parse boot strap mode.
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

To: [email protected]
To: [email protected]
To: Yao Zi <[email protected]>

Cc Huan Zhou <[email protected]>
Cc Tom Rini <[email protected]>
Cc Guodong Xu <[email protected]>
Cc Raymond Mao <[email protected]>
Cc Peng Fan <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Anshul Dalal <[email protected]>
Cc Bastien Curutchet <[email protected]>
Cc Johan Jonker <[email protected]>
Cc Sumit Garg <[email protected]>
Cc Yixun Lan <[email protected]>
Cc Iker Pedrosa <[email protected]>
Cc Alex Elder <[email protected]>
Cc Andre Heider <[email protected]>
Cc Trevor Gamblin <[email protected]>
Cc Tim Ouyang <[email protected]>
Cc Leo Liang <[email protected]>

---
Eric Chung (7):
spacemit: k1: select boot device via config registers
mmc: k1: add sdhci platform driver
dts: k1: enable mmc devices in SPL
configs: k1: enable SD and eMMC support
MAINTAINER: update Spacemit K1 entry
doc: spacemit: flash on K1 SoC based boards
spacemit: k1: fix product name detection and DTB matching in SPL

 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi |  12 +-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 136 +-----
 board/spacemit/k1/MAINTAINERS             |   5 +-
 board/spacemit/k1/spl.c                   | 148 ++++++-
 configs/spacemit_k1_defconfig             |  22 +
 doc/board/spacemit/index.rst              |   1 +
 doc/board/spacemit/k1-mmc.rst             | 271 ++++++++++++
 drivers/mmc/Kconfig                       |   7 +
 drivers/mmc/Makefile                      |   1 +
 drivers/mmc/spacemit_sdhci.c              | 684 ++++++++++++++++++++++++++++++
 10 files changed, 1139 insertions(+), 148 deletions(-)

---
base-commit: 8c29b52d168877c3d5c5e3906c7481b21cf14956
change-id: 20260629-m4-98e01659fefb

Best regards,

Signature · 1 line
Eric Chung <[email protected]>
author
#1 lore raw

PATCH v12 1/7 spacemit: k1: select boot device via config registers

Add logic to determine the current boot device by reading the SoC's configuration registers, rather than using a hardcoded default.

---
v11:
- Fix read_boot_mode() on returning both boot mode and boot device. v9:
- Enhance detection on booting from SD card.
v5:
- Add blank lines around the switch statement.
v2:
- Use FIELD_GET() to parse boot strap mode.
- Remove comments on hacking. Since the sequence between eMMC and SD device is exchanged in the upstream DTS. So it isn't a hacking any more.

---
 board/spacemit/k1/spl.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 97 insertions(+), 1 deletion(-)
board/spacemit/k1/spl.c +97 -1
index d749e21a2d57..374922573c98 100644
@@ -13,6 +13,7 @@
 #include <dm/device.h>
 #include <dm/uclass.h>
 #include <i2c.h>
+#include <linux/bitfield.h>
 #include <linux/ctype.h>
 #include <linux/delay.h>
 #include <log.h>
@@ -22,6 +23,20 @@
 #include <tlv_eeprom.h>
 #include "tlv_codes.h"
 
+/* boot mode configs */
+#define BOOT_DEV_FLAG_REG	0xd4282d10
+#define BOOT_PIN_SEL_REG	0xd4282c20
+
+#define BOOT_STRAP_MODE_OFFSET	9
+#define BOOT_STRAP_MODE_MASK	3
+#define BOOT_STRAP_MODE_EMMC	0
+#define BOOT_STRAP_MODE_SPI	1
+#define BOOT_STRAP_MODE_NAND	2
+#define BOOT_STRAP_MODE_SD	3
+
+#define STORAGE_API_P_ADDR	0xc0838498
+#define SDCARD_API_ENTRY	0xffe0a548
+
 #define MUX_MODE4		4
 #define EDGE_NONE		BIT(6)
 #define PULL_UP			(6 << 13)       /* bit[15:13] 110 */
@@ -46,6 +61,17 @@ typedef void (*puts_func_t)(const char *s);
 typedef int (*ddr_init_func_t)(u64 ddr_base, u32 cs_num, u32 data_rate,
 			       puts_func_t puts);
 
+enum board_boot_mode {
+	BOOT_MODE_NONE = 0,
+	BOOT_MODE_USB = 0x55a,
+	BOOT_MODE_EMMC,
+	BOOT_MODE_NAND,
+	BOOT_MODE_SPI,
+	BOOT_MODE_SD,
+	BOOT_MODE_SHELL = 0x55f,
+	BOOT_MODE_BOOTSTRAP,
+};
+
 struct ddr_cfg {
 	u32     data_rate;
 	u32     cs_num;
@@ -58,6 +84,47 @@ binman_sym_declare(ulong, ddr_fw, size);
 
 char product_name[I2C_BUF_SIZE] = "k1";
 
+static u32 read_boot_mode(void)
+{
+	void __iomem *boot_dev = (void __iomem *)BOOT_DEV_FLAG_REG;
+	void __iomem *boot_strap = (void __iomem *)BOOT_PIN_SEL_REG;
+	void __iomem *storage_api = (void __iomem *)STORAGE_API_P_ADDR;
+	u32 mode, sel;
+
+	mode = readl(storage_api);
+	if (mode == SDCARD_API_ENTRY)
+		return BOOT_MODE_SD;
+
+	mode = readl(boot_dev);
+	if (mode == BOOT_MODE_NONE || mode > BOOT_MODE_SD) {
+		sel = FIELD_GET(BOOT_STRAP_MODE_MASK << BOOT_STRAP_MODE_OFFSET,
+				readl(boot_strap));
+		switch (sel) {
+		case BOOT_STRAP_MODE_EMMC:
+			mode = BOOT_MODE_EMMC;
+			break;
+		case BOOT_STRAP_MODE_NAND:
+			mode = BOOT_MODE_NAND;
+			break;
+		case BOOT_STRAP_MODE_SPI:
+			mode = BOOT_MODE_SPI;
+			break;
+		case BOOT_STRAP_MODE_SD:
+		default:
+			mode = BOOT_MODE_SD;
+			break;
+		}
+	}
+	return mode;
+}
+
+static void write_boot_mode(u32 mode)
+{
+	void __iomem *boot_dev = (void __iomem *)BOOT_DEV_FLAG_REG;
+
+	writel(mode, boot_dev);
+}
+
 static void i2c_early_init(void)
 {
 	struct udevice *bus;
@@ -327,8 +394,12 @@ void nor_early_init(void)
 
 void board_init_f(ulong dummy)
 {
+	u32 mode;
 	int ret;
 
+	mode = read_boot_mode();
+	write_boot_mode(mode);
+
 	ret = spl_early_init();
 	if (ret)
 		panic("spl_early_init() failed:%d\n", ret);
@@ -354,7 +425,32 @@ void board_init_f(ulong dummy)
 
 u32 spl_boot_device(void)
 {
-	return BOOT_DEVICE_SPI;
+	u32 mode;
+	int ret;
+
+	mode = read_boot_mode();
+	switch (mode) {
+	case BOOT_MODE_EMMC:
+		ret = BOOT_DEVICE_MMC1;
+		break;
+	case BOOT_MODE_NAND:
+		ret = BOOT_DEVICE_NAND;
+		break;
+	case BOOT_MODE_SPI:
+		ret = BOOT_DEVICE_SPI;
+		break;
+	case BOOT_MODE_USB:
+		ret = BOOT_DEVICE_USB;
+		break;
+	case BOOT_MODE_SD:
+		ret = BOOT_DEVICE_MMC2;
+		break;
+	default:
+		ret = BOOT_DEVICE_MMC1;
+		break;
+	}
+
+	return ret;
 }
 
 void spl_board_init(void)
Signature · 1 line
2.51.0
author
#2 lore raw

PATCH v12 2/7 mmc: k1: add sdhci platform driver

In reply to Eric Chung

Add SDHCI platform driver support for SpacemiT K1 SoC. This driver implements the necessary platform-specific operations for the SDHCI controller, enabling MMC/SD card functionality on K1-based platforms.

---
v9:
- Disable CMD18 (multiple-block read) for SD cards in SPL. v6:
- Remove ".data = 0" in spacemit_sdhci_ids[].
v5:
- Remove MMC_CAP_CMD23 as the CMD23 support is now a separate series.
- Use tabs for macro definition alignment.
- Use read_poll_timeout().
- Set pinctrl state based on selected timing mode.
- Add the definition of SDHC_DLL_REG1_HS400_VAL.
- Remove the condition based on quirks.
v4:
- Add bulk release operations on reset and clock.
v3:
- Enable CMD23 in capability.
v2:
- Enable ADMA mode support.
- Use CMD23 for multi-block read/write.
- Move ASR/AIB register into pinctrl driver.
- Correct pinctrl state from "fast" to "uhs".
- Migrate tuning support from the spacemit linux driver.

---
 drivers/mmc/Kconfig          |   7 +
 drivers/mmc/Makefile         |   1 +
 drivers/mmc/spacemit_sdhci.c | 684 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 692 insertions(+)
drivers/mmc/Kconfig +7 -0
index 4ee56465c0fe..f3443cc9bed8 100644
@@ -729,6 +729,13 @@ config MMC_SDHCI_SNPS
 
 	  If unsure, say N.
 
+config MMC_SDHCI_SPACEMIT
+	bool "Spacemit SDHCI controller"
+	depends on MMC_SDHCI
+	help
+	  Support for Secure Digital Host Controller Interface (SDHCI) on
+	  Spacemit K1 SoC.
+
 config MMC_SDHCI_STI
 	bool "SDHCI support for STMicroelectronics SoC"
 	depends on MMC_SDHCI && OF_CONTROL && ARCH_STI
drivers/mmc/Makefile +1 -0
index f4a40ee10d5b..5130b46f29c0 100644
@@ -72,6 +72,7 @@ obj-$(CONFIG_MMC_SDHCI_ROCKCHIP)	+= rockchip_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_ADI)		+= adi_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_S5P)		+= s5p_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_SNPS)		+= snps_sdhci.o
+obj-$(CONFIG_MMC_SDHCI_SPACEMIT)	+= spacemit_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_STI)		+= sti_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_TANGIER)		+= tangier_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_TEGRA)		+= tegra_mmc.o
drivers/mmc/spacemit_sdhci.c new file +684 -0

684 lines not on this page · raw message

Signature · 1 line
2.51.0
#3 lore raw

Re: [PATCH v12 2/7] mmc: k1: add sdhci platform driver

Quoted 33 lines · Eric Chung

Add SDHCI platform driver support for SpacemiT K1 SoC. This driver implements the necessary platform-specific operations for the SDHCI controller, enabling MMC/SD card functionality on K1-based platforms.

---
v9:
- Disable CMD18 (multiple-block read) for SD cards in SPL. v6:
- Remove ".data = 0" in spacemit_sdhci_ids[].
v5:
- Remove MMC_CAP_CMD23 as the CMD23 support is now a separate series.
- Use tabs for macro definition alignment.
- Use read_poll_timeout().
- Set pinctrl state based on selected timing mode.
- Add the definition of SDHC_DLL_REG1_HS400_VAL.
- Remove the condition based on quirks.
v4:
- Add bulk release operations on reset and clock.
v3:
- Enable CMD23 in capability.
v2:
- Enable ADMA mode support.
- Use CMD23 for multi-block read/write.
- Move ASR/AIB register into pinctrl driver.
- Correct pinctrl state from "fast" to "uhs".
- Migrate tuning support from the spacemit linux driver.

---
 drivers/mmc/Kconfig          |   7 +
 drivers/mmc/Makefile         |   1 +
 drivers/mmc/spacemit_sdhci.c | 684 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 692 insertions(+)

...

Quoted 6 lines
drivers/mmc/spacemit_sdhci.c new file +0 -0
new file mode 100644
index 000000000000..4731c9ca0832
@@ -0,0 +1,684 @@

...

Quoted 1 line

+#define SPACEMIT_RX_DLINE_REG 9

There's an on-going series containing fixes for SpacemiT MMC controllers in Linux upstream, and I noticed this patch carries same issues for the delay granularity[1] and minimum RX tuning window[2]. Should it be fixed?

...

Quoted 2 lines
drivers/mmc/spacemit_sdhci.c new file +2 -0
+static int spacemit_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
+{

...

drivers/mmc/spacemit_sdhci.c line 458

Quoted 4 lines
drivers/mmc/spacemit_sdhci.c new file +4 -0
+	if (max_pass_len < 3) {
+		log_err("Tuning failed: no stable window found\n");
+		return -EIO;
+	}

and here.

Best regards,
Yao Zi

[1]: https://lore.kernel.org/spacemit/[email protected]/
[2]: https://lore.kernel.org/spacemit/[email protected]/

author
#4 lore raw

Re: [PATCH v12 2/7] mmc: k1: add sdhci platform driver

Quoted 65 lines · Yao Zi
Quoted 33 lines · Eric Chung

Add SDHCI platform driver support for SpacemiT K1 SoC. This driver implements the necessary platform-specific operations for the SDHCI controller, enabling MMC/SD card functionality on K1-based platforms.

---
v9:
- Disable CMD18 (multiple-block read) for SD cards in SPL. v6:
- Remove ".data = 0" in spacemit_sdhci_ids[].
v5:
- Remove MMC_CAP_CMD23 as the CMD23 support is now a separate series.
- Use tabs for macro definition alignment.
- Use read_poll_timeout().
- Set pinctrl state based on selected timing mode.
- Add the definition of SDHC_DLL_REG1_HS400_VAL.
- Remove the condition based on quirks.
v4:
- Add bulk release operations on reset and clock.
v3:
- Enable CMD23 in capability.
v2:
- Enable ADMA mode support.
- Use CMD23 for multi-block read/write.
- Move ASR/AIB register into pinctrl driver.
- Correct pinctrl state from "fast" to "uhs".
- Migrate tuning support from the spacemit linux driver.

---
 drivers/mmc/Kconfig          |   7 +
 drivers/mmc/Makefile         |   1 +
 drivers/mmc/spacemit_sdhci.c | 684 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 692 insertions(+)

...

Quoted 6 lines
drivers/mmc/spacemit_sdhci.c new file +0 -0
new file mode 100644
index 000000000000..4731c9ca0832
@@ -0,0 +1,684 @@

...

Quoted 1 line

+#define SPACEMIT_RX_DLINE_REG 9

There's an on-going series containing fixes for SpacemiT MMC controllers in Linux upstream, and I noticed this patch carries same issues for the delay granularity[1] and minimum RX tuning window[2]. Should it be fixed?

...

Quoted 2 lines
drivers/mmc/spacemit_sdhci.c new file +2 -0
+static int spacemit_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
+{

...

drivers/mmc/spacemit_sdhci.c line 458

Quoted 4 lines
drivers/mmc/spacemit_sdhci.c new file +4 -0
+     if (max_pass_len < 3) {
+             log_err("Tuning failed: no stable window found\n");
+             return -EIO;
+     }
Quoted 7 lines

and here.

Best regards,
Yao Zi

[1]: https://lore.kernel.org/spacemit/[email protected]/
[2]: https://lore.kernel.org/spacemit/[email protected]/

OK. I'll include them.

maintainer
#5 lore raw

Re: [PATCH v12 2/7] mmc: k1: add sdhci platform driver

Hi Eric,

Quoted 2 lines · Eric Chung
Quoted 1 line · Yao Zi

..

Quoted 26 lines
Quoted 26 lines
Quoted 3 lines
drivers/mmc/spacemit_sdhci.c new file +0 -0
@@ -0,0 +1,684 @@

...

Quoted 1 line

+#define SPACEMIT_RX_DLINE_REG 9

There's an on-going series containing fixes for SpacemiT MMC controllers in Linux upstream, and I noticed this patch carries same issues for the delay granularity[1] and minimum RX tuning window[2]. Should it be fixed?

...

Quoted 2 lines
drivers/mmc/spacemit_sdhci.c new file +2 -0
+static int spacemit_sdhci_execute_tuning(struct mmc *mmc, u8 opcode)
+{

...

drivers/mmc/spacemit_sdhci.c line 458

Quoted 4 lines
drivers/mmc/spacemit_sdhci.c new file +4 -0
+     if (max_pass_len < 3) {
+             log_err("Tuning failed: no stable window found\n");
+             return -EIO;
+     }

and here.

Quoted 7 lines
Quoted 5 lines

Best regards,
Yao Zi

[1]: https://lore.kernel.org/spacemit/[email protected]/
[2]: https://lore.kernel.org/spacemit/[email protected]/

OK. I'll include them.

I'm fine if you do this since the patches are quite trivial, but that series is mainly targeting for sdio support

Signature · 1 line
Yixun Lan (dlan)
author
#6 lore raw

PATCH v12 3/7 dts: k1: enable mmc devices in SPL

In reply to Eric Chung

Enable eMMC and SD device nodes in SPL stage. And set the bus frequency for mmc device nodes.

Remove the redundant device nodes that are delcared in upstream DTS files.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi |  12 ++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 136 +++---------------------------
 2 files changed, 21 insertions(+), 127 deletions(-)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +10 -2
index 7f9443d69510..3077cdee55d7 100644
@@ -50,7 +50,6 @@
 
 &i2c2 {
 	bootph-pre-ram;
-	resets = <&syscon_apbc RESET_TWSI2>;
 
 	eeprom@50 {
 		bootph-pre-ram;
@@ -65,7 +64,6 @@
  */
 &i2c8 {
 	bootph-pre-ram;
-	resets = <&syscon_apbc RESET_TWSI8>;
 
 	pmic@41 {
 		bootph-pre-ram;
@@ -89,6 +87,16 @@
 	};
 };
 
+&emmc {
+	bootph-pre-ram;
+	max-frequency = <204800000>;
+};
+
+&sdhci0 {
+	bootph-pre-ram;
+	max-frequency = <204800000>;
+};
+
 &binman {
 	u-boot-spl-ddr {
 		type = "section";
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +11 -125

183 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#7 lore raw

PATCH v12 4/7 configs: k1: enable SD and eMMC support

In reply to Eric Chung

Enable high-speed MMC modes.

---
v7:
- Remove the change on MAINTAINERS.
- Force DM to use alias by CONFIG_DM_SEQ_ALIAS. Since the sequence of mmc devices in DTS are inverted by alias.
v5:
- Remove ADMA support since it depends on CMD23 support.
- Enable PINCONF support for related power source setting. v2:
- Enable ADMA support.
- Enable SYSCON support.

---
 configs/spacemit_k1_defconfig | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
configs/spacemit_k1_defconfig +22 -0
index 0604c2feefc1..5f9923c7f470 100644
@@ -23,6 +23,7 @@ CONFIG_DEBUG_UART_BASE=0xd4017000
 CONFIG_DEBUG_UART_CLOCK=14700000
 CONFIG_TARGET_SPACEMIT_K1=y
 CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_ISA_ZICBOM=y
 CONFIG_RISCV_SMODE=y
 CONFIG_SPL_RISCV_MMODE=y
 # CONFIG_SPL_SMP is not set
@@ -48,6 +49,7 @@ CONFIG_SPL_CMD_TLV_EEPROM=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
 CONFIG_SPL_SYSCON=y
 CONFIG_CLK=y
 CONFIG_CLK_CCF=y
@@ -61,6 +63,7 @@ CONFIG_MISC=y
 CONFIG_I2C_EEPROM=y
 CONFIG_SPL_I2C_EEPROM=y
 CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
 CONFIG_PINCTRL_SPACEMIT_K1=y
 CONFIG_GPIO=y
 CONFIG_DM_GPIO=y
@@ -87,9 +90,28 @@ CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_MEM=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x000a0000
 CONFIG_CMD_SPI=y
+CONFIG_DM_SEQ_ALIAS=y
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SPACEMIT=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_MMC_HS400_SUPPORT=y
+CONFIG_MMC_HS400_ES_SUPPORT=y
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x4
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMINFO_MAP=y
+CONFIG_EFI_PARTITION=y
 CONFIG_SPL_SPI=y
 CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SPL_SPI_FLASH_TINY=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_MMC=y
+CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
Signature · 1 line
2.51.0
author
#8 lore raw

PATCH v12 5/7 MAINTAINER: update Spacemit K1 entry

In reply to Eric Chung

Update the maintainer for Spacemit K1 from Guodong to Eric.

Add mmc driver to maintained files.

---
v7:
- Add mmc driver to maintained files.
v4:
- Update the maintainer.

---
 board/spacemit/k1/MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
board/spacemit/k1/MAINTAINERS +2 -1
index 32d47ecc8f1e..4b2bc4ecfc10 100644
@@ -1,6 +1,6 @@
 BananaPi F3
 M:	Huan Zhou <[email protected]>
-M:	Guodong Xu <[email protected]>
+M:	Eric Chung <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	arch/riscv/dts/k1-*-u-boot.dtsi
@@ -9,6 +9,7 @@ F:	configs/spacemit_k1_defconfig
 F:	doc/board/spacemit/bananapi-f3.rst
 F:	drivers/gpio/spacemit_gpio.c
 F:	drivers/i2c/k1_i2c.c
+F:	drivers/mmc/spacemit_sdhci.c
 F:	drivers/pinctrl/spacemit/
 F:	drivers/power/pmic/pmic_spacemit_p1.c
 F:	drivers/power/regulator/spacemit_p1_regulator.c
Signature · 1 line
2.51.0
author
#9 lore raw

PATCH v12 6/7 doc: spacemit: flash on K1 SoC based boards

In reply to Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v9:
- Add to generate the partition table of SD card. v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 271 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 273 insertions(+), 1 deletion(-)
board/spacemit/k1/MAINTAINERS +1 -1
index 4b2bc4ecfc10..e12288a206e0 100644
@@ -6,7 +6,7 @@ S:	Maintained
 F:	arch/riscv/dts/k1-*-u-boot.dtsi
 F:	board/spacemit/k1/
 F:	configs/spacemit_k1_defconfig
-F:	doc/board/spacemit/bananapi-f3.rst
+F:	doc/board/spacemit/
 F:	drivers/gpio/spacemit_gpio.c
 F:	drivers/i2c/k1_i2c.c
 F:	drivers/mmc/spacemit_sdhci.c
doc/board/spacemit/index.rst +1 -0
index a5e35ee12ab6..71854e5735bd 100644
@@ -6,5 +6,6 @@ SpacemiT
    :maxdepth: 1
 
    bananapi-f3
+   k1-mmc
    k1-spl
 
doc/board/spacemit/k1-mmc.rst new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
2.51.0
#10 lore raw

Re: [PATCH v12 6/7] doc: spacemit: flash on K1 SoC based boards

Quoted 14 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v9:
- Add to generate the partition table of SD card. v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 271 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 273 insertions(+), 1 deletion(-)

...

Quoted 5 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 000000000000..0be5d5fa1c39

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 4GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``sgdisk``, ``lsblk`` commands)
+- The Bianbu release package from
+  <https://archive.spacemit.com/image/k1/version/bianbu/v2.3.3/Bianbu-Minimal-K1-V2.3.3-20260128183217.zip>
+- A custom ``FSBL.bin`` and ``u-boot.itb`` file to be written to the U-Boot
+  partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Obtain the release images**
+
+Unpack the release package to get the image files. Replace the ``FSBL.bin``
+and ``u-boot.itb`` with your custom builds.
+
+**2. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**3. Write the image to the SD card**
+
+Run ``sgdisk`` to generate the partition table, then use ``dd`` to write
+the images to the corresponding partitions.
+
+.. code-block:: console
+
+    $sudo sgdisk -o /dev/sdb
+    $sudo sgdisk -a 128 \
+        -n 1:256:767 -t 1:8300 \
+        -n 2:768:895 -t 2:8300 \
+        -n 3:2048:4095 -t 3:8300 \

doc/board/spacemit/k1-mmc.rst line 238

Quoted 10 lines
doc/board/spacemit/k1-mmc.rst new file +10 -0
+        -n 4:4096:8191 -t 4:8300 \
+        -n 5:8192:532479 -t 5:8300 \
+        -n 6:532480:4726783 -t 6:8300 \
+        /dev/sdb
+    $sudo dd if=FSBL.bin of=/dev/sdb1 bs=512 seek=0 status=progress
+    $sudo dd if=env.bin of=/dev/sdb2 bs=512 seek=0 status=progress
+    $sudo dd if=fw_dynamic.itb of=/dev/sdb3 bs=512 seek=0 status=progress
+    $sudo dd if=u-boot.itb of=/dev/sdb4 bs=512 seek=0 status=progress
+    $sudo dd if=bootfs.img of=/dev/sdb5 bs=1M status=progress
+    $sudo dd if=rootfs.ext4 of=/dev/sdb6 bs=1M status=progress

The bootfs/rootfs part aren't U-Boot-related stuff, so please omit them from this documentation to keep it simplified.

Then the only binary we need to extract from the "SpacemiT release package" is env.bin and fw_dynamic.bin.

For env.bin, I think this U-Boot port depends on no specific environment setttings? If no, please omit it, too; otherwise please provide a .env file in upstream U-Boot tree, and make it the default environment to use.

For fw_dynamic.bin, I think SpacemiT K1 support has been landed in the upstream OpenSBI tree? Please check if it works with upstream U-Boot. If no, please try fixing it, and then it's okay to stick to the downstream OpenSBI, but you need providing a guidance to build it from source if possible.

Then you could fully omit the step of downloading the "SpacemiT release package".

Quoted 22 lines
doc/board/spacemit/k1-mmc.rst new file +22 -0
+The SD card is now ready as a bootable system disk.
+
+Understanding the SD Card Partition Layout
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The role of each partition:
+
++----------+----------+------------------------------------+
+| Partition| Size     | Purpose                            |
++==========+==========+====================================+
+| ``sdb1`` | 256 KB   | FSBL (First Stage Bootloader)      |
++----------+----------+------------------------------------+
+| ``sdb2`` | 64 KB    | ENV                                |
++----------+----------+------------------------------------+
+| ``sdb3`` | 1 MB     | OpenSBI                            |
++----------+----------+------------------------------------+
+| ``sdb4`` | 2 MB     | U-Boot binary (``u-boot.itb``)     |
++----------+----------+------------------------------------+
+| ``sdb5`` | 256 MB   | Boot partition (kernel)            |
++----------+----------+------------------------------------+
+| ``sdb6`` | 2 GB     | Root filesystem (ext4)             |
++----------+----------+------------------------------------+

...

Quoted 2 lines
+- If the board boots successfully, the new device tree or U-Boot image
+  is compatible with your hardware.

This sentence looks extra, please drop it.

Best regards,
Yao Zi

author
#11 lore raw

Re: [PATCH v12 6/7] doc: spacemit: flash on K1 SoC based boards

Quoted 96 lines · Yao Zi
Quoted 14 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v9:
- Add to generate the partition table of SD card. v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 271 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 273 insertions(+), 1 deletion(-)

...

Quoted 5 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 000000000000..0be5d5fa1c39

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 4GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``sgdisk``, ``lsblk`` commands)
+- The Bianbu release package from
+  <https://archive.spacemit.com/image/k1/version/bianbu/v2.3.3/Bianbu-Minimal-K1-V2.3.3-20260128183217.zip>
+- A custom ``FSBL.bin`` and ``u-boot.itb`` file to be written to the U-Boot
+  partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Obtain the release images**
+
+Unpack the release package to get the image files. Replace the ``FSBL.bin``
+and ``u-boot.itb`` with your custom builds.
+
+**2. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**3. Write the image to the SD card**
+
+Run ``sgdisk`` to generate the partition table, then use ``dd`` to write
+the images to the corresponding partitions.
+
+.. code-block:: console
+
+    $sudo sgdisk -o /dev/sdb
+    $sudo sgdisk -a 128 \
+        -n 1:256:767 -t 1:8300 \
+        -n 2:768:895 -t 2:8300 \
+        -n 3:2048:4095 -t 3:8300 \

doc/board/spacemit/k1-mmc.rst line 238

Quoted 10 lines
doc/board/spacemit/k1-mmc.rst new file +10 -0
+        -n 4:4096:8191 -t 4:8300 \
+        -n 5:8192:532479 -t 5:8300 \
+        -n 6:532480:4726783 -t 6:8300 \
+        /dev/sdb
+    $sudo dd if=FSBL.bin of=/dev/sdb1 bs=512 seek=0 status=progress
+    $sudo dd if=env.bin of=/dev/sdb2 bs=512 seek=0 status=progress
+    $sudo dd if=fw_dynamic.itb of=/dev/sdb3 bs=512 seek=0 status=progress
+    $sudo dd if=u-boot.itb of=/dev/sdb4 bs=512 seek=0 status=progress
+    $sudo dd if=bootfs.img of=/dev/sdb5 bs=1M status=progress
+    $sudo dd if=rootfs.ext4 of=/dev/sdb6 bs=1M status=progress

The bootfs/rootfs part aren't U-Boot-related stuff, so please omit them from this documentation to keep it simplified.

Quoted 7 lines

Then the only binary we need to extract from the "SpacemiT release package" is env.bin and fw_dynamic.bin.

For env.bin, I think this U-Boot port depends on no specific environment setttings? If no, please omit it, too; otherwise please provide a .env file in upstream U-Boot tree, and make it the default environment to use.

OK. I can drop these binaries.

Quoted 6 lines

For fw_dynamic.bin, I think SpacemiT K1 support has been landed in the upstream OpenSBI tree? Please check if it works with upstream U-Boot. If no, please try fixing it, and then it's okay to stick to the downstream OpenSBI, but you need providing a guidance to build it from source if possible.

The patch set is for MMC/SD. OpenSBI is another topic that does not belong to u-boot either. They should not be mixed together.

I prefer to address one topic per patch set.

Quoted 36 lines

Then you could fully omit the step of downloading the "SpacemiT release package".

Quoted 22 lines
doc/board/spacemit/k1-mmc.rst new file +22 -0
+The SD card is now ready as a bootable system disk.
+
+Understanding the SD Card Partition Layout
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The role of each partition:
+
++----------+----------+------------------------------------+
+| Partition| Size     | Purpose                            |
++==========+==========+====================================+
+| ``sdb1`` | 256 KB   | FSBL (First Stage Bootloader)      |
++----------+----------+------------------------------------+
+| ``sdb2`` | 64 KB    | ENV                                |
++----------+----------+------------------------------------+
+| ``sdb3`` | 1 MB     | OpenSBI                            |
++----------+----------+------------------------------------+
+| ``sdb4`` | 2 MB     | U-Boot binary (``u-boot.itb``)     |
++----------+----------+------------------------------------+
+| ``sdb5`` | 256 MB   | Boot partition (kernel)            |
++----------+----------+------------------------------------+
+| ``sdb6`` | 2 GB     | Root filesystem (ext4)             |
++----------+----------+------------------------------------+

...

Quoted 2 lines
+- If the board boots successfully, the new device tree or U-Boot image
+  is compatible with your hardware.

This sentence looks extra, please drop it.

Best regards,
Yao Zi

#12 lore raw

Re: [PATCH v12 6/7] doc: spacemit: flash on K1 SoC based boards

Quoted 108 lines · Eric Chung
Quoted 96 lines · Yao Zi
Quoted 14 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v9:
- Add to generate the partition table of SD card. v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 271 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 273 insertions(+), 1 deletion(-)

...

Quoted 5 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 000000000000..0be5d5fa1c39

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 4GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``sgdisk``, ``lsblk`` commands)
+- The Bianbu release package from
+  <https://archive.spacemit.com/image/k1/version/bianbu/v2.3.3/Bianbu-Minimal-K1-V2.3.3-20260128183217.zip>
+- A custom ``FSBL.bin`` and ``u-boot.itb`` file to be written to the U-Boot
+  partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Obtain the release images**
+
+Unpack the release package to get the image files. Replace the ``FSBL.bin``
+and ``u-boot.itb`` with your custom builds.
+
+**2. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**3. Write the image to the SD card**
+
+Run ``sgdisk`` to generate the partition table, then use ``dd`` to write
+the images to the corresponding partitions.
+
+.. code-block:: console
+
+    $sudo sgdisk -o /dev/sdb
+    $sudo sgdisk -a 128 \
+        -n 1:256:767 -t 1:8300 \
+        -n 2:768:895 -t 2:8300 \
+        -n 3:2048:4095 -t 3:8300 \

doc/board/spacemit/k1-mmc.rst line 238

Quoted 10 lines
doc/board/spacemit/k1-mmc.rst new file +10 -0
+        -n 4:4096:8191 -t 4:8300 \
+        -n 5:8192:532479 -t 5:8300 \
+        -n 6:532480:4726783 -t 6:8300 \
+        /dev/sdb
+    $sudo dd if=FSBL.bin of=/dev/sdb1 bs=512 seek=0 status=progress
+    $sudo dd if=env.bin of=/dev/sdb2 bs=512 seek=0 status=progress
+    $sudo dd if=fw_dynamic.itb of=/dev/sdb3 bs=512 seek=0 status=progress
+    $sudo dd if=u-boot.itb of=/dev/sdb4 bs=512 seek=0 status=progress
+    $sudo dd if=bootfs.img of=/dev/sdb5 bs=1M status=progress
+    $sudo dd if=rootfs.ext4 of=/dev/sdb6 bs=1M status=progress

The bootfs/rootfs part aren't U-Boot-related stuff, so please omit them from this documentation to keep it simplified.

Quoted 7 lines

Then the only binary we need to extract from the "SpacemiT release package" is env.bin and fw_dynamic.bin.

For env.bin, I think this U-Boot port depends on no specific environment setttings? If no, please omit it, too; otherwise please provide a .env file in upstream U-Boot tree, and make it the default environment to use.

OK. I can drop these binaries.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

For fw_dynamic.bin, I think SpacemiT K1 support has been landed in the upstream OpenSBI tree? Please check if it works with upstream U-Boot. If no, please try fixing it, and then it's okay to stick to the downstream OpenSBI, but you need providing a guidance to build it from source if possible.

The patch set is for MMC/SD. OpenSBI is another topic that does not belong to u-boot either. They should not be mixed together.

At least "which OpenSBI variants are compatible with this port" should belong to this documentation, because your port requires a functional OpenSBI image to boot.

If you really do not want to include the build steps here, though it could be very brief to only one or two paragraphs, please check upstream OpenSBI, and if it works, describe the minimum required OpenSBI version, and the platform to build; if not, please mention which downstream OpenSBI should be used instead, how to build it, and if you could figure it out, why.

Quoted 4 lines

I prefer to address one topic per patch set.

Quoted 3 lines

Then you could fully omit the step of downloading the "SpacemiT release package".

Regards,
Yao Zi

maintainer
#13 lore raw

Re: [PATCH v12 6/7] doc: spacemit: flash on K1 SoC based boards

In reply to Eric Chung

hi Eric,

Quoted 76 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v9:
- Add to generate the partition table of SD card. v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 271 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 273 insertions(+), 1 deletion(-)
board/spacemit/k1/MAINTAINERS +1 -1
index 4b2bc4ecfc10..e12288a206e0 100644
@@ -6,7 +6,7 @@ S:	Maintained
 F:	arch/riscv/dts/k1-*-u-boot.dtsi
 F:	board/spacemit/k1/
 F:	configs/spacemit_k1_defconfig
-F:	doc/board/spacemit/bananapi-f3.rst
+F:	doc/board/spacemit/
 F:	drivers/gpio/spacemit_gpio.c
 F:	drivers/i2c/k1_i2c.c
 F:	drivers/mmc/spacemit_sdhci.c
doc/board/spacemit/index.rst +1 -0
index a5e35ee12ab6..71854e5735bd 100644
@@ -6,5 +6,6 @@ SpacemiT
    :maxdepth: 1
 
    bananapi-f3
+   k1-mmc
    k1-spl
 
doc/board/spacemit/k1-mmc.rst new file +31 -0
new file mode 100644
index 000000000000..0be5d5fa1c39
@@ -0,0 +1,271 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+SpacemiT K1 eMMC and SD Card Boot Guide
+=======================================
+
+This guide covers two separate methods for booting and flashing U-Boot on
+SpacemiT K1 based boards:
+
+1. **eMMC Flash**: Flashing U-Boot and SPL images to eMMC via USB fastboot.
+2. **SD Card Boot**: Creating a bootable Bianbu SD card and optionally
+   replacing U-Boot on the card.
+
+Tested boards: Banana Pi BPI-F3, MusePi Pro.
+
+
+Chapter 1: eMMC Flash (U-Boot via USB Fastboot)
+===============================================
+
+SpacemiT K1 U-Boot Flash Guide
+==============================
+
+This guide explains how to flash U-Boot on SpacemiT K1 based boards. It covers
+flashing images via USB fastboot.
+
+.. note::
+
+   This procedure flashes images to eMMC over USB fastboot. The fastboot
+   function is not enabled in our SPL yet, so the download stage runs the
+   SpacemiT released SPL; our built FSBL.bin and fit.itb are the images
+   written to eMMC and used on the next normal boot.
+

..

Quoted 2 lines

+Prerequisites
+~~~~~~~~~~~~~

.. first label here

Quoted 9 lines
doc/board/spacemit/k1-mmc.rst new file +9 -0
+
+- A SpacemiT K1 board with USB Type-C and UART access
+- USB-to-UART adapter (3.3V TTL)
+- ``minicom`` or equivalent serial terminal, configured at 115200 8N1
+- ``fastboot`` and ``flashserver`` tool on the host
+
+Hardware Setup
+~~~~~~~~~~~~~~
+

...

doc/board/spacemit/k1-mmc.rst line 186

Quoted 13 lines
doc/board/spacemit/k1-mmc.rst new file +13 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~

second one, so this trigger a CI warning, snip from the log..

looking for now-outdated files... /builds/u-boot/custodians/u-boot-spacemit/doc/board/spacemit/k1-mmc.rst:186: WARNING: duplicate label board/spacemit/k1-mmc:prerequisites,

so how about adding an additional name of this specific procedure?

for first:   Prerequisites to flash
for second:  Prerequisites to boot
Signature · 1 line
Yixun Lan (dlan)
author
#14 lore raw

PATCH v12 7/7 spacemit: k1: fix product name detection and DTB matching in SPL

In reply to Eric Chung

Use a table to handle DTB matching.

---
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(-)
board/spacemit/k1/spl.c +32 -18
index 374922573c98..ef23db62d6cc 100644
@@ -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;
 }
Signature · 1 line
2.51.0