riscv: spacemit: Add GPIO and pinctrl support in SPL
Subsystems (6)
v3 cover riscv: spacemit: Add GPIO and pinctrl support in SPL
This series improves SPL initialization and SD card support for SpacemiT K1-based boards, including the Banana Pi BPI-F3 and MusePi Pro.
Start by consolidating common U-Boot-specific device tree nodes and properties into a shared K1 DTSI and removing redundant board-specific overrides.
Add GPIO and AIB clock support in SPL, followed by SPL support for the SpacemiT GPIO and pinctrl drivers. This allows GPIO-based card detection and device tree-based pin configuration during early boot.
Improve the SpacemiT SDHCI driver by adding voltage switching diagnostics and selecting the appropriate pinctrl state based on the requested signal voltage rather than the timing mode.
Adjust the SPL stack and malloc configuration, retain the GPIO and pinctrl nodes required during early boot, and enable GPIO, pinctrl and MMC UHS support.
Finally, enable uncompressed multi-DTB FIT support in SPL and update the Binman configuration to accommodate multi-DTB SPL images. Using an uncompressed FIT avoids the additional memory allocation required for FIT decompression within the limited SPL SRAM.
The series lays the groundwork for supporting multiple K1-based boards with a single SPL binary.
Changes in v2:
v2: https://patchwork.ozlabs.org/project/uboot/list/?series=535531
- Consolidate additional common U-Boot properties into spacemit-k1-u-boot.dtsi.
- Reduce duplication in the board-specific DTSI files.
- Retain board-specific configuration where required.
v1: https://patchwork.ozlabs.org/project/uboot/list/?series=530594
Thanks
-Anand
Anand Moon (13):
riscv: dts: spacemit: k1: Move common U-Boot nodes to shared DTSI
riscv: dts: spacemit: k1-musepi-pro: Drop redundant DT overrides
riscv: dts: spacemit: k1: Move common U-Boot properties to shared DTSI
clk: spacemit: k1: Add GPIO and AIB clock support in SPL
pinctrl: spacemit: Add SPL support for K1/K3 pinctrl driver
gpio: spacemit: Add SPL support for K1/K3 GPIO driver
mmc: spacemit_sdhci: Improve voltage switching diagnostics
mmc: spacemit_sdhci: Select pinctrl state based on signal voltage
riscv: spacemit: k1: Adjust SPL stack and malloc configuration
riscv: dts: spacemit: k1: Retain GPIO and pinctrl nodes in SPL
riscv: spacemit: k1: Enable GPIO, pinctrl and MMC UHS support
riscv: spacemit: k1: Enable uncompressed multi-DTB FIT support in SPL
riscv: dts: spacemit: k1: Support multi-DTB SPL images in Binman
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 86 ------------- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 113 ----------------- arch/riscv/dts/spacemit-k1-binman.dtsi | 30 +++++ arch/riscv/dts/spacemit-k1-u-boot.dtsi | 133 ++++++++++++++++++++ configs/spacemit_k1_defconfig | 14 ++- drivers/clk/spacemit/clk-k1.c | 29 +++-- drivers/gpio/Kconfig | 7 ++ drivers/mmc/spacemit_sdhci.c | 144 +++++++++++++++------- drivers/pinctrl/spacemit/Kconfig | 8 ++ 9 files changed, 306 insertions(+), 258 deletions(-) create mode 100644 arch/riscv/dts/spacemit-k1-binman.dtsi create mode 100644 arch/riscv/dts/spacemit-k1-u-boot.dtsi
base-commit: 9d67454e920b3908529c9fc642a8c911db040896
Signature · 1 line
2.56.1
PATCH v3 1/13 riscv: dts: spacemit: k1: Move common U-Boot nodes to shared DTSI
The Banana Pi BPI-F3 and MusePi Pro U-Boot device trees contain identical Binman descriptions and memory node overrides.
Move the Binman description into spacemit-k1-binman.dtsi and the memory override into spacemit-k1-u-boot.dtsi.
Include the common U-Boot device tree through DEVICE_TREE_INCLUDES to avoid duplicating these definitions in the board-specific files.
This is a device tree reorganization with no intended functional changes.
--- arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 32 ----------------------- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 29 -------------------- arch/riscv/dts/spacemit-k1-binman.dtsi | 29 ++++++++++++++++++++ arch/riscv/dts/spacemit-k1-u-boot.dtsi | 13 +++++++++ configs/spacemit_k1_defconfig | 1 + 5 files changed, 43 insertions(+), 61 deletions(-) create mode 100644 arch/riscv/dts/spacemit-k1-binman.dtsi create mode 100644 arch/riscv/dts/spacemit-k1-u-boot.dtsi
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +0 -32
@@ -3,15 +3,6 @@ * Copyright (C) 2026 RISCstar Ltd. */ -#include "binman.dtsi" - -/ { - memory@0 { - device_type = "memory"; - reg = <0x00000000 0x00000000 0x00000000 0x80000000>; - }; -}; - &uart0 { bootph-pre-ram; };
@@ -96,26 +87,3 @@ 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/k1-musepi-pro-u-boot.dtsi +0 -29
@@ -4,7 +4,6 @@ */ #include <dt-bindings/clock/spacemit,k1-syscon.h> -#include "binman.dtsi" / { aliases {
@@ -15,11 +14,6 @@ chosen { stdout-path = "serial0:115200n8"; }; - - memory@0 { - device_type = "memory"; - reg = <0x00000000 0x00000000 0x00000000 0x80000000>; - }; }; &syscon_mpmu {
@@ -133,26 +127,3 @@ 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
@@ -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 new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Copyright (C) 2026 RISCstar Ltd. + */ + +/ { + memory@0 { + device_type = "memory"; + reg = <0x00000000 0x00000000 0x00000000 0x80000000>; + }; +}; + +#include "spacemit-k1-binman.dtsi"
configs/spacemit_k1_defconfig +1 -0
@@ -66,6 +66,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_EFI_PARTITION=y CONFIG_OF_UPSTREAM=y +CONFIG_DEVICE_TREE_INCLUDES="spacemit-k1-u-boot.dtsi" CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro" CONFIG_MULTI_DTB_FIT=y CONFIG_ENV_OVERWRITE=y
Signature · 1 line
2.56.1
Re: [PATCH v3 01/13] riscv: dts: spacemit: k1: Move common U-Boot nodes to shared DTSI
Quoted 185 lines · Anand Moon
The Banana Pi BPI-F3 and MusePi Pro U-Boot device trees contain identical Binman descriptions and memory node overrides.
Move the Binman description into
spacemit-k1-binman.dtsiand the memory override intospacemit-k1-u-boot.dtsi.Include the common U-Boot device tree through
DEVICE_TREE_INCLUDESto avoid duplicating these definitions in the board-specific files.This is a device tree reorganization with no intended functional changes.
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]>Signed-off-by Anand Moon <[email protected]>--- arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 32 ----------------------- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 29 -------------------- arch/riscv/dts/spacemit-k1-binman.dtsi | 29 ++++++++++++++++++++ arch/riscv/dts/spacemit-k1-u-boot.dtsi | 13 +++++++++ configs/spacemit_k1_defconfig | 1 + 5 files changed, 43 insertions(+), 61 deletions(-) create mode 100644 arch/riscv/dts/spacemit-k1-binman.dtsi create mode 100644 arch/riscv/dts/spacemit-k1-u-boot.dtsiarch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +0
-32@@ -3,15 +3,6 @@ * Copyright (C) 2026 RISCstar Ltd. */ -#include "binman.dtsi" - -/ { - memory@0 { - device_type = "memory"; - reg = <0x00000000 0x00000000 0x00000000 0x80000000>; - }; -}; - &uart0 { bootph-pre-ram; };@@ -96,26 +87,3 @@ 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/k1-musepi-pro-u-boot.dtsi +0
-29@@ -4,7 +4,6 @@ */ #include <dt-bindings/clock/spacemit,k1-syscon.h> -#include "binman.dtsi" / { aliases {@@ -15,11 +14,6 @@ chosen { stdout-path = "serial0:115200n8"; }; - - memory@0 { - device_type = "memory"; - reg = <0x00000000 0x00000000 0x00000000 0x80000000>; - }; }; &syscon_mpmu {@@ -133,26 +127,3 @@ 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@@ -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 new file +13
-0@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Copyright (C) 2026 RISCstar Ltd. + */ + +/ { + memory@0 { + device_type = "memory"; + reg = <0x00000000 0x00000000 0x00000000 0x80000000>; + }; +}; + +#include "spacemit-k1-binman.dtsi"configs/spacemit_k1_defconfig +0
-0
configs/spacemit_k1_defconfig CONFIG_CMD_EXT4=y · line 72
Quoted 7 lines
configs/spacemit_k1_defconfig +1
-0@@ -66,6 +66,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_EFI_PARTITION=y CONFIG_OF_UPSTREAM=y +CONFIG_DEVICE_TREE_INCLUDES="spacemit-k1-u-boot.dtsi" CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro" CONFIG_MULTI_DTB_FIT=y CONFIG_ENV_OVERWRITE=y
PATCH v3 2/13 riscv: dts: spacemit: k1-musepi-pro: Drop redundant DT overrides
In reply to Anand MoonThe upstream MusePi Pro device tree already defines the serial0, mmc0 and mmc1 aliases, as well as the chosen stdout-path.
Remove the duplicate definitions from the U-Boot-specific device tree while retaining the console alias.
No functional changes are intended.
--- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 5 ----- 1 file changed, 5 deletions(-)
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +0 -5
@@ -8,11 +8,6 @@ / { aliases { console = &uart0; - serial0 = &uart0; - }; - - chosen { - stdout-path = "serial0:115200n8"; }; };
Signature · 1 line
2.56.1
Re: [PATCH v3 02/13] riscv: dts: spacemit: k1-musepi-pro: Drop redundant DT overrides
Quoted 24 lines · Anand Moon
The upstream MusePi Pro device tree already defines the serial0, mmc0 and mmc1 aliases, as well as the chosen stdout-path.
Remove the duplicate definitions from the U-Boot-specific device tree while retaining the console alias.
No functional changes are intended.
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]>Signed-off-by Anand Moon <[email protected]>--- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 5 ----- 1 file changed, 5 deletions(-)arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +0
-0@@ -8,11 +8,6 @@ / {
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi line 13
Quoted 10 lines
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +0
-5aliases { console = &uart0; - serial0 = &uart0; - }; - - chosen { - stdout-path = "serial0:115200n8"; }; };
PATCH v3 3/13 riscv: dts: spacemit: k1: Move common U-Boot properties to shared DTSI
In reply to Anand MoonMove common U-Boot device tree properties from the Banana Pi F3 and MusePi Pro board-specific DTSI files into spacemit-k1-u-boot.dtsi.
Consolidate early boot properties for UART, clocks, I2C, eMMC and SDHCI controllers to reduce duplication between the boards.
Also move the clock configuration for the MPMU and APBC system controllers into the shared DTSI.
--- arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 54 ---------------- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 79 ----------------------- arch/riscv/dts/spacemit-k1-u-boot.dtsi | 76 ++++++++++++++++++++++ 3 files changed, 76 insertions(+), 133 deletions(-)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +0 -54
@@ -3,50 +3,6 @@ * Copyright (C) 2026 RISCstar Ltd. */ -&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. * The SPL board code looks up the bucks that DDR training depends on by
@@ -77,13 +33,3 @@ }; }; }; - -&emmc { - bootph-pre-ram; - max-frequency = <204800000>; -}; - -&sdhci0 { - bootph-pre-ram; - max-frequency = <204800000>; -};
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +0 -79
88 lines not on this page · raw message
arch/riscv/dts/spacemit-k1-u-boot.dtsi +76 -0
87 lines not on this page · raw message
Signature · 1 line
2.56.1
Re: [PATCH v3 03/13] riscv: dts: spacemit: k1: Move common U-Boot properties to shared DTSI
Hi Anand,
Quoted 5 lines · Anand Moon
Move common U-Boot device tree properties from the Banana Pi F3 and MusePi Pro board-specific DTSI files into
spacemit-k1-u-boot.dtsi.Consolidate early boot properties for UART, clocks, I2C, eMMC and SDHCI controllers to reduce duplication between the boards.
No, this "reduce duplication" increases the duplication of work in future and likely broken outcome, also making git bisect confusing to compare. If a node sits in k1-bananapi-f3.dts devicetree-rebasing and needs a bootph-pre-ram hint then it should get the override in u-boot k1-bananapi-f3-u-boot.dtsi; if there is e.g. "k1-common.dtsi" included by *some* boards' dts then it is still per-board and not spacemit-k1-u-boot.dtsi specific, for u-boot override purposes. What I can think of that should be in spacemit-k1-u-boot.dtsi u-boot override are k1.dtsi specific nodes.
If they are indeed common then upstream would have consolidated this firstly. I would accept a link to LKML discussion where such "consolidation" has been reviewed and queued for-next in the case where you are implementing this here knowing that, for development cycle schedule considerations, it is going to be the same as the shape of upstream development that has not yet been applied in a merge window for the Linux development cycle.
Quoted 261 lines
Also move the clock configuration for the MPMU and APBC system controllers into the shared DTSI.
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]>Signed-off-by Anand Moon <[email protected]>--- arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 54 ---------------- arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 79 ----------------------- arch/riscv/dts/spacemit-k1-u-boot.dtsi | 76 ++++++++++++++++++++++ 3 files changed, 76 insertions(+), 133 deletions(-)arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +0
-54@@ -3,50 +3,6 @@ * Copyright (C) 2026 RISCstar Ltd. */ -&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. * The SPL board code looks up the bucks that DDR training depends on by@@ -77,13 +33,3 @@ }; }; }; - -&emmc { - bootph-pre-ram; - max-frequency = <204800000>; -}; - -&sdhci0 { - bootph-pre-ram; - max-frequency = <204800000>; -};arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +0
-79@@ -3,75 +3,6 @@ * Copyright (C) 2026 RISCstar Ltd. */ -#include <dt-bindings/clock/spacemit,k1-syscon.h> - -/ { - aliases { - console = &uart0; - }; -}; - -&syscon_mpmu { - clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>, - <&pll CLK_PLL1_D4>; - clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m", - "pll1_d4"; -}; - -&syscon_apbc { - clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>, - <&pll CLK_PLL1_D4>, - <&syscon_mpmu CLK_PLL1_31P5>, - <&syscon_apmu CLK_PMUA_ACLK>; - clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m", - "pll1_d4", "pll1_d78_31p5", "pmua_aclk"; -}; - -&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; - status = "okay"; - }; -}; - &i2c8 { bootph-pre-ram; status = "okay";@@ -112,13 +43,3 @@ status = "okay"; }; }; - -&emmc { - bootph-pre-ram; - max-frequency = <204800000>; -}; - -&sdhci0 { - bootph-pre-ram; - max-frequency = <204800000>; -};arch/riscv/dts/spacemit-k1-u-boot.dtsi +69
-0@@ -3,11 +3,87 @@ * Copyright (C) 2026 RISCstar Ltd. */ +#include <dt-bindings/clock/spacemit,k1-syscon.h> + / { memory@0 { device_type = "memory"; reg = <0x00000000 0x00000000 0x00000000 0x80000000>; }; + + aliases { + console = &uart0; + }; +}; + +&syscon_mpmu { + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>, + <&pll CLK_PLL1_D4>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m", + "pll1_d4"; +}; + +&syscon_apbc { + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>, + <&pll CLK_PLL1_D4>, + <&syscon_mpmu CLK_PLL1_31P5>, + <&syscon_apmu CLK_PMUA_ACLK>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m", + "pll1_d4", "pll1_d78_31p5", "pmua_aclk"; +}; + +&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; + }; +}; + +&emmc {
arch/riscv/dts/spacemit-k1-u-boot.dtsi line 89
Quoted 10 lines
arch/riscv/dts/spacemit-k1-u-boot.dtsi +7
-0+ bootph-pre-ram; + max-frequency = <204800000>; +}; + +&sdhci0 { + bootph-pre-ram; + max-frequency = <204800000>; }; #include "spacemit-k1-binman.dtsi"
As above, changes requested please.
-E
Re: [PATCH v3 03/13] riscv: dts: spacemit: k1: Move common U-Boot properties to shared DTSI
Hi E Shattow,
Quoted 10 lines · E Shattow
Hi Anand,
Quoted 5 lines · Anand Moon
Move common U-Boot device tree properties from the Banana Pi F3 and MusePi Pro board-specific DTSI files into
spacemit-k1-u-boot.dtsi.Consolidate early boot properties for UART, clocks, I2C, eMMC and SDHCI controllers to reduce duplication between the boards.
Quoted 10 lines
No, this "reduce duplication" increases the duplication of work in future and likely broken outcome, also making git bisect confusing to compare. If a node sits in
k1-bananapi-f3.dtsdevicetree-rebasing and needs a bootph-pre-ram hint then it should get the override in u-bootk1-bananapi-f3-u-boot.dtsi; if there is e.g. "k1-common.dtsi" included by *some* boards' dts then it is still per-board and notspacemit-k1-u-boot.dtsispecific, for u-boot override purposes. What I can think of that should be inspacemit-k1-u-boot.dtsiu-boot override arek1.dtsispecific nodes.
As of now, k1.dtsi does not contain any bootph-pre-ram properties, so the early boot overrides are still necessary where the corresponding devices are required in SPL.
Quoted 8 lines
If they are indeed common then upstream would have consolidated this firstly. I would accept a link to LKML discussion where such "consolidation" has been reviewed and queued for-next in the case where you are implementing this here knowing that, for development cycle schedule considerations, it is going to be the same as the shape of upstream development that has not yet been applied in a merge window for the Linux development cycle.
Earlier, I had requested adding the missing bootph-pre-ram properties to the pinctrl nodes and the missing regulator names in the upstream device trees [1].
Currently, most of the device tree configurations for eMMC, SD cards, SPI flash and PCIe are already available in the upstream device trees under dts/upstream/src/riscv/spacemit/. Only a few bootph-pre-ram properties and other required properties are missing.
The intention behind moving the common properties into spacemit-k1-u-boot.dtsi was to simplify the U-Boot-specific device tree overrides for Banana Pi BPI-F3 and MusePi Pro, while retaining the board-specific i2c8 regulator configurations in their respective DTSI files.
However, I understand your concern about maintaining consistency with the upstream device tree hierarchy and avoiding additional maintenance during future devicetree-rebasing updates.
I will revisit these changes and limit spacemit-k1-u-boot.dtsi to overrides for nodes defined in k1.dtsi, while retaining board-specific overrides in their respective U-Boot DTSI files.
Once the changes are accepted and synchronized into U-Boot through devicetree-rebasing, we can remove the corresponding redundant overrides.
[1] https://lore.kernel.org/all/CANAwSgQ=Djw_o89MgvEsmKVxuNiE3Yuy=e0T5DcLfqCYy6eWMw@mail.gmail.com/#t
Thanks,
-Anand
PATCH v3 4/13 clk: spacemit: k1: Add GPIO and AIB clock support in SPL
In reply to Anand MoonThe SpacemiT K1 GPIO and pinctrl controllers require their functional and bus clocks to be enabled before accessing the controller registers.
These clocks are currently only available in U-Boot proper, preventing the GPIO and pinctrl drivers from enabling their clocks in SPL.
Move the GPIO and AIB clock definitions outside the SPL conditional and register them in the SPL APBC clock table.
This allows both controllers to enable their required clocks during early boot.
--- drivers/clk/spacemit/clk-k1.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/clk/spacemit/clk-k1.c +17 -12
@@ -379,9 +379,6 @@ CCU_MUX_GATE_DEFINE(CLK_UART9, uart9_clk, uart9_clk, uart_clk_parents,ARRAY_SIZE (uart_clk_parents),APBC_UART9_CLK_RST , 4, 3, BIT(1) | BIT(0), 0); -CCU_GATE_DEFINE (CLK_GPIO , gpio_clk, gpio_clk,"clock-24m" ,APBC_GPIO_CLK_RST , -BIT (1 ) |BIT (0 ),0 ); -static const char *const pwm_parents[] = {"pll1_d192_12p8" ,"clock-32k" ,
@@ -499,9 +496,6 @@ CCU_MUX_GATE_DEFINE(CLK_TIMERS2, timers2_clk, timers2_clk, timer_parents,ARRAY_SIZE (timer_parents),APBC_TIMERS2_CLK_RST ,4 ,3 , BIT(1) | BIT(0), 0); -CCU_GATE_DEFINE (CLK_AIB , aib_clk, aib_clk,"clock-24m" ,APBC_AIB_CLK_RST , -BIT (1 ) |BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_ONEWIRE , onewire_clk, onewire_clk,"clock-24m" ,APBC_ONEWIRE_CLK_RST ,BIT (1 ) |BIT (0 ),0 );
@@ -584,9 +578,6 @@ CCU_GATE_DEFINE(CLK_UART8_BUS, uart8_bus_clk, uart8_bus_clk, "apb_clk",CCU_GATE_DEFINE (CLK_UART9_BUS , uart9_bus_clk, uart9_bus_clk,"apb_clk" ,APBC_UART9_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_GPIO_BUS , gpio_bus_clk, gpio_bus_clk,"apb_clk" , -APBC_GPIO_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_PWM0_BUS , pwm0_bus_clk, pwm0_bus_clk,"apb_clk" ,APBC_PWM0_CLK_RST ,BIT (0 ),0 ); CCU_GATE_DEFINE(CLK_PWM1_BUS, pwm1_bus_clk, pwm1_bus_clk, "apb_clk",
@@ -655,9 +646,6 @@ CCU_GATE_DEFINE(CLK_TIMERS1_BUS, timers1_bus_clk, timers1_bus_clk, "apb_clk",CCU_GATE_DEFINE (CLK_TIMERS2_BUS , timers2_bus_clk, timers2_bus_clk,"apb_clk" ,APBC_TIMERS2_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_AIB_BUS , aib_bus_clk, aib_bus_clk,"apb_clk" , -APBC_AIB_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_ONEWIRE_BUS , onewire_bus_clk, onewire_bus_clk,"apb_clk" ,APBC_ONEWIRE_CLK_RST ,BIT (0 ),0 );
@@ -672,6 +660,19 @@ CCU_GATE_DEFINE(CLK_TSEN_BUS, tsen_bus_clk, tsen_bus_clk, "apb_clk",CCU_GATE_DEFINE (CLK_IPC_AP2AUD_BUS , ipc_ap2aud_bus_clk, ipc_ap2aud_bus_clk,"apb_clk" ,APBC_IPC_AP2AUD_CLK_RST ,BIT (0 ),0 );#endif + +CCU_GATE_DEFINE (CLK_GPIO , gpio_clk, gpio_clk,"clock-24m" ,APBC_GPIO_CLK_RST , +BIT (1 ) |BIT (0 ),0 ); + +CCU_GATE_DEFINE (CLK_AIB , aib_clk, aib_clk,"clock-24m" ,APBC_AIB_CLK_RST , +BIT (1 ) |BIT (0 ),0 ); + +CCU_GATE_DEFINE (CLK_GPIO_BUS , gpio_bus_clk, gpio_bus_clk,"apb_clk" , +APBC_GPIO_CLK_RST ,BIT (0 ),0 ); + +CCU_GATE_DEFINE (CLK_AIB_BUS , aib_bus_clk, aib_bus_clk,"apb_clk" , +APBC_AIB_CLK_RST ,BIT (0 ),0 ); +/* APBC clocks end */ /* APMU clocks start */
@@ -1309,10 +1310,14 @@ static const struct spacemit_ccu_data k1_ccu_mpmu_data = {#if IS_ENABLED (CONFIG_SPL_BUILD )static struct clk *k1_ccu_apbc_clks[] = { &uart0_clk.common.clk, + &gpio_clk.common.clk, &twsi2_clk.common.clk, &twsi8_clk.common.clk, + &aib_clk.common.clk, + &gpio_bus_clk.common.clk, &twsi2_bus_clk.common.clk, &twsi8_bus_clk.common.clk, + &aib_bus_clk.common.clk, };#else static struct clk *k1_ccu_apbc_clks[] = {
Signature · 1 line
2.56.1
Re: [PATCH v3 04/13] clk: spacemit: k1: Add GPIO and AIB clock support in SPL
Quoted 92 lines · Anand Moon
The SpacemiT K1 GPIO and pinctrl controllers require their functional and bus clocks to be enabled before accessing the controller registers.
These clocks are currently only available in U-Boot proper, preventing the GPIO and pinctrl drivers from enabling their clocks in SPL.
Move the GPIO and AIB clock definitions outside the SPL conditional and register them in the SPL APBC clock table.
This allows both controllers to enable their required clocks during early boot.
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]>Suggested-by Junhui Liu <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/clk/spacemit/clk-k1.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)drivers/clk/spacemit/clk-k1.c +14
-12@@ -379,9 +379,6 @@ CCU_MUX_GATE_DEFINE(CLK_UART9, uart9_clk, uart9_clk, uart_clk_parents,ARRAY_SIZE (uart_clk_parents),APBC_UART9_CLK_RST , 4, 3, BIT(1) | BIT(0), 0); -CCU_GATE_DEFINE (CLK_GPIO , gpio_clk, gpio_clk,"clock-24m" ,APBC_GPIO_CLK_RST , -BIT (1 ) |BIT (0 ),0 ); -static const char *const pwm_parents[] = {"pll1_d192_12p8" ,"clock-32k" ,@@ -499,9 +496,6 @@ CCU_MUX_GATE_DEFINE(CLK_TIMERS2, timers2_clk, timers2_clk, timer_parents,ARRAY_SIZE (timer_parents),APBC_TIMERS2_CLK_RST ,4 ,3 , BIT(1) | BIT(0), 0); -CCU_GATE_DEFINE (CLK_AIB , aib_clk, aib_clk,"clock-24m" ,APBC_AIB_CLK_RST , -BIT (1 ) |BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_ONEWIRE , onewire_clk, onewire_clk,"clock-24m" ,APBC_ONEWIRE_CLK_RST ,BIT (1 ) |BIT (0 ),0 );@@ -584,9 +578,6 @@ CCU_GATE_DEFINE(CLK_UART8_BUS, uart8_bus_clk, uart8_bus_clk, "apb_clk",CCU_GATE_DEFINE (CLK_UART9_BUS , uart9_bus_clk, uart9_bus_clk,"apb_clk" ,APBC_UART9_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_GPIO_BUS , gpio_bus_clk, gpio_bus_clk,"apb_clk" , -APBC_GPIO_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_PWM0_BUS , pwm0_bus_clk, pwm0_bus_clk,"apb_clk" ,APBC_PWM0_CLK_RST ,BIT (0 ),0 ); CCU_GATE_DEFINE(CLK_PWM1_BUS, pwm1_bus_clk, pwm1_bus_clk, "apb_clk",@@ -655,9 +646,6 @@ CCU_GATE_DEFINE(CLK_TIMERS1_BUS, timers1_bus_clk, timers1_bus_clk, "apb_clk",CCU_GATE_DEFINE (CLK_TIMERS2_BUS , timers2_bus_clk, timers2_bus_clk,"apb_clk" ,APBC_TIMERS2_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_AIB_BUS , aib_bus_clk, aib_bus_clk,"apb_clk" , -APBC_AIB_CLK_RST ,BIT (0 ),0 ); -CCU_GATE_DEFINE (CLK_ONEWIRE_BUS , onewire_bus_clk, onewire_bus_clk,"apb_clk" ,APBC_ONEWIRE_CLK_RST ,BIT (0 ),0 );@@ -672,6 +660,19 @@ CCU_GATE_DEFINE(CLK_TSEN_BUS, tsen_bus_clk, tsen_bus_clk, "apb_clk",CCU_GATE_DEFINE (CLK_IPC_AP2AUD_BUS , ipc_ap2aud_bus_clk, ipc_ap2aud_bus_clk,"apb_clk" ,APBC_IPC_AP2AUD_CLK_RST ,BIT (0 ),0 );#endif + +CCU_GATE_DEFINE (CLK_GPIO , gpio_clk, gpio_clk,"clock-24m" ,APBC_GPIO_CLK_RST , +BIT (1 ) |BIT (0 ),0 ); + +CCU_GATE_DEFINE (CLK_AIB , aib_clk, aib_clk,"clock-24m" ,APBC_AIB_CLK_RST , +BIT (1 ) |BIT (0 ),0 ); + +CCU_GATE_DEFINE (CLK_GPIO_BUS , gpio_bus_clk, gpio_bus_clk,"apb_clk" , +APBC_GPIO_CLK_RST ,BIT (0 ),0 ); + +CCU_GATE_DEFINE (CLK_AIB_BUS , aib_bus_clk, aib_bus_clk,"apb_clk" , +APBC_AIB_CLK_RST ,BIT (0 ),0 ); +/* APBC clocks end */ /* APMU clocks start */ @@ -1309,10 +1310,14 @@ static const struct spacemit_ccu_data k1_ccu_mpmu_data = {#if IS_ENABLED (CONFIG_SPL_BUILD )static struct clk *k1_ccu_apbc_clks[] = { &uart0_clk.common.clk, + &gpio_clk.common.clk,
drivers/clk/spacemit/clk-k1.c static const struct spacemit_ccu_data k1_ccu_mpmu_data = { · line 1323
Quoted 10 lines
drivers/clk/spacemit/clk-k1.c +3
-0&twsi2_clk.common.clk, &twsi8_clk.common.clk, + &aib_clk.common.clk, + &gpio_bus_clk.common.clk, &twsi2_bus_clk.common.clk, &twsi8_bus_clk.common.clk, + &aib_bus_clk.common.clk, };#else static struct clk *k1_ccu_apbc_clks[] = {
PATCH v3 5/13 pinctrl: spacemit: Add SPL support for K1/K3 pinctrl driver
In reply to Anand MoonAdd a Kconfig option to enable the SpacemiT K1/K3 pinctrl driver in SPL, allowing pin multiplexing and pin configuration during early board initialization.
--- drivers/pinctrl/spacemit/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/pinctrl/spacemit/Kconfig +8 -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/K3 pinctrl driver in SPL" + depends on SPL_PINCTRL && (TARGET_SPACEMIT_K1 || TARGET_SPACEMIT_K3) + select PINCTRL_SPACEMIT_K1 + help + Enable the SpacemiT K1/K3 pinctrl driver in SPL to configure + pin multiplexing and pin settings during early initialization.
Signature · 1 line
2.56.1
Re: [PATCH v3 05/13] pinctrl: spacemit: Add SPL support for K1/K3 pinctrl driver
Quoted 21 lines · Anand Moon
Add a
Kconfigoption to enable the SpacemiT K1/K3 pinctrl driver in SPL, allowing pin multiplexing and pin configuration during 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]>Reviewed-by Yixun Lan <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/pinctrl/spacemit/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/pinctrl/spacemit/Kconfig +0
-0@@ -7,3 +7,11 @@ config PINCTRL_SPACEMIT_K1 The driver is controlled by a device tree node which contains both
drivers/pinctrl/spacemit/Kconfig config PINCTRL_SPACEMIT_K1 · line 17
Quoted 10 lines
drivers/pinctrl/spacemit/Kconfig +8
-0the GPIO definitions and pin control functions for each available multiplex function. + +config SPL_PINCTRL_SPACEMIT_K1 + bool "SpacemiT K1/K3 pinctrl driver in SPL" + depends on SPL_PINCTRL && (TARGET_SPACEMIT_K1 || TARGET_SPACEMIT_K3) + select PINCTRL_SPACEMIT_K1 + help + Enable the SpacemiT K1/K3 pinctrl driver in SPL to configure + pin multiplexing and pin settings during early initialization.
PATCH v3 6/13 gpio: spacemit: Add SPL support for K1/K3 GPIO driver
In reply to Anand MoonAllow SPL to access GPIOs on SpacemiT K1 and K3 platforms during early board initialization, including GPIO-based card detection for SD controllers.
--- drivers/gpio/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpio/Kconfig +7 -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 GPIO driver in SPL" + depends on SPL_DM_GPIO && (TARGET_SPACEMIT_K1 || TARGET_SPACEMIT_K3) + select SPACEMIT_GPIO + help + Enable the SpacemiT GPIO driver in SPL to provide GPIO + access during early board initialization. config SUNXI_GPIO bool "Allwinner GPIO driver"
Signature · 1 line
2.56.1
Re: [PATCH v3 06/13] gpio: spacemit: Add SPL support for K1/K3 GPIO driver
Quoted 23 lines · Anand Moon
Allow SPL to access GPIOs on SpacemiT K1 and K3 platforms during early board initialization, including GPIO-based card detection for SD controllers.
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]>Reviewed-by Yixun Lan <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/gpio/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpio/Kconfig +0
-0@@ -457,6 +457,13 @@ config SPACEMIT_GPIO arranged into a number of banks (different for each SoC type) each with 32 GPIOs.
drivers/gpio/Kconfig config SPACEMIT_GPIO · line 469
Quoted 10 lines
drivers/gpio/Kconfig +7
-0+config SPL_SPACEMIT_GPIO + bool "SpacemiT GPIO driver in SPL" + depends on SPL_DM_GPIO && (TARGET_SPACEMIT_K1 || TARGET_SPACEMIT_K3) + select SPACEMIT_GPIO + help + Enable the SpacemiT GPIO driver in SPL to provide GPIO + access during early board initialization. config SUNXI_GPIO bool "Allwinner GPIO driver"
PATCH v3 7/13 mmc: spacemit_sdhci: Improve voltage switching diagnostics
In reply to Anand MoonImprove 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.
--- drivers/mmc/spacemit_sdhci.c | 79 ++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 31 deletions(-)
drivers/mmc/spacemit_sdhci.c +48 -31
@@ -226,11 +226,18 @@ static int spacemit_sdhci_set_vqmmc_voltage(struct mmc *mmc, int voltage)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 +246,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.1
PATCH v3 8/13 mmc: spacemit_sdhci: Select pinctrl state based on signal voltage
In reply to Anand MoonThe default and UHS pinctrl states describe the electrical configuration of the SD interface for 3.3V and 1.8V operation, respectively.
Selecting the pinctrl state based on the timing mode may apply an incorrect pin configuration during voltage switching and does not account for UHS DDR50 mode.
Introduce a helper to select the appropriate pinctrl state based on the requested signal voltage immediately after configuring the controller voltage.
Check whether the requested pinctrl state is available before attempting to select it, as not all SDHCI instances provide pinctrl states and these properties may be absent in SPL.
Use the phase-specific PINCTRL configuration and report errors when pinctrl state selection fails.
--- drivers/mmc/spacemit_sdhci.c | 65 +++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 15 deletions(-)
drivers/mmc/spacemit_sdhci.c +50 -15
@@ -341,12 +341,62 @@ static int spacemit_sdhci_wait_dat0(struct udevice *dev, int state,return 0 ; } +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_pinctrl_state (struct sdhci_host *host) +{ +struct mmc *mmc = host->mmc; +struct udevice *dev = mmc->dev; +const char *state; +int ret; + +if (!CONFIG_IS_ENABLED (PINCTRL )) +return ; + +switch (mmc->signal_voltage) { +case MMC_SIGNAL_VOLTAGE_330 : + state ="default" ; +break ; +case MMC_SIGNAL_VOLTAGE_180 : + state ="uhs" ; +break ; +default : +return ; + } + +if (!spacemit_sdhci_has_pinctrl_state (dev, state)) +return ; + + ret =pinctrl_select_state (dev, state); +if (ret) +log_err ("%s: failed to select pinctrl state '%s': %d\n" , + dev->name, state, ret); +else +log_debug ("%s: selected pinctrl state '%s'\n" , + dev->name, state); +} +static void spacemit_sdhci_set_control_reg (struct sdhci_host *host) {struct mmc *mmc = host->mmc;u32 reg;spacemit_sdhci_set_voltage (host); +spacemit_sdhci_set_pinctrl_state (host);if (spacemit_sdhci_is_voltage_switch_cmd (host))spacemit_sdhci_set_clk_gate (host,0 );
@@ -368,21 +418,6 @@ 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 )) { -switch (mmc->selected_mode) { -case UHS_SDR12 : -case UHS_SDR25 : -case UHS_SDR50 : -case UHS_SDR104 : -pinctrl_select_state (mmc->dev,"uhs" ); -break ; -default : -pinctrl_select_state (mmc->dev,"default" ); -break ; - } - } -if (mmc->selected_mode ==MMC_HS_200 || mmc->selected_mode ==MMC_HS_400 || mmc->selected_mode ==MMC_HS_400_ES ) {
Signature · 1 line
2.56.1
PATCH v3 9/13 riscv: spacemit: k1: Adjust SPL stack and malloc configuration
In reply to Anand MoonMove the configured initial stack pointer from 0x01000000 to 0x01200000 and set the SPL relocated-stack simple malloc allocation size to 2 MiB.
Trying to boot from MMC2
Transfer data timeout
spl: mmc init failed with error: -110
Error: -110
SPL: Unsupported Boot Device!
Trying to boot from MMC1
alloc space exhausted ptr 100380 limit 100000
Aligned buffer alloc failed
spl: could not find mmc device 0. error: -19
Error: -19
This updates the early boot memory configuration to accommodate SPL stack and dynamic allocation requirements.
--- configs/spacemit_k1_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
configs/spacemit_k1_defconfig +2 -1
@@ -3,7 +3,8 @@ 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_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x200000 CONFIG_DM_GPIO=y CONFIG_SPL_DM_SPI=y CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-musepi-pro"
Signature · 1 line
2.56.1
PATCH v3 10/13 riscv: dts: spacemit: k1: Retain GPIO and pinctrl nodes in SPL
In reply to Anand MoonThe GPIO and pinctrl controllers are required during early boot to configure pins and access GPIOs used by SPL devices.
Add bootph-pre-ram to the GPIO and pinctrl controller nodes and the pin configuration groups used by UART, I2C, QSPI and SDHCI.
Retain the corresponding child nodes to prevent SPL device tree filtering from removing the pinmux and electrical configuration properties.
This makes the required pin configurations available during SPL initialization on SpacemiT K1 boards.
--- arch/riscv/dts/spacemit-k1-u-boot.dtsi | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
arch/riscv/dts/spacemit-k1-u-boot.dtsi +44 -0
@@ -86,4 +86,48 @@ max-frequency = <204800000>; }; +&gpio { + bootph-pre-ram; +}; + +&pinctrl { + bootph-pre-ram; +}; + +&qspi_cfg { + bootph-pre-ram; + + qspi-pins { + bootph-pre-ram; + }; + + qspi-cs1-pins { + bootph-pre-ram; + }; +}; + +&mmc1_cfg { + bootph-pre-ram; + + mmc1-data-cmd-pins { + bootph-pre-ram; + }; + + mmc1-clk-pins { + bootph-pre-ram; + }; +}; + +&mmc1_uhs_cfg { + bootph-pre-ram; + + mmc1-data-cmd-pins { + bootph-pre-ram; + }; + + mmc1-clk-pins { + bootph-pre-ram; + }; +}; + #include "spacemit-k1-binman.dtsi"
Signature · 1 line
2.56.1
PATCH v3 11/13 riscv: spacemit: k1: Enable GPIO, pinctrl and MMC UHS support
In reply to Anand MoonEnable the SpacemiT GPIO and pinctrl drivers in SPL to support GPIO-based SD card detection and device tree-based pin configuration during early boot.
Enable MMC UHS support in both SPL and U-Boot proper to allow SD cards to operate in the supported UHS modes and select the appropriate pinctrl state for 1.8V signaling.
--- configs/spacemit_k1_defconfig | 7 +++++++ 1 file changed, 7 insertions(+)
configs/spacemit_k1_defconfig +7 -0
@@ -122,3 +122,10 @@ CONFIG_USB_DWC3_GENERIC=y CONFIG_USB_STORAGE=y CONFIG_USB_ONBOARD_HUB=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_MMC_UHS_SUPPORT=y +CONFIG_SPL_MMC_UHS_SUPPORT=y
Signature · 1 line
2.56.1
PATCH v3 12/13 riscv: spacemit: k1: Enable uncompressed multi-DTB FIT support in SPL
In reply to Anand MoonEnable multi-DTB FIT support in SPL for the Banana Pi BPI-F3 and MusePi Pro boards.
Use an uncompressed FIT to avoid allocating a decompression buffer from the limited early SPL malloc pool.
Increasing the early malloc pool to accommodate the compressed FIT causes the relocated DDR firmware to overlap SPL global data and malloc memory, resulting in memory corruption before DDR initialization.
Using an uncompressed FIT allows the original early malloc pool size to be retained and avoids the observed SRAM overlap.
--- configs/spacemit_k1_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/spacemit_k1_defconfig +3 -0
@@ -69,7 +69,10 @@ CONFIG_EFI_PARTITION=y CONFIG_OF_UPSTREAM=y CONFIG_DEVICE_TREE_INCLUDES="spacemit-k1-u-boot.dtsi" CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro" +CONFIG_SPL_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro" CONFIG_MULTI_DTB_FIT=y +CONFIG_SPL_MULTI_DTB_FIT=y +CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y CONFIG_ENV_OVERWRITE=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_SYSCON=y
Signature · 1 line
2.56.1
PATCH v3 13/13 riscv: dts: spacemit: k1: Support multi-DTB SPL images in Binman
In reply to Anand MoonWhen SPL multi-DTB FIT support is enabled, the build appends the FIT image to the SPL binary instead of generating a standalone u-boot-spl.dtb file.
The expanded Binman SPL entry expects this standalone DTB, causing image generation to fail.
Add the no-expanded property to use the combined SPL binary directly, allowing both single-DTB and multi-DTB SPL images to be packaged while preserving the existing DDR firmware alignment.
--- arch/riscv/dts/spacemit-k1-binman.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/riscv/dts/spacemit-k1-binman.dtsi +1 -0
@@ -12,6 +12,7 @@ pad-byte = <0xff>; u-boot-spl { + no-expanded; }; ddr-fw {
Signature · 1 line
2.56.1