Skip to contentSkip to conversation

riscv: dts: spacemit: Improve K1 SPL support

PATCH In review Anand Moon 4 participants 15 messages Oct 29 – Nov 20

Subsystems (5)
lore
Share & tools
lore

Anand Moon

author
#0 lore raw

cover riscv: dts: spacemit: Improve K1 SPL support

This series improves U-Boot support for SpacemiT K1-based boards by consolidating common device tree configuration and enabling GPIO and pinctrl support during SPL initialization.

It also improves the SpacemiT SDHCI driver's voltage-switching diagnostics and handling of missing pinctrl states, making SD card initialization more robust across board configurations.

This series builds on the upstream changes proposed here:
[1] https://lore.kernel.org/all/[email protected]/

The SpacemiT SPL uses the P1 PMIC to initialize the regulator framework and enable the SD card and eMMC interfaces. Since boards may use different device tree node names for vmmc-supply and vqmmc-supply, the regulator configuration must be handled appropriately for each board.

This series used above series to marks the nodes required during early initialization with bootph-pre-ram, including SoC clocks, UART, boot media, I2C buses, EEPROM, PMIC rails, and SPI NOR flash. This ensures that the required devices are available during SPL execution.

Additionally, the series moves the I2C8-related nodes required for regulator configuration into the respective board device trees. This avoids duplicated board-specific settings in the shared spacemit-k1-u-boot.dtsi and keeps the common K1 configuration minimal and easier to maintain.

Tested on the Banana Pi BPI-F3 board.

Thanks,
Anand

Anand Moon (6):
riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL
Initialization
mmc: spacemit_sdhci: Improve voltage switching diagnostics
mmc: spacemit_sdhci: Handle missing pinctrl states
gpio: spacemit: Add SPL support for K1 GPIO driver
pinctrl: spacemit: Add SPL support for K1 pinctrl driver
configs: spacemit_k1: Enable SPL GPIO and pinctrl support

 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi     | 121 ------------------
 arch/riscv/dts/spacemit-k1-binman.dtsi        |  29 +++++
 ...ro-u-boot.dtsi => spacemit-k1-u-boot.dtsi} |  80 +++++-------
 configs/spacemit_k1_defconfig                 |  20 ++-
 drivers/gpio/Kconfig                          |   7 +
 drivers/mmc/spacemit_sdhci.c                  | 118 ++++++++++++-----
 drivers/pinctrl/spacemit/Kconfig              |   8 ++
 7 files changed, 174 insertions(+), 209 deletions(-)
 delete mode 100644 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi
 create mode 100644 arch/riscv/dts/spacemit-k1-binman.dtsi
 rename arch/riscv/dts/{k1-musepi-pro-u-boot.dtsi => spacemit-k1-u-boot.dtsi} (66%)

base-commit: 03e45557e1f38a39a0c80fe30483130ff376cf92

Signature · 1 line
2.56.0
author
#1 lore raw

PATCH 1/6 riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL Initialization

Consolidate common SpacemiT K1 U-Boot device tree configuration into spacemit-k1-u-boot.dtsi, replacing the MusePi Pro and Banana Pi F3 specific overlays with a shared K1 configuration.

Separate the Binman layout and DDR firmware packaging into spacemit-k1-binman.dtsi, keeping image generation independent of board-specific bring-up.

Keep common clock, UART, I2C, GPIO, and pinctrl settings in the shared DTSI to support SPL initialization and reduce duplicated board-specific configuration.

Move the I2C8 regulator configuration to dts/upstream so regulators can be mapped by name to the corresponding nodes in the board device trees.

These changes provide a cleaner foundation for migrating peripheral configuration to the upstream device trees while minimizing duplicated settings across SpacemiT K1 boards.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi     | 121 ------------------
 arch/riscv/dts/spacemit-k1-binman.dtsi        |  29 +++++
 ...ro-u-boot.dtsi => spacemit-k1-u-boot.dtsi} |  80 +++++-------
 3 files changed, 59 insertions(+), 171 deletions(-)
 delete mode 100644 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi
 create mode 100644 arch/riscv/dts/spacemit-k1-binman.dtsi
 rename arch/riscv/dts/{k1-musepi-pro-u-boot.dtsi => spacemit-k1-u-boot.dtsi} (66%)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi deleted +0 -121
deleted file mode 100644
index 3077cdee55d..00000000000
@@ -1,121 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+ OR MIT
-/*
- * Copyright (C) 2026 RISCstar Ltd.
- */
-
-#include "binman.dtsi"
-
-/ {
-	memory@0 {
-		device_type = "memory";
-		reg = <0x00000000 0x00000000 0x00000000 0x80000000>;
-	};
-};
-
-&uart0 {
-	bootph-pre-ram;
-};
-
-&osc_32k {
-	bootph-pre-ram;
-};
-
-&vctcxo_1m {
-	bootph-pre-ram;
-};
-
-&vctcxo_3m {
-	bootph-pre-ram;
-};
-
-&vctcxo_24m {
-	bootph-pre-ram;
-};
-
-&syscon_mpmu {
-	bootph-pre-ram;
-};
-
-&pll {
-	bootph-pre-ram;
-};
-
-&syscon_apmu {
-	bootph-pre-ram;
-};
-
-&syscon_apbc {
-	bootph-pre-ram;
-};
-
-&i2c2 {
-	bootph-pre-ram;
-
-	eeprom@50 {
-		bootph-pre-ram;
-	};
-};
-
-/*
- * The kernel pmic@41 nodes use the standard regulator-* properties only;
- * U-Boot's regulator framework looks up suppliers by `regulator-name`.
- * Carry the U-Boot-specific names (vdd_core / vdd_1v8 / vdd_1v8_mmc) here
- * so SPL can program the bucks that DDR training depends on.
- */
-&i2c8 {
-	bootph-pre-ram;
-
-	pmic@41 {
-		bootph-pre-ram;
-
-		regulators {
-			buck1 {
-				regulator-name = "vdd_core";
-				bootph-pre-ram;
-			};
-
-			buck3 {
-				regulator-name = "vdd_1v8";
-				bootph-pre-ram;
-			};
-
-			aldo1 {
-				regulator-name = "vdd_1v8_mmc";
-				bootph-pre-ram;
-			};
-		};
-	};
-};
-
-&emmc {
-	bootph-pre-ram;
-	max-frequency = <204800000>;
-};
-
-&sdhci0 {
-	bootph-pre-ram;
-	max-frequency = <204800000>;
-};
-
-&binman {
-	u-boot-spl-ddr {
-		type = "section";
-		filename = "u-boot-spl-ddr.bin";
-		pad-byte = <0xff>;
-
-		u-boot-spl {
-		};
-
-		ddr-fw {
-			type = "blob";
-			filename = "ddr_fw.bin";
-			align = <64>;
-		};
-
-		u-boot-any {
-			type = "section";
-			size = <0>;
-			offset = <0>;
-		};
-	};
-};
arch/riscv/dts/spacemit-k1-binman.dtsi new file +29 -0
new file mode 100644
index 00000000000..2ff6bd2cc43
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+/*
+ * Copyright (C) 2026 RISCstar Ltd.
+ */
+
+#include "binman.dtsi"
+
+&binman {
+	u-boot-spl-ddr {
+		type = "section";
+		filename = "u-boot-spl-ddr.bin";
+		pad-byte = <0xff>;
+
+		u-boot-spl {
+		};
+
+		ddr-fw {
+			type = "blob";
+			filename = "ddr_fw.bin";
+			align = <64>;
+		};
+
+		u-boot-any {
+			type = "section";
+			size = <0>;
+			offset = <0>;
+		};
+	};
+};
arch/riscv/dts/spacemit-k1-u-boot.dtsi renamed from arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +30 -50

119 lines not on this page · raw message

Signature · 1 line
2.56.0
#2 lore raw

Re: [PATCH v1 1/6] riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL Initialization

Hi Anand,

Thanks for sending this. I tested the series on a Milk-V Jupiter, booting from SD. It reaches the U-Boot prompt, but the SPL no longer finds the PMIC:

Get board name:k1-x_milkv-jupiter
No PMIC (-19), leaving rails as found
DDR firmware: [0xc0820740]:0xf0227179, size:0x8d98

With a Jupiter -u-boot.dtsi that has the same i2c8/pmic block this patch removes, the SPL sets the rails before DDR init:

vdd_core, value:900000
vdd_1v8, value:1800000
vdd_1v8_mmc, value:3300000

The commit message says the regulator configuration moves to dts/upstream, but k1-milkv-jupiter.dts there has no bootph tags and no vdd_core/vdd_1v8/vdd_1v8_mmc names, so the PMIC is not in the SPL device tree and pmic_init() skips it. It works on this board only because the BootROM leaves usable voltages. How do you plan to let the SPL find the rails?

Two other things I saw, neither caused by this series: the SPI NOR on the Jupiter is a GigaDevice part (JEDEC c8 40 17), which needs "configs: k1: enable GigaDevice SPI NOR flash support" [1], and U-Boot reports 8 GiB on this 4 GiB board, a known issue in ddr_get_density().

[1] https://lore.kernel.org/u-boot/[email protected]/

Thanks,
Hung-Chun

#3 lore raw

Re: [PATCH v1 1/6] riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL Initialization

In reply to Anand Moon

Hi Anand,

Thanks for sending this. I tested the series on a Milk-V Jupiter, booting from SD. It reaches the U-Boot prompt, but the SPL no longer finds the PMIC:

Get board name:k1-x_milkv-jupiter
No PMIC (-19), leaving rails as found
DDR firmware: [0xc0820740]:0xf0227179, size:0x8d98

With a Jupiter -u-boot.dtsi that has the same i2c8/pmic block this patch removes, the SPL sets the rails before DDR init:

vdd_core, value:900000
vdd_1v8, value:1800000
vdd_1v8_mmc, value:3300000

The commit message says the regulator configuration moves to dts/upstream, but k1-milkv-jupiter.dts there has no bootph tags and no vdd_core/vdd_1v8/vdd_1v8_mmc names, so the PMIC is not in the SPL device tree and pmic_init() skips it. It works on this board only because the rails come up at usable voltages. How do you plan to let the SPL find the rails?

The new file is also not picked up until 6/6. U-Boot includes <dtb>-u-boot.dtsi, $(SYS_SOC)-u-boot.dtsi, $(SYS_CPU)-u-boot.dtsi, $(SYS_VENDOR)-u-boot.dtsi and u-boot.dtsi (scripts/Makefile.lib), which on K1 means k1-u-boot.dtsi or spacemit-u-boot.dtsi. Nothing includes spacemit-k1-u-boot.dtsi until 6/6 sets CONFIG_DEVICE_TREE_INCLUDES, so 1/6 to 5/6 build without any K1 overlay, which breaks bisection. I have not built each step. Naming the file k1-u-boot.dtsi would get it included from this patch on, and 6/6 would not need DEVICE_TREE_INCLUDES.

The MusePi Pro overlay also set sdhci0's cd-gpios to GPIO 80 active low, while k1-musepi-pro.dts in dts/upstream has it active high, so removing the override flips card detect on that board. Was the override fixing the upstream polarity?

Two other things I saw, neither caused by this series: the SPI NOR on the Jupiter is a GigaDevice part (JEDEC c8 40 17), which needs "configs: k1: enable GigaDevice SPI NOR flash support" [1], and U-Boot reports 8 GiB on this 4 GiB board, a known issue in ddr_get_density().

[1] https://lore.kernel.org/u-boot/[email protected]/

Thanks,
Hung-Chun

author
#4 lore raw

Re: [PATCH v1 1/6] riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL Initialization

Hi Hung-Chun,

Thanks for testing this series

Quoted 25 lines · Hung-Chun Tseng

Hi Anand,

Thanks for sending this. I tested the series on a Milk-V Jupiter, booting from SD. It reaches the U-Boot prompt, but the SPL no longer finds the PMIC:

Get board name:k1-x_milkv-jupiter
No PMIC (-19), leaving rails as found
DDR firmware: [0xc0820740]:0xf0227179, size:0x8d98

With a Jupiter -u-boot.dtsi that has the same i2c8/pmic block this patch removes, the SPL sets the rails before DDR init:

vdd_core, value:900000
vdd_1v8, value:1800000
vdd_1v8_mmc, value:3300000

The commit message says the regulator configuration moves to dts/upstream, but k1-milkv-jupiter.dts there has no bootph tags and no vdd_core/vdd_1v8/vdd_1v8_mmc names, so the PMIC is not in the SPL device tree and pmic_init() skips it. It works on this board only because the rails come up at usable voltages. How do you plan to let the SPL find the rails?

Quoted 10 lines

The new file is also not picked up until 6/6. U-Boot includes <dtb>-u-boot.dtsi, $(SYS_SOC)-u-boot.dtsi, $(SYS_CPU)-u-boot.dtsi, $(SYS_VENDOR)-u-boot.dtsi and u-boot.dtsi (scripts/Makefile.lib), which on K1 means k1-u-boot.dtsi or spacemit-u-boot.dtsi. Nothing includes spacemit-k1-u-boot.dtsi until 6/6 sets CONFIG_DEVICE_TREE_INCLUDES, so 1/6 to 5/6 build without any K1 overlay, which breaks bisection. I have not built each step. Naming the file k1-u-boot.dtsi would get it included from this patch on, and 6/6 would not need DEVICE_TREE_INCLUDES.

I think configs/spacemit_k3_defconfig uses the same approach.

CONFIG_DEVICE_TREE_INCLUDES="spacemit-k3-u-boot.dtsi"

It is consistent to use the same naming format for files.

Quoted 4 lines

The MusePi Pro overlay also set sdhci0's cd-gpios to GPIO 80 active low, while k1-musepi-pro.dts in dts/upstream has it active high, so removing the override flips card detect on that board. Was the override fixing the upstream polarity?

I haven't verified this yet, but we can retain the override if you prefer

Quoted 7 lines

Two other things I saw, neither caused by this series: the SPI NOR on the Jupiter is a GigaDevice part (JEDEC c8 40 17), which needs "configs: k1: enable GigaDevice SPI NOR flash support" [1], and U-Boot reports 8 GiB on this 4 GiB board, a known issue in ddr_get_density().

Yep, you can enable CONFIG_SPI_FLASH_GIGADEVICE in the configs/spacemit_k1_defconfig

Quoted 2 lines

[1] https://lore.kernel.org/u-boot/[email protected]/

You likely need to update the regulator name in your upstream patches to match the specific naming convention of your board.

for example

               regulators {
                        buck1_0v9: buck1 {
                                regulator-name = "vdd_core";
                                bootph-pre-ram;
                                regulator-min-microvolt = <500000>;
                                regulator-max-microvolt = <1050000>;
                                regulator-ramp-delay = <5000>;
                                regulator-always-on;
                        };

                          buck4: buck4 {
                                bootph-pre-ram;
                                regulator-name = "vdd_1v8";
                                regulator-min-microvolt = <500000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-ramp-delay = <5000>;
                                regulator-always-on;
                        };

                        aldo1: aldo1 {
                                regulator-name = "vdd_1v8_mmc";
                                bootph-pre-ram;
                                regulator-min-microvolt = <500000>;
                                regulator-max-microvolt = <3400000>;
                                regulator-boot-on;
                        };

You can verify this using the command below

 # dtc -I dtb -O dts spl/u-boot-spl.dtb |
    grep -n -E \
    'regulator|pmic|reset-controller|reset-gpios|vmmc-supply|vqmmc-supply'
136:                    pmic@41 {
149:                            regulators {
152:                                            regulator-name = "vdd_core";
153:
regulator-min-microvolt = <0x7a120>;
154:
regulator-max-microvolt = <0x100590>;
155:                                            regulator-ramp-delay = <0x1388>;
156:                                            regulator-always-on;
161:                                            regulator-name = "vdd_1v8";
162:
regulator-min-microvolt = <0x7a120>;
163:
regulator-max-microvolt = <0x1b7740>;
164:                                            regulator-ramp-delay = <0x1388>;
165:                                            regulator-always-on;
170:                                            regulator-name = "vdd_1v8_mmc";
171:
regulator-min-microvolt = <0x7a120>;
172:
regulator-max-microvolt = <0x33e140>;
173:                                            regulator-boot-on;
298:                            vmmc-supply = <0x3d>;
299:                            vqmmc-supply = <0x3e>;

If you get this working on your boards, please consider updating it in your patch series.

Quoted 2 lines

Thanks,
Hung-Chun

Thanks
-Anand

#5 lore raw

Re: [PATCH v1 1/6] riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL Initialization

Hi Anand,

Quoted 40 lines · Anand Moon

Hi Hung-Chun,

Thanks for testing this series

Quoted 25 lines · Hung-Chun Tseng

Hi Anand,

Thanks for sending this. I tested the series on a Milk-V Jupiter, booting from SD. It reaches the U-Boot prompt, but the SPL no longer finds the PMIC:

Get board name:k1-x_milkv-jupiter
No PMIC (-19), leaving rails as found
DDR firmware: [0xc0820740]:0xf0227179, size:0x8d98

With a Jupiter -u-boot.dtsi that has the same i2c8/pmic block this patch removes, the SPL sets the rails before DDR init:

vdd_core, value:900000
vdd_1v8, value:1800000
vdd_1v8_mmc, value:3300000

The commit message says the regulator configuration moves to dts/upstream, but k1-milkv-jupiter.dts there has no bootph tags and no vdd_core/vdd_1v8/vdd_1v8_mmc names, so the PMIC is not in the SPL device tree and pmic_init() skips it. It works on this board only because the rails come up at usable voltages. How do you plan to let the SPL find the rails?

Quoted 10 lines

The new file is also not picked up until 6/6. U-Boot includes <dtb>-u-boot.dtsi, $(SYS_SOC)-u-boot.dtsi, $(SYS_CPU)-u-boot.dtsi, $(SYS_VENDOR)-u-boot.dtsi and u-boot.dtsi (scripts/Makefile.lib), which on K1 means k1-u-boot.dtsi or spacemit-u-boot.dtsi. Nothing includes spacemit-k1-u-boot.dtsi until 6/6 sets CONFIG_DEVICE_TREE_INCLUDES, so 1/6 to 5/6 build without any K1 overlay, which breaks bisection. I have not built each step. Naming the file k1-u-boot.dtsi would get it included from this patch on, and 6/6 would not need DEVICE_TREE_INCLUDES.

Quoted 4 lines

I think configs/spacemit_k3_defconfig uses the same approach.

CONFIG_DEVICE_TREE_INCLUDES="spacemit-k3-u-boot.dtsi"

Please split up the dts reorganization changes into three-or-four patches [A], ([B]), [C], and [D]; The initial transition to this as [A] should be not adding or fixing any nodes:

A1. New file 'spacemit-k1-binman.dtsi' with '#include "binman.dtsi"' at the top just after the copyright identifier

A2. '&binman' sections from per-board k1-*-u-boot.dtsi overrides should merge and be moved appended to spacemit-k1-binman.dtsi

A3. New file 'spacemit-k1-u-boot.dtsi' specified by CONFIG_DEVICE_TREE_INCLUDES, with '#include "spacemit-k1-binman.dtsi"' as the very last line of the file.

A4. Merge and move from per-board k1-*-u-boot.dtsi files any properties in devicetree root that are rejected by upstream for devicetree-rebasing subtree. The content should be inserted after the copyright identifier and before the last line of the file '#include "spacemit-k1-binman.dtsi"'. An example of this is the memory controller reg override in which we specify a sensible fixed-amount value so that the bootloader bring-up can function, but this configuration would never be accepted upstream. If not for [B] this should only be the memory controller reg override, apparently.

B. Resolve the presence of /aliases and /chosen nodes in k1-musepi-pro-u-boot.dtsi compared to the lack of such nodes in k1-bananapi-f3-u-boot.dtsi and then upstream and/or merge and move any resolution to spacemit-k1-u-boot.dtsi ; I do not understand the implications so maybe you would find that this can be ignored unchanged and then removed in [D]

C(n). Import to per-board -u-boot.dtsi and spacemit-k1-u-boot.dtsi all the proposed upstream changes (i.e. bootph-pre-ram hints). These should be grouped by upstream patch discussion thread or commit id so that from view of u-boot git tree one upstream discussion thread (patch or commit id) is referenced in a comment within the dtsi file(s) that import it.

D. Delete redundant nodes and properties from per-board dtsi places where they are redundant. This deletion is not combined with [C] because we should be able to later do a git revert of [C(n)] when a corresponding commit lands upstream.

There is going to be a considerable amount of per-board overrides that are identical over a subset of per-board override -u-boot.dtsi and so duplication is preferable as it is (from U-Boot git log) logically grouped by commits that reference a particular upstream discussion or commit id. That is also to say further organizing some changesets in additional dtsi files to be included from a subset of per-board dtsi is considered, but I am not yet convinced it would be helpful rather than just duplicating it among the per-board dtsi files now and having a sensible git history for reverting later when appropriate.

Quoted 79 lines

It is consistent to use the same naming format for files.

Quoted 4 lines

The MusePi Pro overlay also set sdhci0's cd-gpios to GPIO 80 active low, while k1-musepi-pro.dts in dts/upstream has it active high, so removing the override flips card detect on that board. Was the override fixing the upstream polarity?

I haven't verified this yet, but we can retain the override if you prefer

Quoted 7 lines

Two other things I saw, neither caused by this series: the SPI NOR on the Jupiter is a GigaDevice part (JEDEC c8 40 17), which needs "configs: k1: enable GigaDevice SPI NOR flash support" [1], and U-Boot reports 8 GiB on this 4 GiB board, a known issue in ddr_get_density().

Yep, you can enable CONFIG_SPI_FLASH_GIGADEVICE in the configs/spacemit_k1_defconfig

Quoted 2 lines

[1] https://lore.kernel.org/u-boot/[email protected]/

You likely need to update the regulator name in your upstream patches to match the specific naming convention of your board.

for example

               regulators {
                        buck1_0v9: buck1 {
                                regulator-name = "vdd_core";
                                bootph-pre-ram;
                                regulator-min-microvolt = <500000>;
                                regulator-max-microvolt = <1050000>;
                                regulator-ramp-delay = <5000>;
                                regulator-always-on;
                        };

                          buck4: buck4 {
                                bootph-pre-ram;
                                regulator-name = "vdd_1v8";
                                regulator-min-microvolt = <500000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-ramp-delay = <5000>;
                                regulator-always-on;
                        };

                        aldo1: aldo1 {
                                regulator-name = "vdd_1v8_mmc";
                                bootph-pre-ram;
                                regulator-min-microvolt = <500000>;
                                regulator-max-microvolt = <3400000>;
                                regulator-boot-on;
                        };

You can verify this using the command below

 # dtc -I dtb -O dts spl/u-boot-spl.dtb |
    grep -n -E \
    'regulator|pmic|reset-controller|reset-gpios|vmmc-supply|vqmmc-supply'
136:                    pmic@41 {
149:                            regulators {
152:                                            regulator-name = "vdd_core";
153:
regulator-min-microvolt = <0x7a120>;
154:
regulator-max-microvolt = <0x100590>;
155:                                            regulator-ramp-delay = <0x1388>;
156:                                            regulator-always-on;
161:                                            regulator-name = "vdd_1v8";
162:
regulator-min-microvolt = <0x7a120>;
163:
regulator-max-microvolt = <0x1b7740>;
164:                                            regulator-ramp-delay = <0x1388>;
165:                                            regulator-always-on;
170:                                            regulator-name = "vdd_1v8_mmc";
171:
regulator-min-microvolt = <0x7a120>;
172:
regulator-max-microvolt = <0x33e140>;
173:                                            regulator-boot-on;
298:                            vmmc-supply = <0x3d>;
299:                            vqmmc-supply = <0x3e>;
Quoted 8 lines

If you get this working on your boards, please consider updating it in your patch series.

Quoted 2 lines

Thanks,
Hung-Chun

Thanks
-Anand

-E

author
#6 lore raw

Re: [PATCH v1 1/6] riscv: dts: spacemit: Clean Up K1 U-Boot Device Tree for SPL Initialization

H E Shattow,

Quoted 91 lines · E Shattow

Hi Anand,

Quoted 40 lines · Anand Moon

Hi Hung-Chun,

Thanks for testing this series

Quoted 25 lines · Hung-Chun Tseng

Hi Anand,

Thanks for sending this. I tested the series on a Milk-V Jupiter, booting from SD. It reaches the U-Boot prompt, but the SPL no longer finds the PMIC:

Get board name:k1-x_milkv-jupiter
No PMIC (-19), leaving rails as found
DDR firmware: [0xc0820740]:0xf0227179, size:0x8d98

With a Jupiter -u-boot.dtsi that has the same i2c8/pmic block this patch removes, the SPL sets the rails before DDR init:

vdd_core, value:900000
vdd_1v8, value:1800000
vdd_1v8_mmc, value:3300000

The commit message says the regulator configuration moves to dts/upstream, but k1-milkv-jupiter.dts there has no bootph tags and no vdd_core/vdd_1v8/vdd_1v8_mmc names, so the PMIC is not in the SPL device tree and pmic_init() skips it. It works on this board only because the rails come up at usable voltages. How do you plan to let the SPL find the rails?

Quoted 10 lines

The new file is also not picked up until 6/6. U-Boot includes <dtb>-u-boot.dtsi, $(SYS_SOC)-u-boot.dtsi, $(SYS_CPU)-u-boot.dtsi, $(SYS_VENDOR)-u-boot.dtsi and u-boot.dtsi (scripts/Makefile.lib), which on K1 means k1-u-boot.dtsi or spacemit-u-boot.dtsi. Nothing includes spacemit-k1-u-boot.dtsi until 6/6 sets CONFIG_DEVICE_TREE_INCLUDES, so 1/6 to 5/6 build without any K1 overlay, which breaks bisection. I have not built each step. Naming the file k1-u-boot.dtsi would get it included from this patch on, and 6/6 would not need DEVICE_TREE_INCLUDES.

Quoted 4 lines

I think configs/spacemit_k3_defconfig uses the same approach.

CONFIG_DEVICE_TREE_INCLUDES="spacemit-k3-u-boot.dtsi"

Please split up the dts reorganization changes into three-or-four patches [A], ([B]), [C], and [D]; The initial transition to this as [A] should be not adding or fixing any nodes:

A1. New file 'spacemit-k1-binman.dtsi' with '#include "binman.dtsi"' at the top just after the copyright identifier

A2. '&binman' sections from per-board k1-*-u-boot.dtsi overrides should merge and be moved appended to spacemit-k1-binman.dtsi

A3. New file 'spacemit-k1-u-boot.dtsi' specified by CONFIG_DEVICE_TREE_INCLUDES, with '#include "spacemit-k1-binman.dtsi"' as the very last line of the file.

A4. Merge and move from per-board k1-*-u-boot.dtsi files any properties in devicetree root that are rejected by upstream for devicetree-rebasing subtree. The content should be inserted after the copyright identifier and before the last line of the file '#include "spacemit-k1-binman.dtsi"'. An example of this is the memory controller reg override in which we specify a sensible fixed-amount value so that the bootloader bring-up can function, but this configuration would never be accepted upstream. If not for [B] this should only be the memory controller reg override, apparently.

B. Resolve the presence of /aliases and /chosen nodes in k1-musepi-pro-u-boot.dtsi compared to the lack of such nodes in k1-bananapi-f3-u-boot.dtsi and then upstream and/or merge and move any resolution to spacemit-k1-u-boot.dtsi ; I do not understand the implications so maybe you would find that this can be ignored unchanged and then removed in [D]

C(n). Import to per-board -u-boot.dtsi and spacemit-k1-u-boot.dtsi all the proposed upstream changes (i.e. bootph-pre-ram hints). These should be grouped by upstream patch discussion thread or commit id so that from view of u-boot git tree one upstream discussion thread (patch or commit id) is referenced in a comment within the dtsi file(s) that import it.

D. Delete redundant nodes and properties from per-board dtsi places where they are redundant. This deletion is not combined with [C] because we should be able to later do a git revert of [C(n)] when a corresponding commit lands upstream.

Quoted 10 lines

There is going to be a considerable amount of per-board overrides that are identical over a subset of per-board override -u-boot.dtsi and so duplication is preferable as it is (from U-Boot git log) logically grouped by commits that reference a particular upstream discussion or commit id. That is also to say further organizing some changesets in additional dtsi files to be included from a subset of per-board dtsi is considered, but I am not yet convinced it would be helpful rather than just duplicating it among the per-board dtsi files now and having a sensible git history for reverting later when appropriate.

Thanks for your review comments.

Yes, I will follow this procedure in future patch series. For this series, I wanted to have the changes tested on another development board
so that I could better understand and follow the proposed process for restructuring
the code changes.

Thanks for the guidance.

Thanks
-Anand

author
#7 lore raw

PATCH 2/6 mmc: spacemit_sdhci: Improve voltage switching diagnostics

In reply to Anand Moon

Improve error reporting when setting or enabling the VQMMC regulator fails.

Refactor voltage handling to determine the target signal voltage before updating the regulator, and report failures when the SDHCI voltage-switch bit does not reflect the requested state.

Keep the SDHCI host-control voltage-bit handling specific to SD devices, while allowing the VQMMC regulator to be configured for other MMC device types.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 drivers/mmc/spacemit_sdhci.c | 85 ++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 32 deletions(-)
drivers/mmc/spacemit_sdhci.c +53 -32
index f5578f38bdd..836201ce83c 100644
@@ -222,15 +222,26 @@ static int spacemit_sdhci_set_vqmmc_voltage(struct mmc *mmc, int voltage)
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	int ret;
 
-	if (!mmc->vqmmc_supply)
+	/*
+	 * eMMC VCCQ is fixed at 1.8V on the BPI-F3.
+	 * Do not attempt to switch its VQMMC regulator.
+	 */
+	if (!IS_SD(mmc) || !mmc->vqmmc_supply)
 		return 0;
 
 	ret = regulator_set_value(mmc->vqmmc_supply, voltage);
-	if (ret)
+	if (ret) {
+		log_err("%s: failed to set VQMMC to %d uV: %d\n",
+			mmc->dev->name, voltage, ret);
 		return ret;
+	}
+
 	ret = regulator_set_enable_if_allowed(mmc->vqmmc_supply, true);
-	if (ret)
+	if (ret) {
+		log_err("%s: failed to enable VQMMC: %d\n",
+			mmc->dev->name, ret);
 		return ret;
+	}
 #endif
 	return 0;
 }
@@ -239,44 +250,54 @@ static void spacemit_sdhci_set_voltage(struct sdhci_host *host)
 {
 	if (IS_ENABLED(CONFIG_MMC_IO_VOLTAGE)) {
 		struct mmc *mmc = host->mmc;
+		bool to_180, ok;
+		int voltage_uv, ret;
 		u32 ctrl;
 
-		ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
-
 		switch (mmc->signal_voltage) {
 		case MMC_SIGNAL_VOLTAGE_330:
-		case MMC_SIGNAL_VOLTAGE_180: {
-			bool to_180 = mmc->signal_voltage ==
-				      MMC_SIGNAL_VOLTAGE_180;
-			bool ok;
-			int voltage_mv = to_180 ? 1800000 : 3300000;
-
-			if (spacemit_sdhci_set_vqmmc_voltage(mmc, voltage_mv))
-				return;
-			if (!IS_SD(mmc))
-				return;
-			if (to_180)
-				ctrl |= SDHCI_CTRL_VDD_180;
-			else
-				ctrl &= ~SDHCI_CTRL_VDD_180;
-			sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
-
-			mdelay(5);
-
-			ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
-			ok = !!(ctrl & SDHCI_CTRL_VDD_180) == to_180;
-			if (ok)
-				return;
-
-			log_err("%d.%dV regulator output not stable\n",
-				voltage_mv / 1000000,
-				(voltage_mv / 100000) % 10);
+			to_180 = false;
+			voltage_uv = 3300000;
+			break;
+		case MMC_SIGNAL_VOLTAGE_180:
+			to_180 = true;
+			voltage_uv = 1800000;
 			break;
-		}
 		default:
 			/* No signal voltage switch required */
 			return;
 		}
+
+		ret = spacemit_sdhci_set_vqmmc_voltage(mmc, voltage_uv);
+		if (ret) {
+			log_err("%s: VQMMC switch to %d uV failed: %d\n",
+				mmc->dev->name, voltage_uv, ret);
+			return;
+		}
+
+		/*
+		 * Non-SD devices may not use the SD Host Control 2
+		 * voltage-switch bit. Keep their handling separate.
+		 */
+		if (!IS_SD(mmc))
+			return;
+
+		ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+
+		if (to_180)
+			ctrl |= SDHCI_CTRL_VDD_180;
+		else
+			ctrl &= ~SDHCI_CTRL_VDD_180;
+
+		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
+		mdelay(5);
+
+		ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+		ok = !!(ctrl & SDHCI_CTRL_VDD_180) == to_180;
+		if (!ok) {
+			log_err("%s: SDHCI voltage bit did not switch to %d uV\n",
+				mmc->dev->name, voltage_uv);
+		}
 	}
 }
 
Signature · 1 line
2.56.0
author
#8 lore raw

PATCH 3/6 mmc: spacemit_sdhci: Handle missing pinctrl states

In reply to Anand Moon

Check for available pinctrl states before selecting them in the SpacemiT SDHCI driver.

Skip pinctrl selection when the device does not define a default state, allowing eMMC configurations without pinctrl properties to work without spurious pinctrl errors.

Select the UHS pinctrl state only when it is defined, and log errors when pinctrl state selection fails.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 drivers/mmc/spacemit_sdhci.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/mmc/spacemit_sdhci.c +30 -3
index 836201ce83c..668555b94e1 100644
@@ -355,10 +355,27 @@ static int spacemit_sdhci_get_b_max(struct udevice *dev, void *dst,
 	return mmc->cfg->b_max;
 }
 
+static bool spacemit_sdhci_has_pinctrl_state(struct udevice *dev,
+					     const char *state_name)
+{
+	char propname[20];
+	int state;
+
+	state = dev_read_stringlist_search(dev, "pinctrl-names",
+					   state_name);
+	if (state < 0)
+		return false;
+
+	snprintf(propname, sizeof(propname), "pinctrl-%d", state);
+
+	return !!dev_read_prop(dev, propname, NULL);
+}
+
 static void spacemit_sdhci_set_control_reg(struct sdhci_host *host)
 {
 	struct mmc *mmc = host->mmc;
 	u32 reg;
+	int ret;
 
 	spacemit_sdhci_set_voltage(host);
 
@@ -383,16 +400,26 @@ static void spacemit_sdhci_set_control_reg(struct sdhci_host *host)
 	sdhci_writel(host, reg, SPACEMIT_SDHC_TX_CFG_REG);
 
 	/* Set pinctrl state based on selected timing mode */
-	if (IS_ENABLED(CONFIG_PINCTRL)) {
+	if (IS_ENABLED(CONFIG_PINCTRL) &&
+	    spacemit_sdhci_has_pinctrl_state(mmc->dev, "default")) {
 		switch (mmc->selected_mode) {
 		case UHS_SDR12:
 		case UHS_SDR25:
 		case UHS_SDR50:
 		case UHS_SDR104:
-			pinctrl_select_state(mmc->dev, "uhs");
+			if (spacemit_sdhci_has_pinctrl_state(mmc->dev, "uhs")) {
+				ret = pinctrl_select_state(mmc->dev, "uhs");
+				if (ret)
+					log_err("SDHCI %s: uhs pinctrl selection failed: %d\n",
+						mmc->dev->name, ret);
+			}
 			break;
+
 		default:
-			pinctrl_select_state(mmc->dev, "default");
+			ret = pinctrl_select_state(mmc->dev, "default");
+			if (ret)
+				log_err("SDHCI %s: default pinctrl selection failed: %d\n",
+					mmc->dev->name, ret);
 			break;
 		}
 	}
Signature · 1 line
2.56.0
author
#9 lore raw

PATCH 4/6 gpio: spacemit: Add SPL support for K1 GPIO driver

In reply to Anand Moon

Add SPL_SPACEMIT_GPIO to enable the SpacemiT K1 GPIO driver during SPL initialization.

Depend on SPL_DM_GPIO and TARGET_SPACEMIT_K1, and select SPACEMIT_GPIO to reuse the existing driver implementation.

This allows SPL to access GPIOs required for early board initialization.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 drivers/gpio/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpio/Kconfig +7 -0
index 7f12e39dad8..3be6a9e54fa 100644
@@ -457,6 +457,13 @@ config SPACEMIT_GPIO
 	  arranged into a number of banks (different for each SoC type) each
 	  with 32 GPIOs.
 
+config SPL_SPACEMIT_GPIO
+	bool "Spacemit K1 GPIO driver in SPL"
+	 depends on SPL_DM_GPIO && TARGET_SPACEMIT_K1
+	 select SPACEMIT_GPIO
+	 help
+	   Enable the Spacemit K1 GPIO driver in SPL.
+	   This allows SPL to configure GPIOs during early board initialization.
 
 config SUNXI_GPIO
 	bool "Allwinner GPIO driver"
Signature · 1 line
2.56.0
maintainer
#10 lore raw

Re: [PATCH v1 4/6] gpio: spacemit: Add SPL support for K1 GPIO driver

Hi Anand,

Can you split out patch 4, 5 and send a v2? I'd like to
take them first..

Quoted 3 lines · Anand Moon

Add SPL_SPACEMIT_GPIO to enable the SpacemiT K1 GPIO driver during SPL initialization.

..

Quoted 3 lines

Depend on SPL_DM_GPIO and TARGET_SPACEMIT_K1, and select SPACEMIT_GPIO to reuse the existing driver implementation.

I'd rather drop above explanation, it's quite obvious from reading the code..

Quoted 1 line

This allows SPL to access GPIOs required for early board

s/This allows/Allow/, use imperative mood

Quoted 2 lines

initialization.

Any specific user of the GPIO? Can you add more detail, I can
think of reason that SdCard's Dectect pin will use gpio..

Quoted 5 lines
Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>

Can you put CC list in cover letter? I'd rather not apply them.. or possibly under line "---" if you want specific CC in single patch? and of course it works..

Quoted 10 lines
---
 drivers/gpio/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpio/Kconfig +0 -0
index 7f12e39dad8..3be6a9e54fa 100644

drivers/gpio/Kconfig config SPACEMIT_GPIO · line 461

Quoted 5 lines
drivers/gpio/Kconfig +2 -0
@@ -457,6 +457,13 @@ config SPACEMIT_GPIO
 	  arranged into a number of banks (different for each SoC type) each
 	  with 32 GPIOs.
 
+config SPL_SPACEMIT_GPIO
+	bool "Spacemit K1 GPIO driver in SPL"

just "SpacemiT GPIO driver in SPL", which also make it work for K3,
so let's not only mention for K1..

drivers/gpio/Kconfig config SPACEMIT_GPIO · line 462

Quoted 1 line
drivers/gpio/Kconfig +1 -0
+	 depends on SPL_DM_GPIO && TARGET_SPACEMIT_K1

I'd also like to see it enabled in K3 platform, so how about

	 depends on SPL_DM_GPIO && (TARGET_SPACEMIT_K1 || TARGET_SPACEMIT_K3)

or simply remove platform contraint..
depends on SPL_DM_GPIO

Quoted 10 lines
drivers/gpio/Kconfig +4 -0
+	 select SPACEMIT_GPIO
+	 help
+	   Enable the Spacemit K1 GPIO driver in SPL.
+	   This allows SPL to configure GPIOs during early board initialization.
 
 config SUNXI_GPIO
 	bool "Allwinner GPIO driver"
Signature · 1 line
2.56.0
Signature · 1 line
Yixun Lan (dlan)
author
#11 lore raw

PATCH 5/6 pinctrl: spacemit: Add SPL support for K1 pinctrl driver

In reply to Anand Moon

Add SPL_PINCTRL_SPACEMIT_K1 to enable the SpacemiT K1 pinctrl driver during SPL initialization.

Depend on SPL_PINCTRL, SPL_DM, and PINCTRL_GENERIC, and select PINCTRL_SPACEMIT_K1 to reuse the existing driver implementation.

This allows SPL to configure pin multiplexing for early board initialization.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 drivers/pinctrl/spacemit/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pinctrl/spacemit/Kconfig +8 -0
index 87cba336923..5770e4865d9 100644
@@ -7,3 +7,11 @@ config PINCTRL_SPACEMIT_K1
 	  The driver is controlled by a device tree node which contains both
 	  the GPIO definitions and pin control functions for each available
 	  multiplex function.
+
+config SPL_PINCTRL_SPACEMIT_K1
+	bool "Spacemit K1 pinctrl driver in SPL"
+	depends on SPL_PINCTRL && SPL_DM && PINCTRL_GENERIC
+	select PINCTRL_SPACEMIT_K1
+	help
+	  Enable the Spacemit K1 pinctrl driver in SPL.
+	  This allows SPL to configure pinctrl during early board initialization.
Signature · 1 line
2.56.0
maintainer
#12 lore raw

Re: [PATCH v1 5/6] pinctrl: spacemit: Add SPL support for K1 pinctrl driver

Hi Anand,

For the title, how about
pinctrl: spacemit: Add SPL support for early access

Quoted 3 lines · Anand Moon

Add SPL_PINCTRL_SPACEMIT_K1 to enable the SpacemiT K1 pinctrl driver during SPL initialization.

..

Quoted 4 lines

Depend on SPL_PINCTRL, SPL_DM, and PINCTRL_GENERIC, and select PINCTRL_SPACEMIT_K1 to reuse the existing driver implementation.

Redundant, drop it

Quoted 3 lines

This allows SPL to configure pin multiplexing for early board initialization.

This is ok, but better if able to add some more detail

Quoted 15 lines
Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 drivers/pinctrl/spacemit/Kconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pinctrl/spacemit/Kconfig +0 -0
index 87cba336923..5770e4865d9 100644

drivers/pinctrl/spacemit/Kconfig config PINCTRL_SPACEMIT_K1 · line 12

Quoted 6 lines
drivers/pinctrl/spacemit/Kconfig +3 -0
@@ -7,3 +7,11 @@ config PINCTRL_SPACEMIT_K1
 	  The driver is controlled by a device tree node which contains both
 	  the GPIO definitions and pin control functions for each available
 	  multiplex function.
+
+config SPL_PINCTRL_SPACEMIT_K1
+	bool "Spacemit K1 pinctrl driver in SPL"

similar, s/Spacemit K1/SpacemiT/
K3 reuse same config with K1, so other part looks good

drivers/pinctrl/spacemit/Kconfig config PINCTRL_SPACEMIT_K1 · line 13

Quoted 1 line
drivers/pinctrl/spacemit/Kconfig +1 -0
+	depends on SPL_PINCTRL && SPL_DM && PINCTRL_GENERIC

can you check if able to combine this two? SPL_PINCTRL && PINCTRL_GENERIC as I see SPL_PINCTRL_GENERIC

Quoted 7 lines
drivers/pinctrl/spacemit/Kconfig +4 -0
+	select PINCTRL_SPACEMIT_K1
+	help
+	  Enable the Spacemit K1 pinctrl driver in SPL.
+	  This allows SPL to configure pinctrl during early board initialization.
Signature · 1 line
2.56.0
Signature · 1 line
Yixun Lan (dlan)
author
#13 lore raw

PATCH 6/6 configs: spacemit_k1: Enable SPL GPIO and pinctrl support

In reply to Anand Moon

Enable GPIO and pinctrl support in SPL for SpacemiT K1 boards to support early board initialization and SD card boot.

Enable SPL MMC I/O voltage switching and configure the shared K1 U-Boot device tree include for the supported boards.

Also enable MTD and SPI NOR partition support with the default flash partition layout.

Configure a 2 MiB SPL simple malloc buffer for early allocations. Enable regulator commands, SPL GPIO and pinctrl support, and SPL MMC I/O voltage switching.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 configs/spacemit_k1_defconfig | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
configs/spacemit_k1_defconfig +17 -3
index 8ee9baa13b7..04b5ec4f700 100644
@@ -3,10 +3,10 @@ CONFIG_SYS_MALLOC_LEN=0x1000000
 CONFIG_SYS_MALLOC_F_LEN=0x10000
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1200000
 CONFIG_DM_GPIO=y
 CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-musepi-pro"
+CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-bananapi-f3"
 CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000
 CONFIG_SPL_MMC=y
 CONFIG_SPL_STACK_R_ADDR=0xc00000
@@ -63,10 +63,12 @@ CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_EXT4=y
+CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_FAT=y
 CONFIG_EFI_PARTITION=y
 CONFIG_OF_UPSTREAM=y
-CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro"
+CONFIG_DEVICE_TREE_INCLUDES="spacemit-k1-u-boot.dtsi"
+CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro spacemit/k1-milkv-jupiter"
 CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
@@ -117,3 +119,15 @@ CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_SPL_GPIO=y
+CONFIG_SPL_DM_GPIO=y
+CONFIG_SPL_PINCTRL=y
+CONFIG_SPL_SPACEMIT_GPIO=y
+CONFIG_SPL_PINCTRL_SPACEMIT_K1=y
+CONFIG_SPL_MMC_IO_VOLTAGE=y
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x200000
+CONFIG_CMD_MTD=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
+CONFIG_MTDPARTS_DEFAULT="spi0.0:128k(bootinfo),512k(fsbl),64k(env),1024k(esos),384k(opensbi),-(uboot)"
Signature · 1 line
2.56.0
maintainer
#14 lore raw

Re: [PATCH v1 6/6] configs: spacemit_k1: Enable SPL GPIO and pinctrl support

Hi Anand,

With those two mmc patches 2,3, which should be used for switching i/o pins to 1.8v, so can you check if it able to work in UHS mode? try with CONFIG_MMC_UHS_SUPPORT enabled?

Quoted 35 lines · Anand Moon

Enable GPIO and pinctrl support in SPL for SpacemiT K1 boards to support early board initialization and SD card boot.

Enable SPL MMC I/O voltage switching and configure the shared K1 U-Boot device tree include for the supported boards.

Also enable MTD and SPI NOR partition support with the default flash partition layout.

Configure a 2 MiB SPL simple malloc buffer for early allocations. Enable regulator commands, SPL GPIO and pinctrl support, and SPL MMC I/O voltage switching.

Cc Dave Klotz <[email protected]>
Cc Eric Chung <[email protected]>
Cc Hung-Chun Tseng <[email protected]>
Cc E Shattow <[email protected]>
Cc Yixun Lan <[email protected]>
---
 configs/spacemit_k1_defconfig | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
configs/spacemit_k1_defconfig +1 -1
index 8ee9baa13b7..04b5ec4f700 100644
@@ -3,10 +3,10 @@ CONFIG_SYS_MALLOC_LEN=0x1000000
 CONFIG_SYS_MALLOC_F_LEN=0x10000
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1200000
 CONFIG_DM_GPIO=y
 CONFIG_SPL_DM_SPI=y

..

configs/spacemit_k1_defconfig CONFIG_SYS_MALLOC_LEN=0x1000000 · line 9

Quoted 2 lines
configs/spacemit_k1_defconfig +1 -1
-CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-musepi-pro"
+CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-bananapi-f3"

no need to change

Quoted 13 lines

CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000
CONFIG_SPL_MMC=y
CONFIG_SPL_STACK_R_ADDR=0xc00000

configs/spacemit_k1_defconfig +2 -1
@@ -63,10 +63,12 @@ CONFIG_CMD_PCI=y
 CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_EXT4=y
+CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_FAT=y
 CONFIG_EFI_PARTITION=y
 CONFIG_OF_UPSTREAM=y
-CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro"
+CONFIG_DEVICE_TREE_INCLUDES="spacemit-k1-u-boot.dtsi"

..

Quoted 1 line

+CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro spacemit/k1-milkv-jupiter"

ditto

Quoted 22 lines

CONFIG_MULTI_DTB_FIT=y
CONFIG_ENV_OVERWRITE=y
CONFIG_SPL_DM_SEQ_ALIAS=y

configs/spacemit_k1_defconfig +12 -0
@@ -117,3 +119,15 @@ CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
 CONFIG_USB_STORAGE=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_SPL_GPIO=y
+CONFIG_SPL_DM_GPIO=y
+CONFIG_SPL_PINCTRL=y
+CONFIG_SPL_SPACEMIT_GPIO=y
+CONFIG_SPL_PINCTRL_SPACEMIT_K1=y
+CONFIG_SPL_MMC_IO_VOLTAGE=y
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x200000
+CONFIG_CMD_MTD=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
+CONFIG_MTDPARTS_DEFAULT="spi0.0:128k(bootinfo),512k(fsbl),64k(env),1024k(esos),384k(opensbi),-(uboot)"
Signature · 1 line
2.56.0
Signature · 1 line
Yixun Lan (dlan)