Skip to contentSkip to conversation

riscv: spacemit: add Spacemit K1 SoC support

PATCH New Eric Chung 1 participant 15 messages Jun 30

Subsystems (4)
lore
Share & tools
lore

Eric Chung

author
#0 lore raw

v5 cover riscv: spacemit: add Spacemit K1 SoC support

Changelog in v5:

- Rebase v4 patch set on next branch.

---
Guodong Xu (2):
clk: spacemit: k1: prune SPL clock tree
doc: spacemit: add K1 SPL build and test guide

Raymond Mao (12):
spacemit: k1: support multi-board infrastructure
spacemit: k1: enable SPL with debug UART
configs: k1: enable early timer support
configs: k1: add default option for clock driver in SPL
dts: k1: enable clocks in SPL
board: k1: initialize clock and serial devices in SPL
i2c: k1: add I2C driver support
spacemit: k1: add TLV EEPROM support in SPL
spacemit: k1: Add DDR firmware support to SPL
power: pmic: add support for Spacemit P1 PMIC
power: regulator: add support for Spacemit P1 SoC
board: k1: enable pmic in spl

 arch/riscv/Kconfig                              |   8 +-
 arch/riscv/cpu/k1/Kconfig                       |   6 +
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi       | 100 +++++
 board/spacemit/bananapi-f3/MAINTAINERS          |   6 -
 board/spacemit/bananapi-f3/Makefile             |   5 -
 board/spacemit/{bananapi-f3 => k1}/Kconfig      |   6 +-
 board/spacemit/k1/MAINTAINERS                   |  11 +
 board/spacemit/k1/Makefile                      |  28 ++
 board/spacemit/{bananapi-f3 => k1}/board.c      |   0
 board/spacemit/k1/spl.c                         | 343 ++++++++++++++++
 board/spacemit/k1/tlv_codes.h                   |  22 +
 configs/bananapi-f3_defconfig                   |  26 --
 configs/spacemit_k1_defconfig                   |  66 +++
 doc/board/spacemit/bananapi-f3.rst              |   2 +-
 doc/board/spacemit/index.rst                    |   1 +
 doc/board/spacemit/k1-spl.rst                   | 243 +++++++++++
 drivers/clk/spacemit/clk-k1.c                   | 128 ++++++
 drivers/i2c/Kconfig                             |   7 +
 drivers/i2c/Makefile                            |   1 +
 drivers/i2c/k1_i2c.c                            | 523 ++++++++++++++++++++++++
 drivers/i2c/k1_i2c.h                            |  69 ++++
 drivers/power/pmic/Kconfig                      |   8 +
 drivers/power/pmic/Makefile                     |   1 +
 drivers/power/pmic/pmic_spacemit_p1.c           |  94 +++++
 drivers/power/regulator/Kconfig                 |   7 +
 drivers/power/regulator/Makefile                |   1 +
 drivers/power/regulator/spacemit_p1_regulator.c | 464 +++++++++++++++++++++
 include/configs/bananapi-f3.h                   |  13 -
 include/configs/k1.h                            |  20 +
 include/power/spacemit_p1.h                     | 163 ++++++++
 30 files changed, 2314 insertions(+), 58 deletions(-)

---
base-commit: 3c5e8836ccca95e4846f6f4b03b8729ede48daf4
change-id: 20260630-m1-795ae0422400

Best regards,

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

PATCH v5 1/14 spacemit: k1: support multi-board infrastructure

From: Raymond Mao <[email protected]>

Restructure K1 SoC support to handle multiple boards through a single configuration:

1. Rename bananapi-f3_defconfig to spacemit_k1_defconfig.
2. Move all K1 board files to board/spacemit/k1/.
3. Replace TARGET_BANANAPI_F3 with TARGET_SPACEMIT_K1 and rename the board's <board>.h header to k1.h.

Eliminates the need for board-specific defconfigs while maintaining hardware compatibility.

---
 arch/riscv/Kconfig                                       | 8 ++++----
 arch/riscv/cpu/k1/Kconfig                                | 4 ++++
 board/spacemit/{bananapi-f3 => k1}/Kconfig               | 6 +++---
 board/spacemit/{bananapi-f3 => k1}/MAINTAINERS           | 4 ++--
 board/spacemit/{bananapi-f3 => k1}/Makefile              | 0
 board/spacemit/{bananapi-f3 => k1}/board.c               | 0
 configs/{bananapi-f3_defconfig => spacemit_k1_defconfig} | 2 +-
 doc/board/spacemit/bananapi-f3.rst                       | 2 +-
 include/configs/{bananapi-f3.h => k1.h}                  | 0
 9 files changed, 15 insertions(+), 11 deletions(-)
arch/riscv/Kconfig +4 -4
index ad7589123c6..485067ed266 100644
@@ -14,9 +14,6 @@ config TARGET_ANDES_AE350
 config TARGET_ANDES_VOYAGER
 	bool "Support Andes Voyager Board"
 
-config TARGET_BANANAPI_F3
-	bool "Support BananaPi F3 Board"
-
 config TARGET_BEAGLEBOARD_BEAGLEVFIRE
 	bool "Support BeagleBoard BeagleV-Fire Board (based on Microchip MPFS)"
 
@@ -50,6 +47,9 @@ config TARGET_SIPEED_MAIX
 	bool "Support Sipeed Maix Board"
 	select SYS_CACHE_SHIFT_6
 
+config TARGET_SPACEMIT_K1
+	bool "Support Spacemit K1 SoC"
+
 config TARGET_STARFIVE_VISIONFIVE2
 	bool "Support StarFive VisionFive2 Board"
 	select BOARD_LATE_INIT
@@ -119,7 +119,7 @@ source "board/sifive/unmatched/Kconfig"
 source "board/sipeed/maix/Kconfig"
 source "board/sophgo/milkv_duo/Kconfig"
 source "board/sophgo/licheerv_nano/Kconfig"
-source "board/spacemit/bananapi-f3/Kconfig"
+source "board/spacemit/k1/Kconfig"
 source "board/starfive/visionfive2/Kconfig"
 source "board/thead/th1520_lpi4a/Kconfig"
 source "board/xilinx/mbv/Kconfig"
arch/riscv/cpu/k1/Kconfig +4 -0
index 14201df80f2..3701bf2b5da 100644
@@ -2,6 +2,8 @@
 #
 # Copyright (C) 2024, Kongyang Liu <[email protected]>
 
+if TARGET_SPACEMIT_K1
+
 config SPACEMIT_K1
 	bool
 	select BINMAN
@@ -17,3 +19,5 @@ config SPACEMIT_K1
 	imply SPL_CPU
 	imply SPL_OPENSBI
 	imply SPL_LOAD_FIT
+
+endif
board/spacemit/k1/Kconfig renamed from board/spacemit/bananapi-f3/Kconfig +3 -3
similarity index 79%
rename from board/spacemit/bananapi-f3/Kconfig
rename to board/spacemit/k1/Kconfig
index f89fa9af2c7..1c615f89b64 100644
@@ -1,7 +1,7 @@
-if TARGET_BANANAPI_F3
+if TARGET_SPACEMIT_K1
 
 config SYS_BOARD
-	default "bananapi-f3"
+	default "k1"
 
 config SYS_VENDOR
 	default "spacemit"
@@ -10,7 +10,7 @@ config SYS_CPU
 	default "k1"
 
 config SYS_CONFIG_NAME
-	default "bananapi-f3"
+	default "k1"
 
 config TEXT_BASE
 	default 0x00200000
board/spacemit/k1/MAINTAINERS renamed from board/spacemit/bananapi-f3/MAINTAINERS +2 -2
similarity index 61%
rename from board/spacemit/bananapi-f3/MAINTAINERS
rename to board/spacemit/k1/MAINTAINERS
index 131bad03181..b256cbe7978 100644
@@ -1,6 +1,6 @@
 BananaPi F3
 M:	Huan Zhou <pericycle.cc@@gmail.com>
 S:	Maintained
-F:	board/spacemit/bananapi-f3/
-F:	configs/bananapi-f3_defconfig
+F:	board/spacemit/k1/
+F:	configs/spacemit_k1_defconfig
 F:	doc/board/spacemit/bananapi-f3.rst
board/spacemit/k1/Makefile renamed from board/spacemit/bananapi-f3/Makefile +0 -0
similarity index 100%
rename from board/spacemit/bananapi-f3/Makefile
rename to board/spacemit/k1/Makefile
board/spacemit/k1/board.c renamed from board/spacemit/bananapi-f3/board.c +0 -0
similarity index 100%
rename from board/spacemit/bananapi-f3/board.c
rename to board/spacemit/k1/board.c
configs/spacemit_k1_defconfig renamed from configs/bananapi-f3_defconfig +1 -1
similarity index 95%
rename from configs/bananapi-f3_defconfig
rename to configs/spacemit_k1_defconfig
index adecbee10f2..fae561bbf8a 100644
@@ -6,7 +6,7 @@ CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000
 CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-bananapi-f3"
 CONFIG_SYS_BOOTM_LEN=0xa000000
 CONFIG_SYS_LOAD_ADDR=0x200000
-CONFIG_TARGET_BANANAPI_F3=y
+CONFIG_TARGET_SPACEMIT_K1=y
 CONFIG_ARCH_RV64I=y
 CONFIG_RISCV_SMODE=y
 CONFIG_FIT=y
doc/board/spacemit/bananapi-f3.rst +1 -1
index f2220950a3a..1ece2ce9d02 100644
@@ -29,7 +29,7 @@ built for SpacemiT K1 SoC as below:
 .. code-block:: console
 
    cd <U-Boot-dir>
-   make bananapi-f3_defconfig
+   make spacemit_k1_defconfig
    make OPENSBI=<OpenSBI-dir>/build/platform/generic/firmware/fw_dynamic.bin
 
 This will generate u-boot.itb
include/configs/k1.h renamed from include/configs/bananapi-f3.h +0 -0
similarity index 100%
rename from include/configs/bananapi-f3.h
rename to include/configs/k1.h
Signature · 1 line
2.51.0
author
#2 lore raw

PATCH v5 2/14 spacemit: k1: enable SPL with debug UART

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Add SPL support featuring debug UART output for early boot diagnostics on K1 SoC.

---
 arch/riscv/cpu/k1/Kconfig                 |  2 ++
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi |  4 ++++
 board/spacemit/k1/Makefile                |  2 ++
 board/spacemit/k1/spl.c                   | 24 ++++++++++++++++++++++++
 configs/spacemit_k1_defconfig             | 16 ++++++++++++++++
 include/configs/k1.h                      |  6 ++++--
 6 files changed, 52 insertions(+), 2 deletions(-)
arch/riscv/cpu/k1/Kconfig +2 -0
index 3701bf2b5da..b155535658d 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 #
 # Copyright (C) 2024, Kongyang Liu <[email protected]>
+# Copyright (C) 2025-2026, RISCstar Ltd.
 
 if TARGET_SPACEMIT_K1
 
@@ -9,6 +10,7 @@ config SPACEMIT_K1
 	select BINMAN
 	select ARCH_EARLY_INIT_R
 	select SYS_CACHE_SHIFT_6
+	select SUPPORT_SPL
 	imply CPU
 	imply CPU_RISCV
 	imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +4 -0
index 5c8789efddb..ef63b43f69f 100644
@@ -11,3 +11,7 @@
 		reg = <0x00000000 0x00000000 0x00000000 0x80000000>;
 	};
 };
+
+&uart0 {
+	bootph-pre-ram;
+};
board/spacemit/k1/Makefile +2 -0
index 2168698402b..f9cbf4b0e06 100644
@@ -1,5 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 #
 # Copyright (c) 2024, Kongyang Liu <[email protected]>
+# Copyright (c) 2025-2026, RISCstar Ltd.
 
 obj-y := board.o
+obj-$(CONFIG_SPL_BUILD) += spl.o
board/spacemit/k1/spl.c new file +24 -0
new file mode 100644
index 00000000000..e15cf5f1abf
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025-2026, RISCstar Ltd.
+ */
+
+#include <spl.h>
+
+void board_init_f(ulong dummy)
+{
+	int ret;
+
+	ret = spl_early_init();
+	if (ret)
+		panic("spl_early_init() failed:%d\n", ret);
+
+	riscv_cpu_setup();
+
+	preloader_console_init();
+}
+
+u32 spl_boot_device(void)
+{
+	return BOOT_DEVICE_NONE;
+}
configs/spacemit_k1_defconfig +16 -0
index fae561bbf8a..29050ece278 100644
@@ -4,17 +4,30 @@ CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000
 CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-bananapi-f3"
+CONFIG_SPL_STACK=0xc083fb00
+CONFIG_SPL_TEXT_BASE=0xc0801000
+CONFIG_SPL_BSS_START_ADDR=0xc083fc00
+CONFIG_SPL_BSS_MAX_SIZE=0x400
 CONFIG_SYS_BOOTM_LEN=0xa000000
 CONFIG_SYS_LOAD_ADDR=0x200000
+CONFIG_SPL_SIZE_LIMIT=0x31000
+CONFIG_SPL=y
+CONFIG_DEBUG_UART_BASE=0xd4017000
+CONFIG_DEBUG_UART_CLOCK=14700000
 CONFIG_TARGET_SPACEMIT_K1=y
 CONFIG_ARCH_RV64I=y
 CONFIG_RISCV_SMODE=y
+CONFIG_STACK_SIZE=0x100000
 CONFIG_FIT=y
+CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 # CONFIG_BOARD_INIT is not set
+CONFIG_SPL_MAX_SIZE=0x33000
+# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
+CONFIG_SPL_HAVE_INIT_STACK=y
 CONFIG_HUSH_PARSER=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
@@ -22,5 +35,8 @@ CONFIG_CLK_SPACEMIT=y
 CONFIG_CLK_SPACEMIT_K1=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
+CONFIG_DEBUG_UART_NS16550=y
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
include/configs/k1.h +4 -2
index 97cf4d72df0..15a40f2128f 100644
@@ -1,13 +1,15 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 /*
  * Copyright (c) 2024, Kongyang Liu <[email protected]>
+ * Copyright (C) 2025-2026, RISCstar Ltd.
  *
  */
 
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CFG_SYS_SDRAM_BASE         0x0
-#define CFG_SYS_NS16550_IER        0x40 /* UART Unit Enable */
+#define CFG_SYS_NS16550_CLK	    14700000
+#define CFG_SYS_NS16550_IER	    0x40 /* UART Unit Enable */
+#define CFG_SYS_SDRAM_BASE	    0x0
 
 #endif /* __CONFIG_H */
Signature · 1 line
2.51.0
author
#3 lore raw

PATCH v5 3/14 configs: k1: enable early timer support

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Enable CONFIG_TIMER_EARLY to allow udelay() calls during early initialization phases. This is required for proper timing operations before the full timer driver is available.

---
 configs/spacemit_k1_defconfig | 6 +++++-
 include/configs/k1.h          | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)
configs/spacemit_k1_defconfig +5 -1
index 29050ece278..fd0d228992a 100644
@@ -17,9 +17,10 @@ CONFIG_DEBUG_UART_CLOCK=14700000
 CONFIG_TARGET_SPACEMIT_K1=y
 CONFIG_ARCH_RV64I=y
 CONFIG_RISCV_SMODE=y
+CONFIG_SPL_RISCV_MMODE=y
+# CONFIG_SPL_SMP is not set
 CONFIG_STACK_SIZE=0x100000
 CONFIG_FIT=y
-CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_SYS_CBSIZE=256
@@ -31,6 +32,8 @@ CONFIG_SPL_HAVE_INIT_STACK=y
 CONFIG_HUSH_PARSER=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SPL_SYSCON=y
 CONFIG_CLK_SPACEMIT=y
 CONFIG_CLK_SPACEMIT_K1=y
 CONFIG_PINCTRL=y
@@ -40,3 +43,4 @@ CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
+CONFIG_TIMER_EARLY=y
include/configs/k1.h +5 -0
index 15a40f2128f..e09c3594905 100644
@@ -12,4 +12,9 @@
 #define CFG_SYS_NS16550_IER	    0x40 /* UART Unit Enable */
 #define CFG_SYS_SDRAM_BASE	    0x0
 
+#define RISCV_MMODE_TIMERBASE	    0xe4000000
+#define RISCV_MMODE_TIMEROFF	    0xbff8
+#define RISCV_MMODE_TIMER_FREQ	    24000000
+#define RISCV_SMODE_TIMER_FREQ	    24000000
+
 #endif /* __CONFIG_H */
Signature · 1 line
2.51.0
author
#4 lore raw

PATCH v5 4/14 clk: spacemit: k1: prune SPL clock tree

In reply to Eric Chung

From: Guodong Xu <[email protected]>

K1 SPL runs from on-chip SRAM with a small pre-relocation malloc heap. Registering the full K1 clock tree would not fit, so split the tree on
CONFIG_SPL_BUILD: the SPL build registers only the subset SPL needs (currently UART, SDHCI, I2C (TWSI), and their PLL/MPMU/APMU/APBC ancestors); the non-SPL build keeps the full tree.

Where surviving SPL CCU definitions reference parent clocks outside that subset, use "clock-dummy", so framework parent lookups still resolve.

---
 drivers/clk/spacemit/clk-k1.c | 128 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
drivers/clk/spacemit/clk-k1.c +128 -0
index 6175cf09500..07adc126ee3 100644
@@ -44,6 +44,18 @@ static const struct ccu_pll_rate_tbl pll1_rate_tbl[] = {
 	CCU_PLL_RATE(2457600000UL, 0x0050dd64, 0x330ccccd),
 };
 
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+CCU_PLL_DEFINE(CLK_PLL1, pll1, pll1, "clock-24m", pll1_rate_tbl,
+	       APBS_PLL1_SWCR1, APBS_PLL1_SWCR3, MPMU_POSR, POSR_PLL1_LOCK,
+	       CLK_SET_RATE_GATE);
+
+CCU_FACTOR_GATE_DEFINE(CLK_PLL1_D4, pll1_d4, pll1_d4, "pll1", APBS_PLL1_SWCR2,
+		       BIT(3), 4, 1);
+CCU_FACTOR_GATE_DEFINE(CLK_PLL1_D6, pll1_d6, pll1_d6, "pll1", APBS_PLL1_SWCR2,
+		       BIT(5), 6, 1);
+CCU_FACTOR_GATE_FLAGS_DEFINE(CLK_PLL1_D8, pll1_d8, pll1_d8, "pll1",
+			     APBS_PLL1_SWCR2, BIT(7), 8, 1, CLK_IS_CRITICAL);
+#else
 static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = {
 	CCU_PLL_RATE(3000000000UL, 0x0050dd66, 0x3fe00000),
 };
@@ -131,9 +143,23 @@ CCU_FACTOR_GATE_DEFINE(CLK_PLL3_D8, pll3_d8, pll3_d8, "pll3", APBS_PLL3_SWCR2,
 CCU_FACTOR_DEFINE(CLK_PLL3_20, pll3_20, pll3_20, "pll3_d8", 20, 1);
 CCU_FACTOR_DEFINE(CLK_PLL3_40, pll3_40, pll3_40, "pll3_d8", 10, 1);
 CCU_FACTOR_DEFINE(CLK_PLL3_80, pll3_80, pll3_80, "pll3_d8", 5, 1);
+#endif
 /* APBS clocks end */
 
 /* MPMU clocks start */
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+CCU_GATE_DEFINE(CLK_PLL1_614, pll1_d4_614p4, pll1_d4_614p4, "pll1_d4",
+		MPMU_ACGR, BIT(15), 0);
+CCU_GATE_DEFINE(CLK_PLL1_409P6, pll1_d6_409p6, pll1_d6_409p6, "pll1_d6",
+		MPMU_ACGR, BIT(0), 0);
+CCU_GATE_DEFINE(CLK_PLL1_307P2, pll1_d8_307p2, pll1_d8_307p2, "pll1_d8",
+		MPMU_ACGR, BIT(13), 0);
+CCU_FACTOR_GATE_DEFINE(CLK_PLL1_31P5, pll1_d78_31p5, pll1_d78_31p5,
+		       "pll1_d4", MPMU_ACGR, BIT(6), 39, 2);
+CCU_DDN_DEFINE(CLK_SLOW_UART2, slow_uart2_48, slow_uart2_48,
+	       "pll1_d4_614p4", MPMU_SUCCR_1,
+	       CCU_DDN_MASK(16, 13), 16, CCU_DDN_MASK(0, 13), 0, 2, 0);
+#else
 CCU_GATE_DEFINE(CLK_PLL1_307P2, pll1_d8_307p2, pll1_d8_307p2, "pll1_d8",
 		MPMU_ACGR, BIT(13), 0);
 
@@ -251,9 +277,37 @@ CCU_GATE_DEFINE(CLK_WDT_BUS, wdt_bus_clk, wdt_bus_clk, "apb_clk", MPMU_WDTPCR,
 		BIT(0), 0);
 
 CCU_GATE_DEFINE(CLK_RIPC, ripc_clk, ripc_clk, "apb_clk", MPMU_RIPCCR, 0x1, 0);
+#endif
 /* MPMU clocks end */
 
 /* APBC clocks start */
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+static const char * const uart_clk_parents[] = {
+	"clock-dummy",
+	"clock-dummy",
+	"slow_uart2_48",
+};
+
+CCU_MUX_GATE_DEFINE(CLK_UART0, uart0_clk, uart0_clk, uart_clk_parents,
+		    ARRAY_SIZE(uart_clk_parents), APBC_UART1_CLK_RST,
+		    4, 3, BIT(1) | BIT(0), 0);
+
+static const char * const twsi_parents[] = {
+	"pll1_d78_31p5",
+};
+
+CCU_MUX_GATE_DEFINE(CLK_TWSI2, twsi2_clk, twsi2_clk, twsi_parents,
+		    ARRAY_SIZE(twsi_parents), APBC_TWSI2_CLK_RST,
+		    4, 3, BIT(1) | BIT(0), 0);
+/*
+ * APBC_TWSI8_CLK_RST has a quirk that reading always results in zero.
+ * Combine functional and bus bits together as a gate to avoid sharing the
+ * write-only register between different clock hardwares.
+ */
+CCU_GATE_DEFINE(CLK_TWSI8, twsi8_clk, twsi8_clk, "pll1_d78_31p5",
+		APBC_TWSI8_CLK_RST, BIT(1) | BIT(0), 0);
+
+#else
 static const char * const uart_clk_parents[] = {
 	"pll1_m3d128_57p6",
 	"slow_uart1_14p74",
@@ -598,9 +652,44 @@ 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
 /* APBC clocks end */
 
 /* APMU clocks start */
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+static const char * const pmua_aclk_parents[] = {
+	"clock-dummy",
+	"pll1_d8_307p2",
+};
+
+CCU_MUX_DIV_FC_DEFINE(CLK_PMUA_ACLK, pmua_aclk, pmua_aclk, pmua_aclk_parents,
+		      ARRAY_SIZE(pmua_aclk_parents),
+		      APMU_ACLK_CLK_CTRL, APMU_ACLK_CLK_CTRL, 1, 2, BIT(4),
+		      0, 1, 0);
+
+CCU_GATE_DEFINE(CLK_SDH_AXI, sdh_axi_aclk, sdh_axi_aclk, "pmua_aclk",
+		APMU_SDH0_CLK_RES_CTRL, BIT(3), 0);
+
+static const char * const sdh01_parents[] = {
+	"pll1_d6_409p6",
+};
+
+CCU_MUX_DIV_GATE_SPLIT_FC_DEFINE(CLK_SDH0, sdh0_clk, sdh0_clk, sdh01_parents,
+				 ARRAY_SIZE(sdh01_parents),
+				 APMU_SDH0_CLK_RES_CTRL,
+				 APMU_SDH0_CLK_RES_CTRL, 8, 3, BIT(11), 5, 3,
+				 BIT(4), 0);
+
+static const char * const sdh2_parents[] = {
+	"pll1_d6_409p6",
+};
+
+CCU_MUX_DIV_GATE_SPLIT_FC_DEFINE(CLK_SDH2, sdh2_clk, sdh2_clk, sdh2_parents,
+				 ARRAY_SIZE(sdh2_parents),
+				 APMU_SDH2_CLK_RES_CTRL,
+				 APMU_SDH2_CLK_RES_CTRL, 8, 3, BIT(11), 5, 3,
+				 BIT(4), 0);
+#else
 static const char * const pmua_aclk_parents[] = {
 	"pll1_d10_245p76",
 	"pll1_d8_307p2",
@@ -1082,8 +1171,17 @@ CCU_GATE_DEFINE(CLK_EMAC1_BUS, emac1_bus_clk, emac1_bus_clk, "pmua_aclk",
 CCU_GATE_DEFINE(CLK_EMAC1_PTP, emac1_ptp_clk, emac1_ptp_clk, "pll2_d6",
 		APMU_EMAC1_CLK_RES_CTRL, BIT(15), 0);
 
+#endif
 /* APMU clocks end */
 
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+static struct clk *k1_ccu_pll_clks[] = {
+	&pll1.common.clk,
+	&pll1_d4.common.clk,
+	&pll1_d6.common.clk,
+	&pll1_d8.common.clk,
+};
+#else
 static struct clk *k1_ccu_pll_clks[] = {
 	&pll1.common.clk,
 	&pll2.common.clk,
@@ -1121,6 +1219,7 @@ static struct clk *k1_ccu_pll_clks[] = {
 	&pll3_40.common.clk,
 	&pll3_20.common.clk,
 };
+#endif
 
 static const struct spacemit_ccu_data k1_ccu_pll_data = {
 	.clks		= k1_ccu_pll_clks,
@@ -1128,6 +1227,15 @@ static const struct spacemit_ccu_data k1_ccu_pll_data = {
 	.offset		= K1_PLL_ID,
 };
 
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+static struct clk *k1_ccu_mpmu_clks[] = {
+	&pll1_d4_614p4.common.clk,
+	&pll1_d6_409p6.common.clk,
+	&pll1_d8_307p2.common.clk,
+	&pll1_d78_31p5.common.clk,
+	&slow_uart2_48.common.clk,
+};
+#else
 static struct clk *k1_ccu_mpmu_clks[] = {
 	&pll1_d8_307p2.common.clk,
 	&pll1_d32_76p8.common.clk,
@@ -1167,6 +1275,7 @@ static struct clk *k1_ccu_mpmu_clks[] = {
 	&i2s_bclk.common.clk,
 	&wdt_bus_clk.common.clk,
 };
+#endif
 
 static const struct spacemit_ccu_data k1_ccu_mpmu_data = {
 	.clks		= k1_ccu_mpmu_clks,
@@ -1174,6 +1283,13 @@ static const struct spacemit_ccu_data k1_ccu_mpmu_data = {
 	.offset		= K1_MPMU_ID,
 };
 
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+static struct clk *k1_ccu_apbc_clks[] = {
+	&uart0_clk.common.clk,
+	&twsi2_clk.common.clk,
+	&twsi8_clk.common.clk,
+};
+#else
 static struct clk *k1_ccu_apbc_clks[] = {
 	&uart0_clk.common.clk,
 	&uart2_clk.common.clk,
@@ -1278,6 +1394,7 @@ static struct clk *k1_ccu_apbc_clks[] = {
 	&sspa0_i2s_bclk.common.clk,
 	&sspa1_i2s_bclk.common.clk,
 };
+#endif
 
 static const struct spacemit_ccu_data k1_ccu_apbc_data = {
 	.clks		= k1_ccu_apbc_clks,
@@ -1285,6 +1402,14 @@ static const struct spacemit_ccu_data k1_ccu_apbc_data = {
 	.offset		= K1_APBC_ID,
 };
 
+#if IS_ENABLED(CONFIG_SPL_BUILD)
+static struct clk *k1_ccu_apmu_clks[] = {
+	&pmua_aclk.common.clk,
+	&sdh_axi_aclk.common.clk,
+	&sdh0_clk.common.clk,
+	&sdh2_clk.common.clk,
+};
+#else
 static struct clk *k1_ccu_apmu_clks[] = {
 	&cci550_clk.common.clk,
 	&cpu_c0_hi_clk.common.clk,
@@ -1349,6 +1474,7 @@ static struct clk *k1_ccu_apmu_clks[] = {
 	&v2d_clk.common.clk,
 	&emmc_bus_clk.common.clk,
 };
+#endif
 
 static int clk_k1_enable(struct clk *clk)
 {
@@ -1473,6 +1599,8 @@ static int k1_pll_clk_probe(struct udevice *dev)
 	const struct spacemit_ccu_data *data;
 	int ret;
 
+	clk_register_fixed_rate(NULL, "clock-dummy", 0);
+
 	ret = regmap_init_mem(dev_ofnode(dev), &base_regmap);
 	if (ret)
 		return ret;
Signature · 1 line
2.51.0
author
#5 lore raw

PATCH v5 5/14 configs: k1: add default option for clock driver in SPL

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Add default option for enabling clock driver in SPL.

---
 configs/spacemit_k1_defconfig | 6 ++++++
 1 file changed, 6 insertions(+)
configs/spacemit_k1_defconfig +6 -0
index fd0d228992a..23019266103 100644
@@ -1,9 +1,11 @@
 CONFIG_RISCV=y
 CONFIG_SYS_MALLOC_LEN=0x1000000
+CONFIG_SYS_MALLOC_F_LEN=0x5000
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000
 CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-bananapi-f3"
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000
 CONFIG_SPL_STACK=0xc083fb00
 CONFIG_SPL_TEXT_BASE=0xc0801000
 CONFIG_SPL_BSS_START_ADDR=0xc083fc00
@@ -29,11 +31,14 @@ CONFIG_SYS_PBSIZE=276
 CONFIG_SPL_MAX_SIZE=0x33000
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_HAVE_INIT_STACK=y
+CONFIG_SPL_DM_RESET=y
 CONFIG_HUSH_PARSER=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
+CONFIG_SPL_CLK=y
+CONFIG_SPL_CLK_CCF=y
 CONFIG_CLK_SPACEMIT=y
 CONFIG_CLK_SPACEMIT_K1=y
 CONFIG_PINCTRL=y
@@ -44,3 +49,4 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_TIMER_EARLY=y
+CONFIG_SPL_LIB_RATIONAL=y
Signature · 1 line
2.51.0
author
#6 lore raw

PATCH v5 6/14 dts: k1: enable clocks in SPL

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Make the K1 clock controllers visible to SPL by tagging the four root fixed clocks (osc_32k, vctcxo_{1,3,24}m) and the four syscon nodes (mpmu, pll, apmu, apbc) with bootph-pre-ram in the BPI-F3 U-Boot overlay.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +32 -0
index ef63b43f69f..e140c07b834 100644
@@ -15,3 +15,35 @@
 &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;
+};
Signature · 1 line
2.51.0
author
#7 lore raw

PATCH v5 7/14 board: k1: initialize clock and serial devices in SPL

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Initialize clock and serial devices in SPL. Otherwise, the device driver won't be loaded in SPL.

---
 board/spacemit/k1/spl.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
board/spacemit/k1/spl.c +39 -0
index e15cf5f1abf..78f26616347 100644
@@ -3,8 +3,45 @@
  * Copyright (c) 2025-2026, RISCstar Ltd.
  */
 
+#include <dm/device.h>
+#include <dm/uclass.h>
+#include <log.h>
 #include <spl.h>
 
+static void clk_early_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device_by_name(UCLASS_CLK, "clock-controller@d4090000", &dev);
+	if (ret)
+		panic("Fail to detect clock-controller@d4090000\n");
+	ret = uclass_get_device_by_name(UCLASS_CLK, "system-controller@d4050000", &dev);
+	if (ret)
+		panic("Fail to detect system-controller@d4050000\n");
+	ret = uclass_get_device_by_name(UCLASS_CLK, "system-controller@d4282800", &dev);
+	if (ret)
+		panic("Fail to detect system-controller@d4282800\n");
+	ret = uclass_get_device_by_name(UCLASS_CLK, "system-controller@d4015000", &dev);
+	if (ret)
+		panic("Fail to detect system-controller@d4015000\n");
+
+	if (device_active(dev))
+		log_debug("clk: device is active\n");
+	else
+		log_debug("clk: device not active, probing...\n");
+}
+
+void serial_early_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device(UCLASS_SERIAL, 0, &dev);
+	if (ret)
+		panic("Serial uclass init failed: %d\n", ret);
+}
+
 void board_init_f(ulong dummy)
 {
 	int ret;
@@ -15,6 +52,8 @@ void board_init_f(ulong dummy)
 
 	riscv_cpu_setup();
 
+	clk_early_init();
+	serial_early_init();
 	preloader_console_init();
 }
 
Signature · 1 line
2.51.0
author
#8 lore raw

PATCH v5 8/14 i2c: k1: add I2C driver support

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Add I2C driver support on Spacemit K1 SoC using driver model.

---
 drivers/i2c/Kconfig  |   7 +
 drivers/i2c/Makefile |   1 +
 drivers/i2c/k1_i2c.c | 523 +++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/k1_i2c.h |  69 +++++++
 4 files changed, 600 insertions(+)
drivers/i2c/Kconfig +7 -0
index ab5af17858c..bc43112f877 100644
@@ -797,6 +797,13 @@ config SYS_I2C_IHS
 	help
 	  Support for gdsys IHS I2C driver on FPGA bus.
 
+config SYS_I2C_SPACEMIT_K1
+	bool "Spacemit K1 I2C driver"
+	depends on DM_I2C
+	help
+	  Support for Spacemit I2C controller. It's based on
+	  Driver Model.
+
 source "drivers/i2c/muxes/Kconfig"
 
 endif
drivers/i2c/Makefile +1 -0
index 2da649e97d3..0e3a0f9fb5f 100644
@@ -47,6 +47,7 @@ obj-$(CONFIG_SYS_I2C_RZ_RIIC) += rz_riic.o
 obj-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o exynos_hs_i2c.o
 obj-$(CONFIG_SYS_I2C_SANDBOX) += sandbox_i2c.o i2c-emul-uclass.o
 obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o
+obj-$(CONFIG_SYS_I2C_SPACEMIT_K1) += k1_i2c.o
 obj-$(CONFIG_SYS_I2C_STM32F7) += stm32f7_i2c.o
 obj-$(CONFIG_SYS_I2C_SUN6I_P2WI) += sun6i_p2wi.o
 obj-$(CONFIG_SYS_I2C_SUN8I_RSB) += sun8i_rsb.o
drivers/i2c/k1_i2c.c new file +523 -0

523 lines not on this page · raw message

drivers/i2c/k1_i2c.h new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#9 lore raw

PATCH v5 9/14 spacemit: k1: add TLV EEPROM support in SPL

In reply to Eric Chung

From: Raymond Mao <[email protected]>

And support for required components including clock, I2C controller, and I2C EEPROM.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi |  9 +++
 board/spacemit/k1/spl.c                   | 93 ++++++++++++++++++++++++++++++-
 board/spacemit/k1/tlv_codes.h             | 22 ++++++++
 configs/spacemit_k1_defconfig             |  8 +++
 4 files changed, 131 insertions(+), 1 deletion(-)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +9 -0
index e140c07b834..231e98d206a 100644
@@ -47,3 +47,12 @@
 &syscon_apbc {
 	bootph-pre-ram;
 };
+
+&i2c2 {
+	bootph-pre-ram;
+	resets = <&syscon_apbc RESET_TWSI2>;
+
+	eeprom@50 {
+		bootph-pre-ram;
+	};
+};
board/spacemit/k1/spl.c +92 -1

118 lines not on this page · raw message

board/spacemit/k1/tlv_codes.h new file +22 -0
new file mode 100644
index 00000000000..e40fbdcee6d
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2025-2026 RISCstar Ltd.
+ */
+
+#ifndef __TLV_CODES_H
+#define __TLV_CODES_H
+
+#define TLV_CODE_SDK_VERSION		0x40
+#define TLV_CODE_DDR_CSNUM		0x41
+#define TLV_CODE_DDR_TYPE		0x42
+#define TLV_CODE_DDR_DATARATE		0x43
+#define TLV_CODE_DDR_TX_ODT		0x44
+
+#define TLV_CODE_WIFI_MAC_ADDR		0x60
+#define TLV_CODE_BLUETOOTH_ADDR		0x61
+
+#define TLV_CODE_PMIC_TYPE		0x80
+#define TLV_CODE_EEPROM_I2C_INDEX	0x81
+#define TLV_CODE_EEPROM_PIN_GROUP	0x82
+
+#endif /* __TLV_CODES_H */
configs/spacemit_k1_defconfig +8 -0
index 23019266103..ce0314686ab 100644
@@ -31,8 +31,11 @@ CONFIG_SYS_PBSIZE=276
 CONFIG_SPL_MAX_SIZE=0x33000
 # CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
 CONFIG_SPL_HAVE_INIT_STACK=y
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_HUSH_PARSER=y
+CONFIG_CMD_TLV_EEPROM=y
+CONFIG_SPL_CMD_TLV_EEPROM=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SPL_REGMAP=y
@@ -41,6 +44,11 @@ CONFIG_SPL_CLK=y
 CONFIG_SPL_CLK_CCF=y
 CONFIG_CLK_SPACEMIT=y
 CONFIG_CLK_SPACEMIT_K1=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_SPACEMIT_K1=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SPL_I2C_EEPROM=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_DEBUG_UART_NS16550=y
Signature · 1 line
2.51.0
author
#10 lore raw

PATCH v5 10/14 spacemit: k1: Add DDR firmware support to SPL

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Include DDR initialization firmware in the SPL image. The firmware path can be specified via the DDR_FW_FILE environment variable. If the firmware is not found, an empty placeholder file is created to allow the build to proceed without DDR initialization support.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi |  23 ++++++
 board/spacemit/k1/Makefile                |  21 +++++
 board/spacemit/k1/spl.c                   | 127 ++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +23 -0
index 231e98d206a..b97bea7fd32 100644
@@ -56,3 +56,26 @@
 		bootph-pre-ram;
 	};
 };
+
+&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>;
+		};
+	};
+};
board/spacemit/k1/Makefile +21 -0
index f9cbf4b0e06..a57af2e1f08 100644
@@ -5,3 +5,24 @@
 
 obj-y := board.o
 obj-$(CONFIG_SPL_BUILD) += spl.o
+
+DDR_FW_SRC ?= $(DDR_FW_FILE)
+FW_TARGET = $(objtree)/ddr_fw.bin
+
+$(obj)/spl.o: $(FW_TARGET)
+
+$(FW_TARGET): FORCE
+	@if [ -n "$(DDR_FW_SRC)" ] && [ -f "$(DDR_FW_SRC)" ]; then \
+		if ! cmp -s "$(DDR_FW_SRC)" $@ 2>/dev/null; then \
+			echo "  Copying DDR firmware from: $(DDR_FW_SRC)"; \
+			cp "$(DDR_FW_SRC)" $@; \
+		fi; \
+	elif [ -s $@ ]; then \
+		: ; \
+	else \
+		echo "  Note: No DDR firmware found, creating empty placeholder"; \
+		echo "  (Set DDR_FW_FILE to specify firmware location)"; \
+		touch $@; \
+	fi
+
+clean-files += $(FW_TARGET)
board/spacemit/k1/spl.c +127 -0

159 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#11 lore raw

PATCH v5 11/14 power: pmic: add support for Spacemit P1 PMIC

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Spacemit's PMIC is used by Spacemit K1 SoC. It contains voltage regulators, GPIOs and Watchdog.

---
 drivers/power/pmic/Kconfig            |   8 ++
 drivers/power/pmic/Makefile           |   1 +
 drivers/power/pmic/pmic_spacemit_p1.c |  94 ++++++++++++++++++++
 include/power/spacemit_p1.h           | 163 ++++++++++++++++++++++++++++++++++
 4 files changed, 266 insertions(+)
drivers/power/pmic/Kconfig +8 -0
index 4bd9b4e1940..d45869cb30f 100644
@@ -434,6 +434,14 @@ config PMIC_RAA215300
 	  allows register access and will bind the sysreset driver
 	  (CONFIG_SYSRESET_RAA215300) if it is enabled.
 
+config PMIC_SPACEMIT_P1
+	bool "Enable driver for Spacemit P1 power management chip"
+	depends on DM_PMIC
+	help
+	  The P1 PMIC integrates multiple functions including
+	  voltage regulators, a watchdog timer, GPIO interfaces, and a
+	  real-time clock.
+
 config DM_PMIC_MTK_PWRAP
 	bool "Enable driver for MediaTek PMIC Wrapper Support"
 	help
drivers/power/pmic/Makefile +1 -0
index 2cda5a892fd..0ac92084221 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_$(PHASE_)DM_PMIC_TPS80031) += tps80031.o
 obj-$(CONFIG_$(PHASE_)PMIC_PALMAS) += palmas.o
 obj-$(CONFIG_$(PHASE_)PMIC_LP873X) += lp873x.o
 obj-$(CONFIG_$(PHASE_)PMIC_LP87565) += lp87565.o
+obj-$(CONFIG_PMIC_SPACEMIT_P1) += pmic_spacemit_p1.o
 obj-$(CONFIG_PMIC_STPMIC1) += stpmic1.o
 obj-$(CONFIG_PMIC_TPS65217) += pmic_tps65217.o
 obj-$(CONFIG_PMIC_TPS65219) += tps65219.o
drivers/power/pmic/pmic_spacemit_p1.c new file +94 -0

94 lines not on this page · raw message

include/power/spacemit_p1.h new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#12 lore raw

PATCH v5 12/14 power: regulator: add support for Spacemit P1 SoC

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Support voltage regulator for Spacemit P1 SoC. It contains 6 BUCKs and 11 LDOs.

---
 drivers/power/regulator/Kconfig                 |   7 +
 drivers/power/regulator/Makefile                |   1 +
 drivers/power/regulator/spacemit_p1_regulator.c | 464 ++++++++++++++++++++++++
 3 files changed, 472 insertions(+)
drivers/power/regulator/Kconfig +7 -0
index 3b3ed97eb9f..2e564536ec9 100644
@@ -557,3 +557,10 @@ config DM_REGULATOR_MT6359
 	  MediaTek MT6359 PMIC.
 	  This driver supports the control of different power rails of device
 	  through regulator interface.
+
+config DM_REGULATOR_SPACEMIT_P1
+	bool "Enable driver for Spacemit P1 PMIC regulators"
+	depends on DM_REGULATOR && PMIC_SPACEMIT_P1
+	help
+	  Enable implementation of driver-model regulator uclass features
+	  for regulator P1. The driver supports BUCKs, LDOs and SWITCHes.
drivers/power/regulator/Makefile +1 -0
index 36a84e7cd71..308a79f6816 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_$(PHASE_)REGULATOR_RK8XX) += rk8xx.o
 obj-$(CONFIG_DM_REGULATOR_S2MPS11) += s2mps11_regulator.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
 obj-$(CONFIG_DM_REGULATOR_SANDBOX) += sandbox.o
+obj-$(CONFIG_DM_REGULATOR_SPACEMIT_P1) += spacemit_p1_regulator.o
 obj-$(CONFIG_REGULATOR_TPS65090) += tps65090_regulator.o
 obj-$(CONFIG_$(PHASE_)DM_REGULATOR_PALMAS) += palmas_regulator.o
 obj-$(CONFIG_$(PHASE_)DM_REGULATOR_PBIAS) += pbias_regulator.o
drivers/power/regulator/spacemit_p1_regulator.c new file +464 -0

464 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#13 lore raw

PATCH v5 13/14 board: k1: enable pmic in spl

In reply to Eric Chung

From: Raymond Mao <[email protected]>

Add Spacemit P1 SoC support in SPL. And set the default voltage for BUCKs and LDOs.

Also update MAINTAINERS: add Guodong Xu as co-maintainer, list the u-boot-spacemit mailing list, register the new K1 driver files (i2c, PMIC, regulator), and fix a pre-existing '@@' typo in Huan Zhou's email.

Fixes 1cd239f44438 ("riscv: spacemit: bananapi_f3: initial support added")
---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 32 ++++++++++++
 board/spacemit/k1/MAINTAINERS             |  7 ++-
 board/spacemit/k1/spl.c                   | 84 +++++++++++++++++++++++++++----
 configs/spacemit_k1_defconfig             |  6 +++
 4 files changed, 117 insertions(+), 12 deletions(-)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +32 -0
index b97bea7fd32..7f9443d6951 100644
@@ -57,6 +57,38 @@
 	};
 };
 
+/*
+ * 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;
+	resets = <&syscon_apbc RESET_TWSI8>;
+
+	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;
+			};
+		};
+	};
+};
+
 &binman {
 	u-boot-spl-ddr {
 		type = "section";
board/spacemit/k1/MAINTAINERS +6 -1
index b256cbe7978..8976c575dff 100644
@@ -1,6 +1,11 @@
 BananaPi F3
-M:	Huan Zhou <pericycle.cc@@gmail.com>
+M:	Huan Zhou <[email protected]>
+M:	Guodong Xu <[email protected]>
+L:	[email protected]
 S:	Maintained
 F:	board/spacemit/k1/
 F:	configs/spacemit_k1_defconfig
 F:	doc/board/spacemit/bananapi-f3.rst
+F:	drivers/i2c/k1_i2c.c
+F:	drivers/power/pmic/pmic_spacemit_p1.c
+F:	drivers/power/regulator/spacemit_p1_regulator.c
board/spacemit/k1/spl.c +73 -11

108 lines not on this page · raw message

configs/spacemit_k1_defconfig +6 -0
index ce0314686ab..e71c079bef2 100644
@@ -33,6 +33,7 @@ CONFIG_SPL_MAX_SIZE=0x33000
 CONFIG_SPL_HAVE_INIT_STACK=y
 CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_POWER=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_TLV_EEPROM=y
 CONFIG_SPL_CMD_TLV_EEPROM=y
@@ -51,6 +52,11 @@ CONFIG_I2C_EEPROM=y
 CONFIG_SPL_I2C_EEPROM=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_SINGLE=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_SPACEMIT_P1=y
+CONFIG_DM_REGULATOR=y
+CONFIG_SPL_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_SPACEMIT_P1=y
 CONFIG_DEBUG_UART_NS16550=y
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_DEBUG_UART_ANNOUNCE=y
Signature · 1 line
2.51.0
author
#14 lore raw

PATCH v5 14/14 doc: spacemit: add K1 SPL build and test guide

In reply to Eric Chung

From: Guodong Xu <[email protected]>

The K1 SPL patchset requires DDR firmware integration and FSBL signing steps that are not covered by existing documentation. Add a SoC-level guide so reviewers and developers can build and test on hardware.

---
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-spl.rst | 243 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 244 insertions(+)
doc/board/spacemit/index.rst +1 -0
index e7d3d94e459..a5e35ee12ab 100644
@@ -6,4 +6,5 @@ SpacemiT
    :maxdepth: 1
 
    bananapi-f3
+   k1-spl
 
doc/board/spacemit/k1-spl.rst new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
2.51.0