Add board support for Spacemit K1 SoC in SPL
Subsystems (6)
v3 cover Add board support for Spacemit K1 SoC in SPL
From: Raymond Mao <[email protected]>
This series adds SPL support for the SpacemiT K1 SoC, enabling boot on K1-based boards such as the BananaPi F3.
To verify, please refer to the doc patch "doc: spacemit: add K1 SPL build and test guide" [1], which is still valid and suggest to be included to riscv/next.
[1] https://lore.kernel.org/u-boot/[email protected]/
Changes in v3:
- Merge CONFIG_ARCH_K1 and CONFIG_TARGET_BANANAPI_F3 into CONFIG_TARGET_SPACEMIT_K1. This configuration should be used for all boards with Spacemit K1 SoC.
- Remove CONFIG_SPL_RESET_SPACEMIT_K1, CONFIG_SPL_CLK_SPACEMIT_K1, CONFIG_SPL_PMIC_SPACEMIT_P1, CONFIG_SPL_DM_REGULATOR_SPACEMIT_P1. Since they're redundant for SPL stage.
- Fix the calculation on clock ID. While the clock driver is initialized in uboot stage, it'll be run twice. Without the protection, it'll cause panic in the second time.
Change in v2:
- Use read_poll_timeout() in k1 i2c driver.
- Abandon to parse offset and size from Kconfig & Makefile for binman.
- Abandon to attach firmware image into the patch set.
- Update the related document and some minor changes.
Junhui Liu (1):
clk: spacemit: Add support for K1 SoC
Raymond Mao (15):
spacemit: k1: support multi-board infrastructure
spacemit: k1: enable SPL with debug UART
configs: k1: enable early timer support
reset: k1: remove TWSI8 reset restriction
dt-bindings: clock: import k1-syscon from upstream
dts: k1: import dts file from upstream folder
dts: k1: enable clocks in SPL
board: k1: initialize clock and serial devices in SPL
configs: k1: add default option for clock driver 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/Makefile | 2 +-
arch/riscv/dts/k1-spl.dts | 228 +++
arch/riscv/dts/k1.dtsi | 666 +++++-
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 | 27 +
board/spacemit/{bananapi-f3 => k1}/board.c | 0
board/spacemit/k1/spl.c | 347 ++++
board/spacemit/k1/tlv_codes.h | 22 +
configs/bananapi-f3_defconfig | 24 -
configs/spacemit_k1_defconfig | 76 +
doc/board/spacemit/bananapi-f3.rst | 2 +-
drivers/clk/Kconfig | 5 +-
drivers/clk/Makefile | 1 +
drivers/clk/spacemit/Kconfig | 22 +
drivers/clk/spacemit/Makefile | 7 +
drivers/clk/spacemit/clk-k1.c | 1798 +++++++++++++++++
drivers/clk/spacemit/clk_common.h | 79 +
drivers/clk/spacemit/clk_ddn.c | 93 +
drivers/clk/spacemit/clk_ddn.h | 53 +
drivers/clk/spacemit/clk_mix.c | 403 ++++
drivers/clk/spacemit/clk_mix.h | 224 ++
drivers/clk/spacemit/clk_pll.c | 157 ++
drivers/clk/spacemit/clk_pll.h | 81 +
drivers/i2c/Kconfig | 7 +
drivers/i2c/Makefile | 1 +
drivers/i2c/k1_i2c.c | 516 +++++
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 | 8 +
drivers/power/regulator/Makefile | 1 +
.../power/regulator/spacemit_p1_regulator.c | 460 +++++
drivers/reset/reset-spacemit-k1.c | 4 -
include/configs/bananapi-f3.h | 13 -
include/configs/k1.h | 19 +
.../dt-bindings/clock/spacemit,k1-syscon.h | 253 +++
include/power/spacemit_p1.h | 163 ++
include/soc/spacemit/k1-syscon.h | 149 ++
44 files changed, 5960 insertions(+), 165 deletions(-)
create mode 100644 arch/riscv/dts/k1-spl.dts
delete mode 100644 board/spacemit/bananapi-f3/MAINTAINERS
delete mode 100644 board/spacemit/bananapi-f3/Makefile
rename board/spacemit/{bananapi-f3 => k1}/Kconfig (79%)
create mode 100644 board/spacemit/k1/MAINTAINERS
create mode 100644 board/spacemit/k1/Makefile
rename board/spacemit/{bananapi-f3 => k1}/board.c (100%)
create mode 100644 board/spacemit/k1/spl.c
create mode 100644 board/spacemit/k1/tlv_codes.h
delete mode 100644 configs/bananapi-f3_defconfig
create mode 100644 configs/spacemit_k1_defconfig
create mode 100644 drivers/clk/spacemit/Kconfig
create mode 100644 drivers/clk/spacemit/Makefile
create mode 100644 drivers/clk/spacemit/clk-k1.c
create mode 100644 drivers/clk/spacemit/clk_common.h
create mode 100644 drivers/clk/spacemit/clk_ddn.c
create mode 100644 drivers/clk/spacemit/clk_ddn.h
create mode 100644 drivers/clk/spacemit/clk_mix.c
create mode 100644 drivers/clk/spacemit/clk_mix.h
create mode 100644 drivers/clk/spacemit/clk_pll.c
create mode 100644 drivers/clk/spacemit/clk_pll.h
create mode 100644 drivers/i2c/k1_i2c.c
create mode 100644 drivers/i2c/k1_i2c.h
create mode 100644 drivers/power/pmic/pmic_spacemit_p1.c
create mode 100644 drivers/power/regulator/spacemit_p1_regulator.c
delete mode 100644 include/configs/bananapi-f3.h
create mode 100644 include/configs/k1.h
create mode 100644 include/dt-bindings/clock/spacemit,k1-syscon.h
create mode 100644 include/power/spacemit_p1.h
create mode 100644 include/soc/spacemit/k1-syscon.hSignature · 1 line
2.25.1
PATCH v3 1/16 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 k1_defconfig.
2. Move all K1 board files to k1 directory.
3. Rename TARGET_BANANAPI_F3 to TARGET_SPACEMIT_K1.
Eliminates the need for board-specific defconfigs while maintaining hardware compatibility.
---
Changes in v3:
- Use flat TARGET_SPACEMIT_K1 to avoid Kconfig recursive dependency caused by merge conflict with b51e59c8b34 ("riscv: Add support for BeagleV-Fire")
arch/riscv/Kconfig | 8 ++++----
arch/riscv/cpu/k1/Kconfig | 4 ++++
arch/riscv/dts/Makefile | 2 +-
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
10 files changed, 16 insertions(+), 12 deletions(-)
rename board/spacemit/{bananapi-f3 => k1}/Kconfig (79%)
rename board/spacemit/{bananapi-f3 => k1}/MAINTAINERS (61%)
rename board/spacemit/{bananapi-f3 => k1}/Makefile (100%)
rename board/spacemit/{bananapi-f3 => k1}/board.c (100%)
rename configs/{bananapi-f3_defconfig => spacemit_k1_defconfig} (95%)
rename include/configs/{bananapi-f3.h => k1.h} (100%)arch/riscv/Kconfig +4 -4
@@ -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
@@ -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
arch/riscv/dts/Makefile +1 -1
@@ -2,7 +2,6 @@ dtb-$(CONFIG_TARGET_ANDES_AE350) += ae350_32.dtb ae350_64.dtb dtb-$(CONFIG_TARGET_ANDES_VOYAGER) += qilai-voyager.dtb -dtb-$(CONFIG_TARGET_BANANAPI_F3) += k1-bananapi-f3.dtb dtb-$(CONFIG_TARGET_K230_CANMV) += k230-canmv.dtb dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb
@@ -10,6 +9,7 @@ dtb-$(CONFIG_TARGET_LICHEERV_NANO) += sg2002-licheerv-nano-b.dtb dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb +dtb-$(CONFIG_TARGET_SPACEMIT_K1) += k1-bananapi-f3.dtb dtb-$(CONFIG_TARGET_XILINX_MBV) += xilinx-mbv32.dtb dtb-$(CONFIG_TARGET_XILINX_MBV) += xilinx-mbv64.dtb dtb-$(CONFIG_TARGET_XILINX_MBV) += xilinx-binman.dtb
board/spacemit/k1/Kconfig renamed from board/spacemit/bananapi-f3/Kconfig +3 -3
@@ -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
@@ -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/k1_defconfig F: doc/board/spacemit/bananapi-f3.rst
board/spacemit/k1/Makefile renamed from board/spacemit/bananapi-f3/Makefile +0 -0
board/spacemit/k1/board.c renamed from board/spacemit/bananapi-f3/board.c +0 -0
configs/spacemit_k1_defconfig renamed from configs/bananapi-f3_defconfig +1 -1
@@ -6,9 +6,9 @@ CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000 CONFIG_DEFAULT_DEVICE_TREE="k1-bananapi-f3" CONFIG_SYS_BOOTM_LEN=0xa000000 CONFIG_SYS_LOAD_ADDR=0x200000 -CONFIG_TARGET_BANANAPI_F3=y CONFIG_ARCH_RV64I=y CONFIG_RISCV_SMODE=y +CONFIG_TARGET_SPACEMIT_K1=y CONFIG_FIT=y CONFIG_SUPPORT_RAW_INITRD=y CONFIG_OF_BOARD_SETUP=y
doc/board/spacemit/bananapi-f3.rst +1 -1
@@ -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
Signature · 1 line
2.25.1
PATCH v3 2/16 spacemit: k1: enable SPL with debug UART
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Add SPL support featuring debug UART output for early boot diagnostics on K1 SoC.
---
Changes in v3:
- Adapt to TARGET_SPACEMIT_K1 Kconfig change in patch 01
arch/riscv/cpu/k1/Kconfig | 2 ++ arch/riscv/dts/Makefile | 2 +- arch/riscv/dts/k1-spl.dts | 25 +++++++++++++++++++++++++ arch/riscv/dts/k1.dtsi | 2 +- board/spacemit/k1/Makefile | 2 ++ board/spacemit/k1/spl.c | 24 ++++++++++++++++++++++++ configs/spacemit_k1_defconfig | 21 ++++++++++++++++++++- include/configs/k1.h | 7 +++++-- 8 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 arch/riscv/dts/k1-spl.dts create mode 100644 board/spacemit/k1/spl.c
arch/riscv/cpu/k1/Kconfig +2 -0
@@ -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/Makefile +1 -1
@@ -9,7 +9,7 @@ dtb-$(CONFIG_TARGET_LICHEERV_NANO) += sg2002-licheerv-nano-b.dtb dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb -dtb-$(CONFIG_TARGET_SPACEMIT_K1) += k1-bananapi-f3.dtb +dtb-$(CONFIG_TARGET_SPACEMIT_K1) += k1-bananapi-f3.dtb k1-spl.dtb dtb-$(CONFIG_TARGET_XILINX_MBV) += xilinx-mbv32.dtb dtb-$(CONFIG_TARGET_XILINX_MBV) += xilinx-mbv64.dtb dtb-$(CONFIG_TARGET_XILINX_MBV) += xilinx-binman.dtb
arch/riscv/dts/k1-spl.dts new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (C) 2023-2026 Spacemit, Inc + * Copyright (C) 2025-2026 RISCstar Ltd. + */ + +/dts-v1/; +#include "k1.dtsi" +#include "binman.dtsi" + +/ { + model = "spacemit k1 spl"; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; + +&soc { + bootph-all; + serial@d4017000 { + status = "okay"; + bootph-pre-ram; + }; +};
arch/riscv/dts/k1.dtsi +1 -1
@@ -318,7 +318,7 @@ }; }; - soc { + soc: soc { compatible = "simple-bus"; interrupt-parent = <&plic>; #address-cells = <2>;
board/spacemit/k1/Makefile +2 -0
@@ -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
@@ -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 +20 -1
@@ -3,7 +3,19 @@ CONFIG_SYS_MALLOC_LEN=0x1000000 CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000 -CONFIG_DEFAULT_DEVICE_TREE="k1-bananapi-f3" +CONFIG_DEFAULT_DEVICE_TREE="k1-spl" +CONFIG_SPL=y +CONFIG_SPL_TEXT_BASE=0xc0801000 +CONFIG_SPL_MAX_SIZE=0x33000 +CONFIG_SPL_BSS_START_ADDR=0xc0837000 +CONFIG_SPL_BSS_MAX_SIZE=0x2000 +# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set +CONFIG_SPL_HAVE_INIT_STACK=y +CONFIG_SPL_STACK=0xc0840000 +CONFIG_SPL_SIZE_LIMIT=0x31000 +CONFIG_SPL_FIT_SIGNATURE=y +CONFIG_SPL_LOAD_FIT_ADDRESS=0x08000000 +CONFIG_STACK_SIZE=0x100000 CONFIG_SYS_BOOTM_LEN=0xa000000 CONFIG_SYS_LOAD_ADDR=0x200000 CONFIG_ARCH_RV64I=y
@@ -22,3 +34,10 @@ CONFIG_PINCTRL_SINGLE=y CONFIG_RESET_SPACEMIT_K1=y CONFIG_SYS_NS16550=y CONFIG_SYS_NS16550_MEM32=y +CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART_BASE=0xd4017000 +CONFIG_DEBUG_UART_CLOCK=14700000 +CONFIG_DEBUG_UART_SHIFT=2 +CONFIG_DEBUG_UART_NS16550=y +CONFIG_DEBUG_UART_ANNOUNCE=y +# CONFIG_DEBUG_SBI_CONSOLE is not set
include/configs/k1.h +5 -2
@@ -1,13 +1,16 @@/* 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_SDRAM_BASE 0x0 + +#define CFG_SYS_NS16550_CLK 14700000 +#define CFG_SYS_NS16550_IER 0x40/* UART Unit Enable */ #endif /* __CONFIG_H */
Signature · 1 line
2.25.1
PATCH v3 3/16 configs: k1: enable early timer support
In reply to Raymond MaoFrom: 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.
---
Changes in v3:
- None.
configs/spacemit_k1_defconfig | 2 ++ include/configs/k1.h | 3 +++ 2 files changed, 5 insertions(+)
configs/spacemit_k1_defconfig +2 -0
@@ -21,6 +21,7 @@ CONFIG_SYS_LOAD_ADDR=0x200000 CONFIG_ARCH_RV64I=y CONFIG_RISCV_SMODE=y CONFIG_TARGET_SPACEMIT_K1=y +CONFIG_SPL_RISCV_SMODE=y CONFIG_FIT=y CONFIG_SUPPORT_RAW_INITRD=y CONFIG_OF_BOARD_SETUP=y
@@ -41,3 +42,4 @@ CONFIG_DEBUG_UART_SHIFT=2 CONFIG_DEBUG_UART_NS16550=y CONFIG_DEBUG_UART_ANNOUNCE=y # CONFIG_DEBUG_SBI_CONSOLE is not set +CONFIG_TIMER_EARLY=y
include/configs/k1.h +3 -0
@@ -13,4 +13,7 @@#define CFG_SYS_NS16550_CLK 14700000#define CFG_SYS_NS16550_IER 0x40/* UART Unit Enable */ +#define RISCV_MMODE_TIMER_FREQ 24000000 +#define RISCV_SMODE_TIMER_FREQ 24000000 +#endif /* __CONFIG_H */
Signature · 1 line
2.25.1
PATCH v3 4/16 reset: k1: remove TWSI8 reset restriction
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Remove TWSI8 (I2C8) reset restriction. Since it's writable, not inaccessible.
---
Changes in v3:
- Drop SPL_RESET_SPACEMIT_K1 Kconfig to fix unmet dependency warning when building without SPL
drivers/reset/reset-spacemit-k1.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/reset/reset-spacemit-k1.c +0 -4
@@ -452,10 +452,6 @@ static int spacemit_reset_update(struct reset_ctl *rst, bool assert)if (rst->id <RESET_UART1 || rst->id >=RESET_NUMBER )return 0 ; -/* can not write to twsi8 */ -if (rst->id ==RESET_TWSI8 ) -return 0 ; -spacemit_reset_set (rst, rst->id, assert);return 0 ; }
Signature · 1 line
2.25.1
PATCH v3 5/16 dt-bindings: clock: import k1-syscon from upstream
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Import spacemit,k1-syscon.h from upstream folder. And remove duplicated reset IDs in it.
---
Changes in v3:
- None.
.../dt-bindings/clock/spacemit,k1-syscon.h | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 include/dt-bindings/clock/spacemit,k1-syscon.h
include/dt-bindings/clock/spacemit,k1-syscon.h new file +253 -0
@@ -0,0 +1,253 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (C) 2024-2025 Haylen Chu <[email protected]> +*/ + +#ifndef _DT_BINDINGS_SPACEMIT_CCU_H_ +#define _DT_BINDINGS_SPACEMIT_CCU_H_ + +/* APBS (PLL) clocks */ +#define CLK_PLL1 0 +#define CLK_PLL2 1 +#define CLK_PLL3 2 +#define CLK_PLL1_D2 3 +#define CLK_PLL1_D3 4 +#define CLK_PLL1_D4 5 +#define CLK_PLL1_D5 6 +#define CLK_PLL1_D6 7 +#define CLK_PLL1_D7 8 +#define CLK_PLL1_D8 9 +#define CLK_PLL1_D11 10 +#define CLK_PLL1_D13 11 +#define CLK_PLL1_D23 12 +#define CLK_PLL1_D64 13 +#define CLK_PLL1_D10_AUD 14 +#define CLK_PLL1_D100_AUD 15 +#define CLK_PLL2_D1 16 +#define CLK_PLL2_D2 17 +#define CLK_PLL2_D3 18 +#define CLK_PLL2_D4 19 +#define CLK_PLL2_D5 20 +#define CLK_PLL2_D6 21 +#define CLK_PLL2_D7 22 +#define CLK_PLL2_D8 23 +#define CLK_PLL3_D1 24 +#define CLK_PLL3_D2 25 +#define CLK_PLL3_D3 26 +#define CLK_PLL3_D4 27 +#define CLK_PLL3_D5 28 +#define CLK_PLL3_D6 29 +#define CLK_PLL3_D7 30 +#define CLK_PLL3_D8 31 +#define CLK_PLL3_80 32 +#define CLK_PLL3_40 33 +#define CLK_PLL3_20 34 + +/* MPMU clocks */ +#define CLK_PLL1_307P2 0 +#define CLK_PLL1_76P8 1 +#define CLK_PLL1_61P44 2 +#define CLK_PLL1_153P6 3 +#define CLK_PLL1_102P4 4 +#define CLK_PLL1_51P2 5 +#define CLK_PLL1_51P2_AP 6 +#define CLK_PLL1_57P6 7 +#define CLK_PLL1_25P6 8 +#define CLK_PLL1_12P8 9 +#define CLK_PLL1_12P8_WDT 10 +#define CLK_PLL1_6P4 11 +#define CLK_PLL1_3P2 12 +#define CLK_PLL1_1P6 13 +#define CLK_PLL1_0P8 14 +#define CLK_PLL1_409P6 15 +#define CLK_PLL1_204P8 16 +#define CLK_PLL1_491 17 +#define CLK_PLL1_245P76 18 +#define CLK_PLL1_614 19 +#define CLK_PLL1_47P26 20 +#define CLK_PLL1_31P5 21 +#define CLK_PLL1_819 22 +#define CLK_PLL1_1228 23 +#define CLK_SLOW_UART 24 +#define CLK_SLOW_UART1 25 +#define CLK_SLOW_UART2 26 +#define CLK_WDT 27 +#define CLK_RIPC 28 +#define CLK_I2S_SYSCLK 29 +#define CLK_I2S_BCLK 30 +#define CLK_APB 31 +#define CLK_WDT_BUS 32 +#define CLK_I2S_153P6 33 +#define CLK_I2S_153P6_BASE 34 +#define CLK_I2S_SYSCLK_SRC 35 +#define CLK_I2S_BCLK_FACTOR 36 + +/* APBC clocks */ +#define CLK_UART0 0 +#define CLK_UART2 1 +#define CLK_UART3 2 +#define CLK_UART4 3 +#define CLK_UART5 4 +#define CLK_UART6 5 +#define CLK_UART7 6 +#define CLK_UART8 7 +#define CLK_UART9 8 +#define CLK_GPIO 9 +#define CLK_PWM0 10 +#define CLK_PWM1 11 +#define CLK_PWM2 12 +#define CLK_PWM3 13 +#define CLK_PWM4 14 +#define CLK_PWM5 15 +#define CLK_PWM6 16 +#define CLK_PWM7 17 +#define CLK_PWM8 18 +#define CLK_PWM9 19 +#define CLK_PWM10 20 +#define CLK_PWM11 21 +#define CLK_PWM12 22 +#define CLK_PWM13 23 +#define CLK_PWM14 24 +#define CLK_PWM15 25 +#define CLK_PWM16 26 +#define CLK_PWM17 27 +#define CLK_PWM18 28 +#define CLK_PWM19 29 +#define CLK_SSP3 30 +#define CLK_RTC 31 +#define CLK_TWSI0 32 +#define CLK_TWSI1 33 +#define CLK_TWSI2 34 +#define CLK_TWSI4 35 +#define CLK_TWSI5 36 +#define CLK_TWSI6 37 +#define CLK_TWSI7 38 +#define CLK_TWSI8 39 +#define CLK_TIMERS1 40 +#define CLK_TIMERS2 41 +#define CLK_AIB 42 +#define CLK_ONEWIRE 43 +#define CLK_SSPA0 44 +#define CLK_SSPA1 45 +#define CLK_DRO 46 +#define CLK_IR 47 +#define CLK_TSEN 48 +#define CLK_IPC_AP2AUD 49 +#define CLK_CAN0 50 +#define CLK_CAN0_BUS 51 +#define CLK_UART0_BUS 52 +#define CLK_UART2_BUS 53 +#define CLK_UART3_BUS 54 +#define CLK_UART4_BUS 55 +#define CLK_UART5_BUS 56 +#define CLK_UART6_BUS 57 +#define CLK_UART7_BUS 58 +#define CLK_UART8_BUS 59 +#define CLK_UART9_BUS 60 +#define CLK_GPIO_BUS 61 +#define CLK_PWM0_BUS 62 +#define CLK_PWM1_BUS 63 +#define CLK_PWM2_BUS 64 +#define CLK_PWM3_BUS 65 +#define CLK_PWM4_BUS 66 +#define CLK_PWM5_BUS 67 +#define CLK_PWM6_BUS 68 +#define CLK_PWM7_BUS 69 +#define CLK_PWM8_BUS 70 +#define CLK_PWM9_BUS 71 +#define CLK_PWM10_BUS 72 +#define CLK_PWM11_BUS 73 +#define CLK_PWM12_BUS 74 +#define CLK_PWM13_BUS 75 +#define CLK_PWM14_BUS 76 +#define CLK_PWM15_BUS 77 +#define CLK_PWM16_BUS 78 +#define CLK_PWM17_BUS 79 +#define CLK_PWM18_BUS 80 +#define CLK_PWM19_BUS 81 +#define CLK_SSP3_BUS 82 +#define CLK_RTC_BUS 83 +#define CLK_TWSI0_BUS 84 +#define CLK_TWSI1_BUS 85 +#define CLK_TWSI2_BUS 86 +#define CLK_TWSI4_BUS 87 +#define CLK_TWSI5_BUS 88 +#define CLK_TWSI6_BUS 89 +#define CLK_TWSI7_BUS 90 +#define CLK_TWSI8_BUS 91 +#define CLK_TIMERS1_BUS 92 +#define CLK_TIMERS2_BUS 93 +#define CLK_AIB_BUS 94 +#define CLK_ONEWIRE_BUS 95 +#define CLK_SSPA0_BUS 96 +#define CLK_SSPA1_BUS 97 +#define CLK_TSEN_BUS 98 +#define CLK_IPC_AP2AUD_BUS 99 +#define CLK_SSPA0_I2S_BCLK 100 +#define CLK_SSPA1_I2S_BCLK 101 + +/* APMU clocks */ +#define CLK_CCI550 0 +#define CLK_CPU_C0_HI 1 +#define CLK_CPU_C0_CORE 2 +#define CLK_CPU_C0_ACE 3 +#define CLK_CPU_C0_TCM 4 +#define CLK_CPU_C1_HI 5 +#define CLK_CPU_C1_CORE 6 +#define CLK_CPU_C1_ACE 7 +#define CLK_CCIC_4X 8 +#define CLK_CCIC1PHY 9 +#define CLK_SDH_AXI 10 +#define CLK_SDH0 11 +#define CLK_SDH1 12 +#define CLK_SDH2 13 +#define CLK_USB_P1 14 +#define CLK_USB_AXI 15 +#define CLK_USB30 16 +#define CLK_QSPI 17 +#define CLK_QSPI_BUS 18 +#define CLK_DMA 19 +#define CLK_AES 20 +#define CLK_VPU 21 +#define CLK_GPU 22 +#define CLK_EMMC 23 +#define CLK_EMMC_X 24 +#define CLK_AUDIO 25 +#define CLK_HDMI 26 +#define CLK_PMUA_ACLK 27 +#define CLK_PCIE0_MASTER 28 +#define CLK_PCIE0_SLAVE 29 +#define CLK_PCIE0_DBI 30 +#define CLK_PCIE1_MASTER 31 +#define CLK_PCIE1_SLAVE 32 +#define CLK_PCIE1_DBI 33 +#define CLK_PCIE2_MASTER 34 +#define CLK_PCIE2_SLAVE 35 +#define CLK_PCIE2_DBI 36 +#define CLK_EMAC0_BUS 37 +#define CLK_EMAC0_PTP 38 +#define CLK_EMAC1_BUS 39 +#define CLK_EMAC1_PTP 40 +#define CLK_JPG 41 +#define CLK_CCIC2PHY 42 +#define CLK_CCIC3PHY 43 +#define CLK_CSI 44 +#define CLK_CAMM0 45 +#define CLK_CAMM1 46 +#define CLK_CAMM2 47 +#define CLK_ISP_CPP 48 +#define CLK_ISP_BUS 49 +#define CLK_ISP 50 +#define CLK_DPU_MCLK 51 +#define CLK_DPU_ESC 52 +#define CLK_DPU_BIT 53 +#define CLK_DPU_PXCLK 54 +#define CLK_DPU_HCLK 55 +#define CLK_DPU_SPI 56 +#define CLK_DPU_SPI_HBUS 57 +#define CLK_DPU_SPIBUS 58 +#define CLK_DPU_SPI_ACLK 59 +#define CLK_V2D 60 +#define CLK_EMMC_BUS 61 + +#endif /* _DT_BINDINGS_SPACEMIT_CCU_H_ */
Signature · 1 line
2.25.1
PATCH v3 6/16 dts: k1: import dts file from upstream folder
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Import K1.dtsi from upstream folder.
---
Changes in v3:
- None.
arch/riscv/dts/k1.dtsi | 562 +++++++++++++++++++++++++++++++++-------- 1 file changed, 460 insertions(+), 102 deletions(-)
arch/riscv/dts/k1.dtsi +460 -102
@@ -1,8 +1,11 @@ -// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// SPDX-License-Identifier: GPL-2.0 OR MIT /* * Copyright (C) 2024 Yangyu Chen <[email protected]> */ +#include <dt-bindings/clock/spacemit,k1-syscon.h> +#include <dt-bindings/reset/spacemit-k1-reset.h> + /dts-v1/; / { #address-cells = <2>;
@@ -10,18 +13,6 @@ model = "SpacemiT K1"; compatible = "spacemit,k1"; - aliases { - serial0 = &uart0; - serial1 = &uart2; - serial2 = &uart3; - serial3 = &uart4; - serial4 = &uart5; - serial5 = &uart6; - serial6 = &uart7; - serial7 = &uart8; - serial8 = &uart9; - }; - cpus { #address-cells = <1>; #size-cells = <0>;
@@ -318,6 +309,36 @@ }; }; + clocks { + vctcxo_1m: clock-1m { + compatible = "fixed-clock"; + clock-frequency = <1000000>; + clock-output-names = "vctcxo_1m"; + #clock-cells = <0>; + }; + + vctcxo_24m: clock-24m { + compatible = "fixed-clock"; + clock-frequency = <24000000>; + clock-output-names = "vctcxo_24m"; + #clock-cells = <0>; + }; + + vctcxo_3m: clock-3m { + compatible = "fixed-clock"; + clock-frequency = <3000000>; + clock-output-names = "vctcxo_3m"; + #clock-cells = <0>; + }; + + osc_32k: clock-32k { + compatible = "fixed-clock"; + clock-frequency = <32000>; + clock-output-names = "osc_32k"; + #clock-cells = <0>; + }; + }; + soc: soc { compatible = "simple-bus"; interrupt-parent = <&plic>;
@@ -326,96 +347,267 @@ dma-noncoherent; ranges; - uart0: serial@d4017000 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017000 0x0 0x100>; - interrupts = <42>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + syscon_rcpu: system-controller@c0880000 { + compatible = "spacemit,k1-syscon-rcpu"; + reg = <0x0 0xc0880000 0x0 0x2048>; + #reset-cells = <1>; + }; + + syscon_rcpu2: system-controller@c0888000 { + compatible = "spacemit,k1-syscon-rcpu2"; + reg = <0x0 0xc0888000 0x0 0x28>; + #reset-cells = <1>; + }; + + syscon_apbc: system-controller@d4015000 { + compatible = "spacemit,k1-syscon-apbc"; + reg = <0x0 0xd4015000 0x0 0x1000>; + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, + <&vctcxo_24m>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", + "vctcxo_24m"; + #clock-cells = <1>; + #reset-cells = <1>; + }; + + gpio: gpio@d4019000 { + compatible = "spacemit,k1-gpio"; + reg = <0x0 0xd4019000 0x0 0x100>; + clocks = <&syscon_apbc CLK_GPIO>, + <&syscon_apbc CLK_GPIO_BUS>; + clock-names = "core", "bus"; + gpio-controller; + #gpio-cells = <3>; + interrupts = <58>; + interrupt-parent = <&plic>; + interrupt-controller; + #interrupt-cells = <3>; + gpio-ranges = <&pinctrl 0 0 0 32>, + <&pinctrl 1 0 32 32>, + <&pinctrl 2 0 64 32>, + <&pinctrl 3 0 96 32>; + }; + + pwm0: pwm@d401a000 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401a000 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM0>; + resets = <&syscon_apbc RESET_PWM0>; + status = "disabled"; + }; + + pwm1: pwm@d401a400 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401a400 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM1>; + resets = <&syscon_apbc RESET_PWM1>; + status = "disabled"; + }; + + pwm2: pwm@d401a800 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401a800 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM2>; + resets = <&syscon_apbc RESET_PWM2>; + status = "disabled"; + }; + + pwm3: pwm@d401ac00 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401ac00 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM3>; + resets = <&syscon_apbc RESET_PWM3>; + status = "disabled"; + }; + + pwm4: pwm@d401b000 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401b000 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM4>; + resets = <&syscon_apbc RESET_PWM4>; + status = "disabled"; + }; + + pwm5: pwm@d401b400 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401b400 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM5>; + resets = <&syscon_apbc RESET_PWM5>; + status = "disabled"; + }; + + pwm6: pwm@d401b800 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401b800 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM6>; + resets = <&syscon_apbc RESET_PWM6>; + status = "disabled"; + }; + + pwm7: pwm@d401bc00 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd401bc00 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM7>; + resets = <&syscon_apbc RESET_PWM7>; + status = "disabled"; + }; + + pinctrl: pinctrl@d401e000 { + compatible = "spacemit,k1-pinctrl"; + reg = <0x0 0xd401e000 0x0 0x400>; + clocks = <&syscon_apbc CLK_AIB>, + <&syscon_apbc CLK_AIB_BUS>; + clock-names = "func", "bus"; + }; + + pwm8: pwm@d4020000 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4020000 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM8>; + resets = <&syscon_apbc RESET_PWM8>; + status = "disabled"; + }; + + pwm9: pwm@d4020400 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4020400 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM9>; + resets = <&syscon_apbc RESET_PWM9>; + status = "disabled"; + }; + + pwm10: pwm@d4020800 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4020800 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM10>; + resets = <&syscon_apbc RESET_PWM10>; status = "disabled"; }; - uart2: serial@d4017100 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017100 0x0 0x100>; - interrupts = <44>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm11: pwm@d4020c00 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4020c00 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM11>; + resets = <&syscon_apbc RESET_PWM11>; status = "disabled"; }; - uart3: serial@d4017200 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017200 0x0 0x100>; - interrupts = <45>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm12: pwm@d4021000 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4021000 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM12>; + resets = <&syscon_apbc RESET_PWM12>; status = "disabled"; }; - uart4: serial@d4017300 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017300 0x0 0x100>; - interrupts = <46>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm13: pwm@d4021400 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4021400 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM13>; + resets = <&syscon_apbc RESET_PWM13>; status = "disabled"; }; - uart5: serial@d4017400 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017400 0x0 0x100>; - interrupts = <47>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm14: pwm@d4021800 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4021800 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM14>; + resets = <&syscon_apbc RESET_PWM14>; status = "disabled"; }; - uart6: serial@d4017500 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017500 0x0 0x100>; - interrupts = <48>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm15: pwm@d4021c00 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4021c00 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM15>; + resets = <&syscon_apbc RESET_PWM15>; status = "disabled"; }; - uart7: serial@d4017600 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017600 0x0 0x100>; - interrupts = <49>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm16: pwm@d4022000 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4022000 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM16>; + resets = <&syscon_apbc RESET_PWM16>; status = "disabled"; }; - uart8: serial@d4017700 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017700 0x0 0x100>; - interrupts = <50>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm17: pwm@d4022400 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4022400 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM17>; + resets = <&syscon_apbc RESET_PWM17>; status = "disabled"; }; - uart9: serial@d4017800 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xd4017800 0x0 0x100>; - interrupts = <51>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; + pwm18: pwm@d4022800 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4022800 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM18>; + resets = <&syscon_apbc RESET_PWM18>; status = "disabled"; }; + pwm19: pwm@d4022c00 { + compatible = "spacemit,k1-pwm", "marvell,pxa910-pwm"; + reg = <0x0 0xd4022c00 0x0 0x10>; + #pwm-cells = <3>; + clocks = <&syscon_apbc CLK_PWM19>; + resets = <&syscon_apbc RESET_PWM19>; + status = "disabled"; + }; + + syscon_mpmu: system-controller@d4050000 { + compatible = "spacemit,k1-syscon-mpmu"; + reg = <0x0 0xd4050000 0x0 0x209c>; + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, + <&vctcxo_24m>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", + "vctcxo_24m"; + #clock-cells = <1>; + #power-domain-cells = <1>; + #reset-cells = <1>; + }; + + pll: clock-controller@d4090000 { + compatible = "spacemit,k1-pll"; + reg = <0x0 0xd4090000 0x0 0x1000>; + clocks = <&vctcxo_24m>; + spacemit,mpmu = <&syscon_mpmu>; + #clock-cells = <1>; + }; + + syscon_apmu: system-controller@d4282800 { + compatible = "spacemit,k1-syscon-apmu"; + reg = <0x0 0xd4282800 0x0 0x400>; + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, + <&vctcxo_24m>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", + "vctcxo_24m"; + #clock-cells = <1>; + #power-domain-cells = <1>; + #reset-cells = <1>; + }; + plic: interrupt-controller@e0000000 { compatible = "spacemit,k1-plic", "sifive,plic-1.0.0"; reg = <0x0 0xe0000000 0x0 0x4000000>;
@@ -446,35 +638,201 @@ <&cpu7_intc 3>, <&cpu7_intc 7>; }; - sec_uart1: serial@f0612000 { - compatible = "spacemit,k1-uart", "intel,xscale-uart"; - reg = <0x0 0xf0612000 0x0 0x100>; - interrupts = <43>; - clock-frequency = <14857000>; - reg-shift = <2>; - reg-io-width = <4>; - status = "reserved"; /* for TEE usage */ - }; - - reset: reset-controller@d4050000 { - compatible = "spacemit,k1-reset"; - reg = <0x0 0xd4050000 0x0 0x209c>, - <0x0 0xd4282800 0x0 0x400>, - <0x0 0xd4015000 0x0 0x1000>, - <0x0 0xd4090000 0x0 0x1000>, - <0x0 0xd4282c00 0x0 0x400>, - <0x0 0xd8440000 0x0 0x98>, - <0x0 0xc0000000 0x0 0x4280>, - <0x0 0xf0610000 0x0 0x20>; - reg-names = "mpmu", "apmu", "apbc", "apbs", "ciu", "dciu", "ddrc", "apbc2"; + syscon_apbc2: system-controller@f0610000 { + compatible = "spacemit,k1-syscon-apbc2"; + reg = <0x0 0xf0610000 0x0 0x20>; #reset-cells = <1>; - status = "disabled"; }; - pinctrl: pinctrl@d401e000 { - compatible = "spacemit,k1-pinctrl", "pinctrl-single"; - reg = <0x0 0xd401e000 0x0 0x400>; - pinctrl-single,register-width = <32>; + camera-bus { + compatible = "simple-bus"; + ranges; + #address-cells = <2>; + #size-cells = <2>; + dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>, + <0x0 0x80000000 0x1 0x00000000 0x1 0x80000000>; + }; + + dma-bus { + compatible = "simple-bus"; + ranges; + #address-cells = <2>; + #size-cells = <2>; + dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>, + <0x1 0x00000000 0x1 0x80000000 0x3 0x00000000>; + + uart0: serial@d4017000 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017000 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART0>, + <&syscon_apbc CLK_UART0_BUS>; + clock-names = "core", "bus"; + interrupts = <42>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart2: serial@d4017100 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017100 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART2>, + <&syscon_apbc CLK_UART2_BUS>; + clock-names = "core", "bus"; + interrupts = <44>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart3: serial@d4017200 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017200 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART3>, + <&syscon_apbc CLK_UART3_BUS>; + clock-names = "core", "bus"; + interrupts = <45>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart4: serial@d4017300 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017300 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART4>, + <&syscon_apbc CLK_UART4_BUS>; + clock-names = "core", "bus"; + interrupts = <46>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart5: serial@d4017400 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017400 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART5>, + <&syscon_apbc CLK_UART5_BUS>; + clock-names = "core", "bus"; + interrupts = <47>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart6: serial@d4017500 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017500 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART6>, + <&syscon_apbc CLK_UART6_BUS>; + clock-names = "core", "bus"; + interrupts = <48>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart7: serial@d4017600 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017600 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART7>, + <&syscon_apbc CLK_UART7_BUS>; + clock-names = "core", "bus"; + interrupts = <49>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart8: serial@d4017700 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017700 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART8>, + <&syscon_apbc CLK_UART8_BUS>; + clock-names = "core", "bus"; + interrupts = <50>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + uart9: serial@d4017800 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xd4017800 0x0 0x100>; + clocks = <&syscon_apbc CLK_UART9>, + <&syscon_apbc CLK_UART9_BUS>; + clock-names = "core", "bus"; + interrupts = <51>; + reg-shift = <2>; + reg-io-width = <4>; + status = "disabled"; + }; + + sec_uart1: serial@f0612000 { + compatible = "spacemit,k1-uart", + "intel,xscale-uart"; + reg = <0x0 0xf0612000 0x0 0x100>; + interrupts = <43>; + clock-frequency = <14857000>; + reg-shift = <2>; + reg-io-width = <4>; + status = "reserved"; /* for TEE usage */ + }; + }; + + multimedia-bus { + compatible = "simple-bus"; + ranges; + #address-cells = <2>; + #size-cells = <2>; + dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>, + <0x0 0x80000000 0x1 0x00000000 0x3 0x80000000>; + }; + + network-bus { + compatible = "simple-bus"; + ranges; + #address-cells = <2>; + #size-cells = <2>; + dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>, + <0x0 0x80000000 0x1 0x00000000 0x0 0x80000000>; + }; + + pcie-bus { + compatible = "simple-bus"; + ranges; + #address-cells = <2>; + #size-cells = <2>; + dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>, + <0x0 0xb8000000 0x1 0x38000000 0x3 0x48000000>; + }; + + storage-bus { + compatible = "simple-bus"; + ranges; + #address-cells = <2>; + #size-cells = <2>; + dma-ranges = <0x0 0x00000000 0x0 0x00000000 0x0 0x80000000>; + + emmc: mmc@d4281000 { + compatible = "spacemit,k1-sdhci"; + reg = <0x0 0xd4281000 0x0 0x200>; + clocks = <&syscon_apmu CLK_SDH_AXI>, + <&syscon_apmu CLK_SDH2>; + clock-names = "core", "io"; + interrupts = <101>; + status = "disabled"; + }; }; }; };
Signature · 1 line
2.25.1
PATCH v3 7/16 clk: spacemit: Add support for K1 SoC
In reply to Raymond MaoFrom: Junhui Liu <[email protected]>
Add clock support for Spacemit K1 SoC.
---
Changes in v3:
- Add protection when registering a clock id. Otherwise, it'll cause panic in u-boot stage.
- Drop SPL_CLK_SPACEMIT_K1 Kconfig since it's redundant.
- Fix typo in Signed-off-by: riststar.com -> riscstar.com
drivers/clk/Kconfig | 5 +- drivers/clk/Makefile | 1 + drivers/clk/spacemit/Kconfig | 22 + drivers/clk/spacemit/Makefile | 7 + drivers/clk/spacemit/clk-k1.c | 1798 +++++++++++++++++++++++++++++ drivers/clk/spacemit/clk_common.h | 79 ++ drivers/clk/spacemit/clk_ddn.c | 93 ++ drivers/clk/spacemit/clk_ddn.h | 53 + drivers/clk/spacemit/clk_mix.c | 403 +++++++ drivers/clk/spacemit/clk_mix.h | 224 ++++ drivers/clk/spacemit/clk_pll.c | 157 +++ drivers/clk/spacemit/clk_pll.h | 81 ++ include/soc/spacemit/k1-syscon.h | 149 +++ 13 files changed, 3070 insertions(+), 2 deletions(-) create mode 100644 drivers/clk/spacemit/Kconfig create mode 100644 drivers/clk/spacemit/Makefile create mode 100644 drivers/clk/spacemit/clk-k1.c create mode 100644 drivers/clk/spacemit/clk_common.h create mode 100644 drivers/clk/spacemit/clk_ddn.c create mode 100644 drivers/clk/spacemit/clk_ddn.h create mode 100644 drivers/clk/spacemit/clk_mix.c create mode 100644 drivers/clk/spacemit/clk_mix.h create mode 100644 drivers/clk/spacemit/clk_pll.c create mode 100644 drivers/clk/spacemit/clk_pll.h create mode 100644 include/soc/spacemit/k1-syscon.h
drivers/clk/Kconfig +3 -2
@@ -276,11 +276,12 @@ source "drivers/clk/mvebu/Kconfig" source "drivers/clk/owl/Kconfig" source "drivers/clk/qcom/Kconfig" source "drivers/clk/renesas/Kconfig" -source "drivers/clk/sophgo/Kconfig" -source "drivers/clk/sunxi/Kconfig" source "drivers/clk/sifive/Kconfig" +source "drivers/clk/sophgo/Kconfig" +source "drivers/clk/spacemit/Kconfig" source "drivers/clk/starfive/Kconfig" source "drivers/clk/stm32/Kconfig" +source "drivers/clk/sunxi/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/ti/Kconfig" source "drivers/clk/thead/Kconfig"
drivers/clk/Makefile +1 -0
@@ -48,6 +48,7 @@ obj-$(CONFIG_CLK_RENESAS) += renesas/ obj-$(CONFIG_$(PHASE_)CLK_SCMI) += clk_scmi.o obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_CLK_SOPHGO) += sophgo/ +obj-$(CONFIG_CLK_SPACEMIT) += spacemit/ obj-$(CONFIG_CLK_SUNXI) += sunxi/ obj-$(CONFIG_CLK_UNIPHIER) += uniphier/ obj-$(CONFIG_CLK_VERSACLOCK) += clk_versaclock.o
drivers/clk/spacemit/Kconfig new file +22 -0
@@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2025, Junhui Liu <[email protected]> + +config CLK_SPACEMIT + bool "Clock support for SpacemiT SoCs" + depends on CLK + select REGMAP + help + This enables support clock driver for Spacemit SoC + family. + +if CLK_SPACEMIT + +config CLK_SPACEMIT_K1 + bool "SpacemiT K1 clock support" + select CLK_CCF + help + This enables support clock driver for Spacemit K1 SoC. + It's based on Common Clock Framework. + +endif
drivers/clk/spacemit/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2025 Junhui Liu <[email protected]> + +obj-$(CONFIG_CLK_SPACEMIT) += clk_ddn.o clk_mix.o clk_pll.o + +obj-$(CONFIG_CLK_SPACEMIT_K1) += clk-k1.o
drivers/clk/spacemit/clk-k1.c new file +1798 -0
1,798 lines not on this page · raw message
drivers/clk/spacemit/clk_common.h new file +79 -0
79 lines not on this page · raw message
drivers/clk/spacemit/clk_ddn.c new file +93 -0
93 lines not on this page · raw message
drivers/clk/spacemit/clk_ddn.h new file +53 -0
53 lines not on this page · raw message
drivers/clk/spacemit/clk_mix.c new file +403 -0
403 lines not on this page · raw message
drivers/clk/spacemit/clk_mix.h new file +224 -0
224 lines not on this page · raw message
drivers/clk/spacemit/clk_pll.c new file +157 -0
157 lines not on this page · raw message
drivers/clk/spacemit/clk_pll.h new file +81 -0
81 lines not on this page · raw message
include/soc/spacemit/k1-syscon.h new file +149 -0
62 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v3 8/16 dts: k1: enable clocks in SPL
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Enable clock nodes for K1 SoC in SPL.
---
Changes in v3:
- None.
arch/riscv/dts/k1-spl.dts | 49 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)
arch/riscv/dts/k1-spl.dts +48 -1
@@ -11,15 +11,62 @@ / { model = "spacemit k1 spl"; + aliases { + console = &uart0; + serial0 = &uart0; + }; + chosen { stdout-path = "serial0:115200n8"; }; }; +&vctcxo_1m { + status = "okay"; + bootph-pre-ram; +}; + +&vctcxo_24m { + status = "okay"; + bootph-pre-ram; +}; + +&vctcxo_3m { + status = "okay"; + bootph-pre-ram; +}; + +&osc_32k { + status = "okay"; + bootph-pre-ram; +}; + &soc { bootph-all; - serial@d4017000 { + system-controller@d4050000 { status = "okay"; bootph-pre-ram; }; + clock-controller@d4090000 { + status = "okay"; + bootph-pre-ram; + }; + system-controller@d4282800 { + status = "okay"; + bootph-pre-ram; + }; + system-controller@d4015000 { + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, + <&vctcxo_24m>, <&syscon_mpmu CLK_PLL1_31P5>, + <&pll CLK_PLL1_D4>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", + "vctcxo_24m", "pll1_d78_31p5", "pll1_d4"; + status = "okay"; + bootph-pre-ram; + }; +}; + +&uart0 { + status = "okay"; + bootph-pre-ram; };
Signature · 1 line
2.25.1
PATCH v3 9/16 board: k1: initialize clock and serial devices in SPL
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Initialize clock and serial devices in SPL. Otherwise, the device driver won't be loaded in SPL.
---
Changes in v3:
- None.
board/spacemit/k1/spl.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
board/spacemit/k1/spl.c +39 -0
@@ -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.25.1
PATCH v3 10/16 configs: k1: add default option for clock driver in SPL
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Add default option for enabling clock driver in SPL.
---
Changes in v3:
- Explicitly enable CONFIG_CLK_CCF, CONFIG_CLK_SPACEMIT_K1, CONFIG_SPL_CLK_CCF, CONFIG_SPL_DM_RESET in defconfig, since CONFIG_SPL_RESET_SPACEMIT_K1 and CONFIG_SPL_CLK_SPACEMIT_K1 has been removed.
configs/spacemit_k1_defconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+)
configs/spacemit_k1_defconfig +12 -0
@@ -43,3 +43,15 @@ CONFIG_DEBUG_UART_NS16550=y CONFIG_DEBUG_UART_ANNOUNCE=y # CONFIG_DEBUG_SBI_CONSOLE is not set CONFIG_TIMER_EARLY=y +CONFIG_REGMAP=y +CONFIG_LIB_RATIONAL=y +CONFIG_CLK=y +CONFIG_CLK_CCF=y +CONFIG_CLK_SPACEMIT=y +CONFIG_CLK_SPACEMIT_K1=y +CONFIG_SYS_MALLOC_F_LEN=0x5000 +CONFIG_SPL_REGMAP=y +CONFIG_SPL_LIB_RATIONAL=y +CONFIG_SPL_DM_RESET=y +CONFIG_SPL_CLK=y +CONFIG_SPL_CLK_CCF=y
Signature · 1 line
2.25.1
PATCH v3 11/16 i2c: k1: add I2C driver support
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Add I2C driver support on Spacemit K1 SoC using driver model.
---
Changes in v3:
- None.
drivers/i2c/Kconfig | 7 + drivers/i2c/Makefile | 1 + drivers/i2c/k1_i2c.c | 516 +++++++++++++++++++++++++++++++++++++++++++ drivers/i2c/k1_i2c.h | 69 ++++++ 4 files changed, 593 insertions(+) create mode 100644 drivers/i2c/k1_i2c.c create mode 100644 drivers/i2c/k1_i2c.h
drivers/i2c/Kconfig +7 -0
@@ -817,6 +817,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
@@ -48,6 +48,7 @@ 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_SOFT) += soft_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 +516 -0
516 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.25.1
PATCH v3 12/16 spacemit: k1: add TLV EEPROM support in SPL
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
And support for required components including clock, I2C controller, and I2C EEPROM.
---
Changes in v3:
- CONFIG_SPL_DM_RESET has already been enabled in patch 10.
arch/riscv/dts/k1-spl.dts | 28 +++++++++ arch/riscv/dts/k1.dtsi | 104 ++++++++++++++++++++++++++++++++++ board/spacemit/k1/spl.c | 104 +++++++++++++++++++++++++++++++++- board/spacemit/k1/tlv_codes.h | 22 +++++++ configs/spacemit_k1_defconfig | 12 ++++ 5 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 board/spacemit/k1/tlv_codes.h
arch/riscv/dts/k1-spl.dts +28 -0
@@ -5,6 +5,7 @@ */ /dts-v1/; + #include "k1.dtsi" #include "binman.dtsi"
@@ -64,6 +65,33 @@ status = "okay"; bootph-pre-ram; }; + + i2c@d4012000 { /* i2c2 */ + status = "okay"; + bootph-pre-ram; + eeprom: eeprom { + compatible = "atmel,24c02"; + reg = <0x50>; + status = "okay"; + bootph-pre-ram; + }; + }; + + i2c@d401d800 { /* i2c8 */ + status = "okay"; + bootph-pre-ram; + pmic@41 { + compatible = "pmic"; + reg = <0x41>; + status = "okay"; + bootph-pre-ram; + }; + }; + + reset-controller@d4050000 { + status = "okay"; + bootph-pre-ram; + }; }; &uart0 {
arch/riscv/dts/k1.dtsi +104 -0
122 lines not on this page · raw message
board/spacemit/k1/spl.c +103 -1
131 lines not on this page · raw message
board/spacemit/k1/tlv_codes.h new file +22 -0
@@ -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 +12 -0
@@ -33,6 +33,7 @@ CONFIG_ENV_OVERWRITE=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y CONFIG_RESET_SPACEMIT_K1=y +CONFIG_SPL_RESET_SPACEMIT_K1=y CONFIG_SYS_NS16550=y CONFIG_SYS_NS16550_MEM32=y CONFIG_DEBUG_UART=y
@@ -50,8 +51,19 @@ CONFIG_CLK_CCF=y CONFIG_CLK_SPACEMIT=y CONFIG_CLK_SPACEMIT_K1=y CONFIG_SYS_MALLOC_F_LEN=0x5000 +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_SPACEMIT_K1=y +CONFIG_MISC=y +CONFIG_I2C_EEPROM=y +CONFIG_CMD_TLV_EEPROM=y +CONFIG_LOG=y CONFIG_SPL_REGMAP=y CONFIG_SPL_LIB_RATIONAL=y CONFIG_SPL_DM_RESET=y CONFIG_SPL_CLK=y CONFIG_SPL_CLK_CCF=y +CONFIG_SPL_I2C=y +CONFIG_SPL_MISC=y +CONFIG_SPL_DRIVERS_MISC=y +CONFIG_SPL_I2C_EEPROM=y +CONFIG_SPL_CMD_TLV_EEPROM=y
Signature · 1 line
2.25.1
PATCH v3 13/16 spacemit: k1: Add DDR firmware support to SPL
In reply to Raymond MaoFrom: 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.
---
Changes in v3:
- None.
arch/riscv/dts/k1-spl.dts | 24 +++++++- board/spacemit/k1/Makefile | 20 ++++++ board/spacemit/k1/spl.c | 122 +++++++++++++++++++++++++++++++++++++ 3 files changed, 165 insertions(+), 1 deletion(-)
arch/riscv/dts/k1-spl.dts +23 -1
@@ -7,7 +7,6 @@ /dts-v1/; #include "k1.dtsi" -#include "binman.dtsi" / { model = "spacemit k1 spl";
@@ -20,6 +19,29 @@ chosen { stdout-path = "serial0:115200n8"; }; + + 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>; + }; + }; + }; }; &vctcxo_1m {
board/spacemit/k1/Makefile +20 -0
@@ -5,3 +5,23 @@ 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): + @echo "Preparing DDR firmware..." + @if [ -n "$(DDR_FW_SRC)" ] && [ -f "$(DDR_FW_SRC)" ]; then \ + echo " Copying from: $(DDR_FW_SRC)"; \ + cp "$(DDR_FW_SRC)" $@; \ + elif [ -f $@ ]; then \ + echo " Using existing $@"; \ + else \ + echo " Note: No firmware found, creating empty file"; \ + echo " (Set DDR_FW_FILE to specify firmware location)"; \ + touch $@; \ + fi + +clean-files += $(FW_TARGET)
board/spacemit/k1/spl.c +122 -0
154 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 14/16 power: pmic: add support for Spacemit P1 PMIC
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Spacemit's PMIC is used by Spacemit K1 SoC. It contains voltage regulators, GPIOs and Watchdog.
---
Changes in v3:
- Drop SPL_PMIC_SPACEMIT_P1 Kconfig
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(+) create mode 100644 drivers/power/pmic/pmic_spacemit_p1.c create mode 100644 include/power/spacemit_p1.h
drivers/power/pmic/Kconfig +8 -0
@@ -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
@@ -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.25.1
PATCH v3 15/16 power: regulator: add support for Spacemit P1 SoC
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Support voltage regulator for Spacemit P1 SoC. It contains 6 BUCKs and 11 LDOs.
---
Changes in v3:
- Drop SPL_DM_REGULATOR_SPACEMIT_P1 Kconfig
drivers/power/regulator/Kconfig | 8 + drivers/power/regulator/Makefile | 1 + .../power/regulator/spacemit_p1_regulator.c | 460 ++++++++++++++++++ 3 files changed, 469 insertions(+) create mode 100644 drivers/power/regulator/spacemit_p1_regulator.c
drivers/power/regulator/Kconfig +8 -0
@@ -547,3 +547,11 @@ 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
@@ -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 +460 -0
460 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 16/16 board: k1: enable pmic in spl
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Add Spacemit P1 SoC support in SPL. And set the default voltage for BUCKs and LDOs.
---
Changes in v3:
- Remove CONFIG_SPL_PMIC_SPACEMIT_P1 and CONFIG_SPL_DM_REGULATOR_SPACEMIT_P1 from defconfig (Kconfig symbols no longer exist)
- Fix MAINTAINERS: use TAB instead of spaces before mailing list
arch/riscv/dts/k1-spl.dts | 128 +++++++++++++++++++++++++++++++--- board/spacemit/k1/MAINTAINERS | 7 +- board/spacemit/k1/spl.c | 82 +++++++++++++++++++--- configs/spacemit_k1_defconfig | 7 ++ 4 files changed, 201 insertions(+), 23 deletions(-)
arch/riscv/dts/k1-spl.dts +117 -11
@@ -99,17 +99,6 @@ }; }; - i2c@d401d800 { /* i2c8 */ - status = "okay"; - bootph-pre-ram; - pmic@41 { - compatible = "pmic"; - reg = <0x41>; - status = "okay"; - bootph-pre-ram; - }; - }; - reset-controller@d4050000 { status = "okay"; bootph-pre-ram;
@@ -120,3 +109,120 @@ status = "okay"; bootph-pre-ram; }; + +&i2c8 { + status = "okay"; + bootph-pre-ram; + pmic@41 { + compatible = "spacemit,p1"; + reg = <0x41>; + status = "okay"; + bootph-pre-ram; + + regulators { + buck1 { + regulator-name = "vdd_core"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + bootph-pre-ram; + }; + + buck2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck3_1v8: buck3 { + regulator-name = "vdd_1v8"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1800000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + bootph-pre-ram; + }; + + buck4 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3300000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck5 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck6 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + aldo1 { + regulator-name = "vdd_1v8_mmc"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-boot-on; + bootph-pre-ram; + }; + + aldo2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + aldo3 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + aldo4 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo1 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo3 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo4 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo5 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo6 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo7 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + }; + }; +};
board/spacemit/k1/MAINTAINERS +6 -1
@@ -1,6 +1,11 @@ BananaPi F3 M: Huan Zhou <pericycle.cc@@gmail.com> +M: Guodong Xu <[email protected]> +L: [email protected] S: Maintained F: board/spacemit/k1/ -F: configs/k1_defconfig +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 +71 -11
111 lines not on this page · raw message
configs/spacemit_k1_defconfig +7 -0
@@ -57,6 +57,10 @@ CONFIG_MISC=y CONFIG_I2C_EEPROM=y CONFIG_CMD_TLV_EEPROM=y CONFIG_LOG=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_SPACEMIT_P1=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_SPACEMIT_P1=y CONFIG_SPL_REGMAP=y CONFIG_SPL_LIB_RATIONAL=y CONFIG_SPL_DM_RESET=y
@@ -67,3 +71,6 @@ CONFIG_SPL_MISC=y CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL_I2C_EEPROM=y CONFIG_SPL_CMD_TLV_EEPROM=y +CONFIG_SPL_POWER=y +CONFIG_SPL_DM_PMIC=y +CONFIG_SPL_DM_REGULATOR=y
Signature · 1 line
2.25.1
Hello,
I wanted to try this series (applied to upstream u-boot, next branch), but it failed to boot properly.
Note that I tried to follow instructions from:
Subject: [PATCH] doc: spacemit: add K1 SPL build and test guide
https://lore.kernel.org/u-boot/[email protected]/
But they looked wrong at times so I tried to guess what was intended.
Can someone see why it failed like that ?
Find the detailed description of what I did below:
## Get the repos
git clone https://github.com/u-boot/u-boot
git clone https://github.com/spacemit-com/spacemit-firmware
git clone https://gitee.com/bianbu-linux/uboot-2022.10 bianbu-uboot-2022.10
## Build u-boot
BUILD_PATH=$(pwd) UBOOT_UPSTREAM_DIR="${BUILD_PATH}/u-boot" UBOOT_BIANBU_DIR="${BUILD_PATH}/bianbu-uboot-2022.10" SPACEMIT_FW_DIR="${BUILD_PATH}/spacemit-firmware"
cd "${UBOOT_UPSTREAM_DIR}"
git checkout -b spacemit-k1 upstream/next
# Grab the series link from:
# https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
curl https://patchwork.ozlabs.org/series/497518/mbox/ > Add-board-support-for-Spacemit-K1-SoC-in-SPL.patch git am < Add-board-support-for-Spacemit-K1-SoC-in-SPL.patch
export CROSS_COMPILE=riscv64-linux-musl-
export ARCH=riscv
export DDR_FW_FILE="${SPACEMIT_FW_DIR}/k1/v0.2/ddr_fw.bin"
make spacemit_k1_defconfig
make -j $(nproc)
# Here the path to fsbl.json was not right
# See: https://gitee.com/spacemit-buildroot/uboot-2022.10/blob/k1-bl-v2.2.y/board/spacemit/k1-x/configs/fsbl.json
mkdir -p "${UBOOT_BIANBU_DIR}/spl_bin/configs"
sed 's/u-boot-spl\.bin/u-boot-spl-ddr.bin/g' \
< "${UBOOT_BIANBU_DIR}/board/spacemit/k1-x/configs/fsbl.json" \
> "${UBOOT_BIANBU_DIR}/spl_bin/configs/fsbl_ddr.json"
echo "Clean binaries in ${UBOOT_BIANBU_DIR}/spl_bin" rm -f "${UBOOT_BIANBU_DIR}/spl_bin/u-boot-spl-ddr.bin" rm -f "${UBOOT_BIANBU_DIR}/spl_bin/u-boot-spl.bin"
cp "${UBOOT_UPSTREAM_DIR}/u-boot-spl-ddr.bin" "${UBOOT_BIANBU_DIR}/spl_bin"
python3 "${UBOOT_BIANBU_DIR}/tools/build_binary_file.py" \
-c "${UBOOT_BIANBU_DIR}/spl_bin/configs/fsbl_ddr.json" \
-o "${UBOOT_BIANBU_DIR}/spl_bin/FSBL.bin"
# This created a FSBL.bin in the specified directory.
## Setup serial console, boot with FDL button pressed, then USB upload:
FSBL="${UBOOT_BIANBU_DIR}/spl_bin/FSBL.bin"
fastboot stage "${FSBL}"
fastboot continue
## Serial console output
sys: 0x1000
bm:2
ROM: usb download handlerusb2d_initialize : enter
Controller Run
usb rst int
SETUP: 0x80 0x6 0x100
usb rst int
SETUP: 0x0 0x5 0x1
SETUP: 0x80 0x6 0x100
SETUP: 0x80 0x6 0x200
SETUP: 0x80 0x6 0x200
SETUP: 0x80 0x6 0x300
SETUP: 0x80 0x6 0x302
SETUP: 0x80 0x6 0x301
SETUP: 0x80 0x6 0x30a
SETUP: 0x0 0x9 0x1usb_rx_bytes : len= 4096 pBuf= 0xc0838720
SETUP: 0x80 0x6 0x302
SETUP: 0x80 0x6 0x304fastboot_handle_command: max-download-sizeusb_tx_bytes : len= 65 pBuf= 0xc083fe88usb_rx_bytes : len= 4096 pBuf= 0xc0838720fastboot_handle_command: 0001e860
Starting download of 125024 bytesusb_tx_bytes : len= 65 pBuf= 0xc083fe88usb_rx_bytes : len= 125024 pBuf= 0xc0800000usb_tx_bytes : len= 65 pBuf= 0xc083fe88usb_rx_bytes : len= 4096 pBuf= 0xc0838720fastboot_handle_command: continueusb_tx_bytes : len= 65 pBuf= 0xc083fe88
j...
<debug_uart>
U-Boot SPL 2026.04-rc4-00543-g2ba03a569e61 (Mar 26 2026 - 16:48:44 +0100) Fail to detect board:-2vdd_core, value:900000vdd_1v8, value:1800000vdd_1v8_mmc, value:500000
DDR firmware: [0xc08159c0]:0xf0227179, size:0x8d98
DDR is ready
SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
## More details
[bianbu-uboot-2022.10]$ git log --oneline -1d61c8c77 (HEAD -> k1-bl-v2.2.y, tag: k1-bl-v2.2.9-release, origin/k1-bl-v2.2.y, origin/HEAD) Update for v2.2.9
[spacemit-firmware]$ git log --oneline -1
3eca456 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #1 from docularxu/add-readme
$ ls -la $DDR_FW_FILE -rw-r--r-- 1 user user 36248 Mar 26 16:38 .../spacemit-firmware/k1/v0.2/ddr_fw.bin $ sha256sum $DDR_FW_FILE 4ca729dae39580fe6d52ff6a1ead95fd18cd6394c942cc4a323882ccf2840148 .../spacemit-firmware/k1/v0.2/ddr_fw.bin
[u-boot]$ git remote -v | grep upstream
upstream https://source.denx.de/u-boot/u-boot.git (fetch) upstream https://source.denx.de/u-boot/u-boot.git (push)
$ git log --oneline upstream/next^..HEAD 2ba03a569e6 (HEAD -> spacemit-k1) board: k1: enable pmic in spl d4b07728ec7 power: regulator: add support for Spacemit P1 SoC 698e1dac98b power: pmic: add support for Spacemit P1 PMIC 76b9c476576 spacemit: k1: Add DDR firmware support to SPL d8bc52c01f2 spacemit: k1: add TLV EEPROM support in SPL 06ac4c0cc55 i2c: k1: add I2C driver support 29c9f971bbe configs: k1: add default option for clock driver in SPL 66fd60bea6e board: k1: initialize clock and serial devices in SPL 1c69ee27980 dts: k1: enable clocks in SPL fdad5fdcc0d clk: spacemit: Add support for K1 SoC 0e4f554b274 dts: k1: import dts file from upstream folder a8cd1f828c4 dt-bindings: clock: import k1-syscon from upstream 0dd6c089190 reset: k1: remove TWSI8 reset restriction a46bdb334d7 configs: k1: enable early timer support 052c15d331a spacemit: k1: enable SPL with debug UART 25905d01c7e spacemit: k1: support multi-board infrastructure 8813d74163e (upstream/next, upstream/WIP/25Mar2026-next, origin/next, origin/WIP/25Mar2026-next) Merge patch series "test/py: gpio: cleanups and improvement" 0f101dac8fb test/py: gpio: allow omitting gpio_op_pin 908db6c647c test/py: gpio: removing trailing semicolons b02b0a0c6cb test/py: gpio: remove unused imports
Thanks
PS: I just (re-)subscribed to the list. I tried to get the email threading right, hopefully it'll work.
And I forgot to add a small piece of info...
The board is Bananapi-F3 (8GB), with something that looks like a "v10" printed, but a bit blurry.
Hello,
Is there something we can do to help this series move forward ?
What are the next steps ?
How can we get a fully booting board after this is enabled ?
Thanks for all the work !
Best regards
Hi Vincent,
Quoted 11 lines · Vincent Legoll
Hello,
Is there something we can do to help this series move forward ?
What are the next steps ?
How can we get a fully booting board after this is enabled ?
There are two upcoming pinmux and SPI patches that can support U-boot proper, and eMMC support is on the way.
If you're using banana-pi, it may not boot fully since SPI NOR is missing on the board.
Raymond
Quoted 6 lines
Thanks for all the work !
Best regards
Hi Tom, Leo,
Do you have a chance to pull or merge this series?
Thanks a lot!
Raymond
Quoted 29 lines · Raymond Mao
Hi Vincent,
Quoted 11 lines · Vincent Legoll
Hello,
Is there something we can do to help this series move forward ?
What are the next steps ?
How can we get a fully booting board after this is enabled ?
There are two upcoming pinmux and SPI patches that can support U-boot proper, and eMMC support is on the way.
If you're using banana-pi, it may not boot fully since SPI NOR is missing on the board.Raymond
Quoted 6 lines
Thanks for all the work !
Best regards
Hi, Vincent
Quoted 6 lines · Vincent Legoll
Hello,
I wanted to try this series (applied to upstream u-boot, next branch), but it failed to boot properly.
Thanks for testing the v3 K1 SPL patchset.
Actually your result confirms the SPL patchset is working correctly and the build/test procedure is generally complete.
PS: I added some walk through to the key lines in your log below (for you and for the community's future reference purpose), but for here please be noted that as I said in the doc patch [1]:
"After DDR init succeeds, SPL proceeds to load U-Boot proper. If
U-Boot proper is not yet available (as in SPL-only testing), you will see SPL: failed to boot from all boot devices - this is expected and confirms that SPL with DDR init is working correctly."
[1] https://lore.kernel.org/u-boot/[email protected]/
Quoted 4 lines
Note that I tried to follow instructions from:
Subject: [PATCH] doc: spacemit: add K1 SPL build and test guide
https://lore.kernel.org/u-boot/[email protected]/
...
Quoted 4 lines
# Here the path to fsbl.json was not right
# See:
https://gitee.com/spacemit-buildroot/uboot-2022.10/blob/k1-bl-v2.2.y/board/spacemit/k1-x/configs/fsbl.json
Thanks for bringing this up.
Regarding the fsbl.json path: allow me to explain the upstream gitee repository URL has been redirected from
https://gitee.com/bianbu-linux/uboot-2022.10
to
https://gitee.com/spacemit-buildroot/uboot-2022.10
Somehow it causes the fsbl.json path in my doc [1] didn't match. I will update the repository URL and fix the fsbl.json path in v2 of the doc patch.
Quoted 11 lines
U-Boot SPL 2026.04-rc4-00543-g2ba03a569e61 (Mar 26 2026 - 16:48:44 +0100) Fail to detect board:-2
vdd_core, value:900000vdd_1v8, value:1800000vdd_1v8_mmc, value:500000
DDR firmware: [0xc08159c0]:0xf0227179, size:0x8d98
DDR is ready
SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
To walk through the key lines:
"DDR firmware: [...], size:0x8d98" - DDR firmware loaded successfully "DDR is ready" - DDR initialization completed
"SPL: failed to boot from all boot devices" - expected, since no
storage driver (SPI NOR, MMC, etc.) is included in this patchset to load U-Boot proper
Back to the patch series itself, your log is a good validation of the v3 SPL patchset.
Thank you again for taking the time.
BR,
Guodong
Quoted 5 lines
Thanks
PS: I just (re-)subscribed to the list. I tried to get the email threading right, hopefully it'll work.
Vincent Legoll
Tested-byHi Guodong Xu,
Quoted 3 lines · Guodong Xu
Thanks for testing the v3 K1 SPL patchset.
Actually your result confirms the SPL patchset is working correctly and the build/test procedure is generally complete.
OK, thanks for confirming.
Quoted 10 lines
PS: I added some walk through to the key lines in your log below (for you and for the community's future reference purpose), but for here please be noted that as I said in the doc patch [1]:
"After DDR init succeeds, SPL proceeds to load U-Boot proper. If
U-Boot proper is not yet available (as in SPL-only testing), you will see SPL: failed to boot from all boot devices - this is expected and confirms that SPL with DDR init is working correctly."
Yes, I missed that part of your doc, so as Heinrich says in
his comment to the v2, you should move that higher or make
it more obvious to see.
I was expecting to see some of what you had in v1 of the
doc patch, in "Expected Output".
Is there some debug macro to enable that output ?
Quoted 2 lines
Back to the patch series itself, your log is a good validation of the v3 SPL patchset.
OK, in this case you can add my:
for the next iteration, or directly to this v3 if there
is no further one.
PATCH v2 1/1 doc: spacemit: add K1 SPL build and test guide
In reply to Raymond MaoThe 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.
---
Changes in v2:
- Update vendor U-Boot repo from bianbu-linux to spacemit-buildroot, and specify the k1-bl-v2.2.y branch
- Fix fsbl.json path to board/spacemit/k1-x/configs/
- Add mkdir -p for spl_bin directory in fsbl.sh
- Replace verbose DDR training log with concise SPL boot output
- Update expected output notes for SPI NOR availability
doc/board/spacemit/index.rst | 1 + doc/board/spacemit/k1-spl.rst | 196 ++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 doc/board/spacemit/k1-spl.rst
doc/board/spacemit/index.rst +1 -0
@@ -6,4 +6,5 @@ SpacemiT :maxdepth: 1 bananapi-f3 + k1-spl
doc/board/spacemit/k1-spl.rst new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2] doc: spacemit: add K1 SPL build and test guide
Quoted 35 lines · Guodong Xu
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.
Signed-off-by Guodong Xu <[email protected]>---
Changes in v2:
- Update vendor U-Boot repo from bianbu-linux to spacemit-buildroot, and specify the k1-bl-v2.2.y branch
- Fix fsbl.json path to board/spacemit/k1-x/configs/
- Add mkdir -p forspl_bindirectory infsbl.sh
- Replace verbose DDR training log with concise SPL boot output
- Update expected output notes for SPI NOR availabilitydoc/board/spacemit/index.rst | 1 + doc/board/spacemit/k1-spl.rst | 196 ++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+)create mode 100644
doc/board/spacemit/k1-spl.rstdoc/board/spacemit/index.rst +1
-0@@ -6,4 +6,5 @@ SpacemiT :maxdepth: 1 bananapi-f3 + k1-spldoc/board/spacemit/k1-spl.rst new file +0
-0
doc/board/spacemit/k1-spl.rst line 8
Quoted 8 lines
doc/board/spacemit/k1-spl.rst new file +8
-0@@ -0,0 +1,196 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +SpacemiT K1 SPL Build and Test Guide +===================================== + +This guide explains how to build and test U-Boot SPL on SpacemiT K1 based +boards. It covers building SPL with DDR initialization, generating the signed +FSBL image, and deploying via USB fastboot.
Thanks a lot for providing this documentation.
Quoted 7 lines
doc/board/spacemit/k1-spl.rst new file +7
-0+ +Tested boards: Banana Pi BPI-F3, MusePi Pro. + +Prerequisites +~~~~~~~~~~~~~ + +- A SpacemiT K1 board with USB Type-C and UART access
doc/board/spacemit/k1-spl.rst line 25
Quoted 10 lines
doc/board/spacemit/k1-spl.rst new file +10
-0+- USB-to-UART adapter (3.3V TTL) +- ``minicom`` or equivalent serial terminal, configured at 115200 8N1 +- ``fastboot`` tool on the host + +Hardware Setup +~~~~~~~~~~~~~~ + +**1. UART Connection** + +Connect a 3.3V USB-to-UART cable to the **J25** header on the BPI-F3.
Isn't this documentation meant to apply to all K1 boards?
How about:
Connect a 3.3V USB-to-UART cable to the board's UART header (J25 on the BPI-F3).
doc/board/spacemit/k1-spl.rst line 26
Quoted 1 line
doc/board/spacemit/k1-spl.rst new file +1
-0+Remove all other cables first, then attach UART::
This sentence should precede before "Connect a 3.3V ....".
doc/board/spacemit/k1-spl.rst line 36
Quoted 10 lines
doc/board/spacemit/k1-spl.rst new file +10
-0+ + BPI-F3 top view + +--------------------------------------------------+ + | | + | J15: USB-C [====] [FDL] [PWR] [RST] | + | | + | | + | J25 (UART header) | + | [TXD] [RXD] [GND] | + +--------------------------------------------------+
I guess the ragged right border is not intentional.
Quoted 98 lines
doc/board/spacemit/k1-spl.rst new file +98
-0+ +After UART is connected, attach the USB Type-C cable to J15 to power on. + +**2. Serial Console** + +.. code-block:: console + + $ minicom -D /dev/ttyUSB0 + +Default baudrate: 115200. + +Building U-Boot SPL +~~~~~~~~~~~~~~~~~~~~ + +**1. Obtain the DDR training firmware** + +The DDR training firmware is a proprietary binary provided by SpacemiT. It is +not included in U-Boot and must be downloaded separately from: + +https://github.com/spacemit-com/spacemit-firmware/tree/master/k1/v0.2 + +Download ``ddr_fw.bin`` from that directory. + +This binary is integrated into the SPL image at build time via the binman +framework. When the SPL image is loaded to SRAM (e.g., via USB fastboot), +the SPL executes the DDR firmware from SRAM to perform DDR initialization. + +**2. Build SPL** + +.. code-block:: console + + $ export CROSS_COMPILE=riscv64-linux-gnu- + $ export ARCH=riscv + $ export DDR_FW_FILE=$(pwd)/ddr_fw.bin + $ make spacemit_k1_defconfig + $ make + +Output: ``u-boot-spl-ddr.bin`` in the build directory. This image contains the +SPL code and the DDR firmware blob packaged together via binman. + +.. note:: + + If ``DDR_FW_FILE`` is not set, the build completes with an empty + placeholder. The resulting SPL will boot but cannot initialize DDR. + +**3. Generate signed FSBL image** + +The K1 BootROM requires a signed first-stage bootloader (FSBL). The signing +tool (``tools/build_binary_file.py``) is in SpacemiT's vendor U-Boot repository: + +.. code-block:: console + + $ git clone -b k1-bl-v2.2.y https://gitee.com/spacemit-buildroot/uboot-2022.10 + +The script uses ``fsbl_ddr.json`` which may not exist by default. If +``fsbl_ddr.json`` does not exist in +``uboot-2022.10/board/spacemit/k1-x/configs/``, +create it by copying ``fsbl.json`` and replacing the reference to +``u-boot-spl.bin`` with ``u-boot-spl-ddr.bin``: + +.. code-block:: console + + $ cd uboot-2022.10/board/spacemit/k1-x/configs + $ cp fsbl.json fsbl_ddr.json + $ sed -i 's/u-boot-spl\.bin/u-boot-spl-ddr.bin/g' fsbl_ddr.json + +Create the ``fsbl.sh`` script below in the ``uboot-2022.10`` directory. +Update the path variables to match your local setup: + +.. code-block:: bash + + #!/bin/sh + MAINLINE_UBOOT_IMG_PATH="{your path}/u-boot" + MAINLINE_SPL_IMG_PATH="{your path}/u-boot/spl" + FSBL_PATH="{your path}/uboot-2022.10/spl_bin" + KEY_TOOL_PATH="{your path}/uboot-2022.10/tools" + CONFIG_PATH="{your path}/uboot-2022.10/board/spacemit/k1-x/configs" + + mkdir -p ${FSBL_PATH} + echo "Clean binaries in ${FSBL_PATH}" + rm -f ${FSBL_PATH}/u-boot-spl-ddr.bin + rm -f ${FSBL_PATH}/u-boot-spl.bin + + if [ ! -d ${MAINLINE_SPL_IMG_PATH} ]; then + MAINLINE_UBOOT_IMG_PATH="{your path}/build" + MAINLINE_SPL_IMG_PATH="{your path}/build/spl" + fi + + cp ${MAINLINE_UBOOT_IMG_PATH}/u-boot-spl-ddr.bin ${FSBL_PATH}/ + python3 ${KEY_TOOL_PATH}/build_binary_file.py \ + -c ${CONFIG_PATH}/fsbl_ddr.json \ + -o ${FSBL_PATH}/FSBL.bin + +Then run: + +.. code-block:: console + + $ chmod +x fsbl.sh
doc/board/spacemit/k1-spl.rst line 144
Quoted 10 lines
doc/board/spacemit/k1-spl.rst new file +10
-0+ $ ./fsbl.sh + +Output: ``FSBL.bin`` in the ``spl_bin`` directory, ready for deployment. + +Deploying via USB Fastboot +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To enter BootROM fastboot mode: + +1. Disconnect USB Type-C cable from J15 (power off)
J15 is only the designation on the BPI-F3. A more generic term may be needed.
How about:
Power of the board by disconnecting the OTG port (J15 on BPI-F3) and any additional power supply (12 V on BPI-F3).
doc/board/spacemit/k1-spl.rst line 146
Quoted 2 lines
doc/board/spacemit/k1-spl.rst new file +2
-0+2. **Press and hold** the FDL button (see board layout above) +3. Reconnect USB Type-C cable while holding the FDL button
How about:
While holding the FDL button use an USB cable to connect the OTG port to your host. This cable will be used by fastboot to upload the firmware.
The OTG USB should be detected as
361c:1001 DFU USB download gadget
doc/board/spacemit/k1-spl.rst line 147
Quoted 1 line
doc/board/spacemit/k1-spl.rst new file +1
-0+4. Release the FDL button
https://docs.banana-pi.org/en/BPI-F3/GettingStarted_BPI-F3 has additionally:
(If you are worried about insufficient USB power, you can first plug in the power, then release the button, and then plug in the USB cable)
doc/board/spacemit/k1-spl.rst line 156
Quoted 9 lines
doc/board/spacemit/k1-spl.rst new file +9
-0+ +The serial console should show a BootROM prompt indicating it is ready to +accept an image via USB. + +On the host: + +.. code-block:: console + + $ sudo fastboot stage FSBL.bin
Maybe a minimum tested version of fastboot should be indicated, cf.
https://gist.github.com/orangecms/8624aa82bab4931f787b5eee572f7668
doc/board/spacemit/k1-spl.rst line 162
Quoted 6 lines
doc/board/spacemit/k1-spl.rst new file +6
-0+ $ sudo fastboot continue + +Expected Output +~~~~~~~~~~~~~~~~ + +After successful SPL boot with DDR initialization, the serial console displays::
At least the first line will be different.
%s/After/During/
%s/displays/shows output like/
Quoted 14 lines
doc/board/spacemit/k1-spl.rst new file +14
-0+ + U-Boot SPL 2026.04-rc4-00543-g2ba03a569e61 (Mar 26 2026 - 16:48:44 +0100) + Fail to detect board:-2> + vdd_core, value:900000 + vdd_1v8, value:1800000 + vdd_1v8_mmc, value:500000 + DDR firmware: [0xc08159c0]:0xf0227179, size:0x8d98 + DDR is ready + SPL: Unsupported Boot Device! + SPL: failed to boot from all boot devices + ### ERROR ### Please RESET the board ### + +To walk through the key lines: + +- ``DDR firmware: [...], size:0x8d98`` - DDR firmware loaded successfully
doc/board/spacemit/k1-spl.rst line 187
Quoted 10 lines
doc/board/spacemit/k1-spl.rst new file +10
-0+- ``DDR is ready`` - DDR initialization completed +- ``SPL: failed to boot from all boot devices`` - expected at this stage, + confirms that SPL with DDR init is working correctly + +.. note:: + + After DDR init succeeds, SPL proceeds to load U-Boot proper. Since + SPI NOR storage driver support is not yet available, SPL cannot + transition into U-Boot proper. When U-Boot stage support is ready, + this document will be updated.
Please, move the note to the top of the document so that reader does not discover at the end of the process that their board does not boot anymore.
Best regards
Heinrich
Quoted 9 lines
doc/board/spacemit/k1-spl.rst new file +9
-0+ +If SPL hangs before printing DDR messages, verify that ``DDR_FW_FILE`` was set +during build and that ``ddr_fw.bin`` is not empty. + +References +~~~~~~~~~~~ + +- `DDR firmware repository <https://github.com/spacemit-com/spacemit-firmware>`_ +- `SpacemiT vendor U-Boot (signing tool) <https://gitee.com/spacemit-buildroot/uboot-2022.10>`_
Re: [PATCH v2] doc: spacemit: add K1 SPL build and test guide
Hi Heinrich, Guodong Xu,
Quoted 1 line · Heinrich Schuchardt
Thanks a lot for providing this documentation.
Yes, I also add my thanks. This is very useful to help passing-by random-joe-testers.
Quoted 9 lines
doc/board/spacemit/k1-spl.rst line 25
Quoted 6 lines
doc/board/spacemit/k1-spl.rst new file +6
-0+Hardware Setup +~~~~~~~~~~~~~~ + +**1. UART Connection** + +Connect a 3.3V USB-to-UART cable to the **J25** header on the BPI-F3.Isn't this documentation meant to apply to all K1 boards?
Quoted 3 lines
How about:
Connect a 3.3V USB-to-UART cable to the board's UART header (J25 on the BPI-F3).
I'd even go a step further, i.e. keep this doc completely board-agnostic
and keep board-specific parts for their own pages. That would mean moving
the "Deploying via USB Fastboot" section out of this document.
This is only IMHO, don't take my personal preference as the maintainers one.
Quoted 9 lines
doc/board/spacemit/k1-spl.rst line 144
Quoted 6 lines
doc/board/spacemit/k1-spl.rst new file +6
-0+Deploying via USB Fastboot +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To enter BootROM fastboot mode: + +1. Disconnect USB Type-C cable from J15 (power off)J15 is only the designation on the BPI-F3. A more generic term may be needed.
Quoted 3 lines
How about:
Power of the board by disconnecting the OTG port (J15 on BPI-F3) and any additional power supply (12 V on BPI-F3).
Maybe just: "Power off the board by unplugging its power supply."
Quoted 1 line
Quoted 1 line
+2. **Press and hold** the FDL button (see board layout above)
The FDL button is also probably BPI-F3 specific information, I see picture
of the OrangePi RV2 having a "Boot Key", which may be the equivalent one.
Quoted 8 lines
Quoted 6 lines
+.. note::
+
+ After DDR init succeeds, SPL proceeds to load U-Boot proper. Since + SPI NOR storage driver support is not yet available, SPL cannot + transition into U-Boot proper. When U-Boot stage support is ready, + this document will be updated.Please, move the note to the top of the document so that reader does not discover at the end of the process that their board does not boot anymore.
Yes, I agree. I missed it, probably out of haste, but still.
Thanks again