Add pinctrl/GPIO and SPI NOR support for Spacemit K1
Subsystems (6)
v3 cover Add pinctrl/GPIO and SPI NOR support for Spacemit K1
From: Raymond Mao <[email protected]>
This series adds pinctrl, GPIO, and SPI NOR flash support for the SpacemiT K1. Drivers are usable in both SPL and U-Boot proper. In SPL, the QSPI controller and SPI NOR flash are probed during early init, and the SPL boot device is changed from memory-mapped NOR to SPI so the common loader reads the next-stage image from NOR. It sits on top of the K1 SPL bring-up series [1], which depends on the K1 clock/reset/dts migration series [2].
To apply on origin/master, two prerequisite series on lore must be applied first, in this order:
1. K1 clock/reset/dts migration [2] (8 patches) 2. K1 SPL bring-up v4 [1] (14 patches) 3. This series (9 patches)
[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://lore.kernel.org/u-boot/20260510-b4-k1-clk-reset-upstream-dts-v1-0-db0b0503ee44@riscstar.com/
Guodong Xu (3):
spl: k1: enable SPI NOR flash detection and boot
spacemit: k1: Add multiple device tree support
configs: k1: enable pinctrl and gpio
Raymond Mao (6):
mtd: spi: select SPL_SPI_FLASH_TINY in SPL stage
mtd: spi: enable spi_nor_remove() in soft reset config
spi: fsl: add support for Spacemit K1 SoC
riscv: binman: Always set default configuration in FIT image
pinctrl: add pinctrl driver for Spacemit K1 SoC
gpio: add gpio driver for Spacemit K1 SoC
arch/riscv/dts/binman.dtsi | 2 - arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 273 ++++++++++++ board/spacemit/k1/MAINTAINERS | 3 + board/spacemit/k1/spl.c | 78 +++- configs/spacemit_k1_defconfig | 36 +- drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/spacemit_gpio.c | 253 +++++++++++ drivers/mtd/spi/Makefile | 5 +- drivers/mtd/spi/sf_probe.c | 8 +- drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/spacemit/Kconfig | 9 + drivers/pinctrl/spacemit/Makefile | 2 + drivers/pinctrl/spacemit/pinctrl-k1.c | 546 +++++++++++++++++++++++ drivers/spi/fsl_qspi.c | 9 + 16 files changed, 1217 insertions(+), 18 deletions(-) create mode 100644 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi create mode 100644 drivers/gpio/spacemit_gpio.c create mode 100644 drivers/pinctrl/spacemit/Kconfig create mode 100644 drivers/pinctrl/spacemit/Makefile create mode 100644 drivers/pinctrl/spacemit/pinctrl-k1.c
Signature · 1 line
2.25.1
PATCH v3 1/9 mtd: spi: select SPL_SPI_FLASH_TINY in SPL stage
From: Raymond Mao <[email protected]>
Fix to select CONFIG_SPL_SPI_FLASH_TINY in SPL_BUILD stage.
---
Changes in v2:
- None.
Changes in v3:
- None.
drivers/mtd/spi/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/spi/Makefile +2 -3
@@ -8,14 +8,13 @@ spi-nor-y := sf_probe.o spi-nor-ids.o ifdef CONFIG_XPL_BUILD obj-$(CONFIG_SPL_SPI_BOOT) += fsl_espi_spl.o +endif + ifeq ($(CONFIG_$(PHASE_)SPI_FLASH_TINY),y) spi-nor-y += spi-nor-tiny.o else spi-nor-y += spi-nor-core.o endif -else -spi-nor-y += spi-nor-core.o -endif obj-$(CONFIG_SPI_FLASH) += spi-nor.o obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o
Signature · 1 line
2.25.1
PATCH v3 2/9 mtd: spi: enable spi_nor_remove() in soft reset config
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
spi_nor_remove() is only implemented in spi-nor-core.o, not spi-nor-tiny.o.
So make spi_nor_remove() only valid for CONFIG_SPI_FLASH_SOFT_RESET.
---
Changes in v2:
- None.
Changes in v3:
- None.
drivers/mtd/spi/sf_probe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/spi/sf_probe.c +5 -3
@@ -229,9 +229,11 @@ static int spi_flash_std_remove(struct udevice *dev)spi_mem_dirmap_destroy (flash->dirmap.rdesc); } - ret =spi_nor_remove (flash); -if (ret) -return ret; +if (CONFIG_IS_ENABLED (SPI_FLASH_SOFT_RESET )) { + ret =spi_nor_remove (flash); +if (ret) +return ret; + }if (CONFIG_IS_ENABLED (SPI_FLASH_MTD ))spi_flash_mtd_unregister (flash);
Signature · 1 line
2.25.1
PATCH v3 3/9 spi: fsl: add support for Spacemit K1 SoC
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Make FSL QSPI driver supporting Spacemit K1 SoC.
---
Changes in v2:
- None.
Changes in v3:
- None.
drivers/spi/fsl_qspi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/spi/fsl_qspi.c +9 -0
@@ -267,6 +267,14 @@ static const struct fsl_qspi_devtype_data ls2080a_data = { .little_endian = true, }; +static const struct fsl_qspi_devtype_data spacemit_k1_data = { + .rxfifo =SZ_128 , + .txfifo =SZ_256 , + .ahb_buf_size =SZ_128 , + .quirks =QUADSPI_QUIRK_TKT253890 , + .little_endian = true, +}; +struct fsl_qspi {struct udevice *dev;void __iomem *iobase;
@@ -870,6 +878,7 @@ static const struct udevice_id fsl_qspi_ids[] = { { .compatible = "fsl,ls1021a-qspi", .data = (ulong)&ls1021a_data, }, { .compatible = "fsl,ls1088a-qspi", .data = (ulong)&ls2080a_data, }, { .compatible = "fsl,ls2080a-qspi", .data = (ulong)&ls2080a_data, }, + { .compatible = "spacemit,k1-qspi", .data = (ulong)&spacemit_k1_data, }, { } };
Signature · 1 line
2.25.1
PATCH v3 4/9 spl: k1: enable SPI NOR flash detection and boot
In reply to Raymond MaoFrom: Guodong Xu <[email protected]>
Add nor_early_init() to probe the QSPI controller and SPI NOR flash in SPL. Switch spl_boot_device() to BOOT_DEVICE_SPI so the board boots from SPI flash.
Change the default device tree to k1-musepi-pro, whose u-boot overlay already defines the QSPI controller and flash node with bootph-pre-ram markers. Enable the required SPI driver model and flash config options.
---
Changes in v2:
- Renamed and reworked from v1 11/16 "board: k1: enable SPI NOR flash in SPL".
- New k1-musepi-pro-u-boot.dtsi overlay; default DT switched to it.
- SPL probes SPI NOR in early init and loads next stage from it. Changes in v3:
- None.
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi | 273 +++++++++++++++++++++++ board/spacemit/k1/spl.c | 24 +- configs/spacemit_k1_defconfig | 25 ++- 3 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi new file +273 -0
@@ -0,0 +1,273 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Copyright (C) 2026 RISCstar Ltd. + */ + +#include <dt-bindings/clock/spacemit,k1-syscon.h> +#include "binman.dtsi" + +/ { + aliases { + console = &uart0; + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x00000000 0x00000000 0x00000000 0x80000000>; + }; +}; + +&syscon_mpmu { + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>, + <&pll CLK_PLL1_D4>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m", + "pll1_d4"; +}; + +&syscon_apbc { + clocks = <&osc_32k>, <&vctcxo_1m>, <&vctcxo_3m>, <&vctcxo_24m>, + <&pll CLK_PLL1_D4>, + <&syscon_mpmu CLK_PLL1_31P5>, + <&syscon_apmu CLK_PMUA_ACLK>; + clock-names = "osc", "vctcxo_1m", "vctcxo_3m", "vctcxo_24m", + "pll1_d4", "pll1_d78_31p5", "pmua_aclk"; +}; + +&uart0 { + bootph-pre-ram; +}; + +&osc_32k { + bootph-pre-ram; +}; + +&vctcxo_1m { + bootph-pre-ram; +}; + +&vctcxo_3m { + bootph-pre-ram; +}; + +&vctcxo_24m { + bootph-pre-ram; +}; + +&syscon_mpmu { + bootph-pre-ram; +}; + +&pll { + bootph-pre-ram; +}; + +&syscon_apmu { + bootph-pre-ram; +}; + +&syscon_apbc { + bootph-pre-ram; +}; + +&i2c2 { + bootph-pre-ram; + status = "okay"; + pinctrl-0 = <&i2c2_0_cfg>; + pinctrl-names = "default"; + resets = <&syscon_apbc RESET_TWSI2>; + + eeprom@50 { + bootph-pre-ram; + status = "okay"; + compatible = "atmel,24c02"; + reg = <0x50>; + vcc-supply = <&buck3_1v8>; /* EEPROM_VCC1V8 */ + pagesize = <16>; + read-only; + size = <256>; + + nvmem-layout { + compatible = "onie,tlv-layout"; + + mac-address { + #nvmem-cell-cells = <1>; + }; + + num-macs { + }; + + serial-number { + }; + }; + }; +}; + +&i2c8 { + bootph-pre-ram; + pinctrl-0 = <&i2c8_cfg>; + pinctrl-names = "default"; + resets = <&syscon_apbc RESET_TWSI8>; + status = "okay"; + + pmic@41 { + bootph-pre-ram; + compatible = "spacemit,p1"; + reg = <0x41>; + interrupts = <64>; + status = "okay"; + + regulators { + buck1 { + bootph-pre-ram; + regulator-name = "vdd_core"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck3_1v8: buck3 { + bootph-pre-ram; + regulator-name = "vdd_1v8"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1800000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + 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 { + bootph-pre-ram; + regulator-name = "vdd_1v8_mmc"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-boot-on; + }; + + 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>; + regulator-boot-on; + }; + + 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>; + regulator-always-on; + }; + + dldo5 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo6 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-always-on; + }; + + dldo7 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + }; + }; +}; + +&qspi { + bootph-pre-ram; + pinctrl-names = "default"; + pinctrl-0 = <&qspi_cfg>; + status = "okay"; + + flash@0 { + bootph-pre-ram; + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <26500000>; + m25p,fast-read; + broken-flash-reset; + status = "okay"; + }; +}; + +&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/spl.c +23 -1
@@ -16,6 +16,7 @@#include <linux/delay.h> #include <log.h> #include <power/regulator.h> +#include <spi_flash.h> #include <spl.h> #include <tlv_eeprom.h> #include "tlv_codes.h"
@@ -306,6 +307,26 @@ void ddr_early_init(void)log_info ("DDR is not ready\n" ); } +void nor_early_init (void ) +{ +struct udevice *dev; +int ret; + + ret =uclass_get_device (UCLASS_SPI ,0 , &dev); +if (ret) +panic ("Fail to detect spi controller.\n" ); +udelay (10 ); + ret =uclass_get_device (UCLASS_SPI_FLASH ,0 , &dev); +if (ret) +log_info ("Fail to detect spi nor flash.\n" ); +udelay (10 ); +} + +void *board_spl_fit_buffer_addr (ulong fit_size,int sectors,int bl_len) +{ +return (void *)CONFIG_SPL_LOAD_FIT_ADDRESS ; +} +void board_init_f (ulong dummy) {u8 i2c_buf[I2C_BUF_SIZE ] = {0 };
@@ -331,11 +352,12 @@ void board_init_f(ulong dummy)pmic_init ();ddr_early_init (); +nor_early_init (); }u32 spl_boot_device (void ) { -return BOOT_DEVICE_NOR ; +return BOOT_DEVICE_SPI ; }void spl_board_init (void )
configs/spacemit_k1_defconfig +23 -2
@@ -1,15 +1,19 @@ CONFIG_RISCV=y CONFIG_SYS_MALLOC_LEN=0x1000000 -CONFIG_SYS_MALLOC_F_LEN=0x5000 +CONFIG_SYS_MALLOC_F_LEN=0x10000 CONFIG_NR_DRAM_BANKS=2 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x1000000 -CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-bananapi-f3" +CONFIG_DEFAULT_DEVICE_TREE="spacemit/k1-musepi-pro" CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000 CONFIG_SPL_STACK=0xc083fb00 CONFIG_SPL_TEXT_BASE=0xc0801000 CONFIG_SPL_BSS_START_ADDR=0xc083fc00 CONFIG_SPL_BSS_MAX_SIZE=0x400 +CONFIG_SPL_STACK_R=y +CONFIG_SPL_STACK_R_ADDR=0xc00000 +CONFIG_SPL_SYS_MALLOC_SIMPLE=y +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000 CONFIG_SYS_BOOTM_LEN=0xa000000 CONFIG_SYS_LOAD_ADDR=0x200000 CONFIG_SPL_SIZE_LIMIT=0x31000
@@ -23,6 +27,8 @@ CONFIG_SPL_RISCV_MMODE=y # CONFIG_SPL_SMP is not set CONFIG_STACK_SIZE=0x100000 CONFIG_FIT=y +CONFIG_SPL_HAS_LOAD_FIT_ADDRESS=y +CONFIG_SPL_LOAD_FIT_ADDRESS=0x08000000 CONFIG_SUPPORT_RAW_INITRD=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_CBSIZE=256
@@ -64,3 +70,18 @@ CONFIG_SYS_NS16550=y CONFIG_SYS_NS16550_MEM32=y CONFIG_TIMER_EARLY=y CONFIG_SPL_LIB_RATIONAL=y +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_DM_SPI_FLASH=y +CONFIG_FSL_QSPI=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_SPI_MEM=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x000a0000 +CONFIG_CMD_SPI=y +CONFIG_SPL_SPI=y +CONFIG_SPL_DM_SPI=y +CONFIG_SPL_DM_SPI_FLASH=y +CONFIG_SPL_SPI_LOAD=y +CONFIG_SPL_SPI_FLASH_TINY=y +CONFIG_SPL_SPI_FLASH_SUPPORT=y
Signature · 1 line
2.25.1
PATCH v3 5/9 riscv: binman: Always set default configuration in FIT image
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
When CONFIG_MULTI_DTB_FIT is enabled, the FIT image contains multiple device tree configurations for different boards. The default configuration must be explicitly set to ensure the FIT framework traverses all available configurations instead of falling back to CONFIG_DEFAULT_DEVICE_TREE.
Without this default property, fit_find_config_node() will use CONFIG_DEFAULT_DEVICE_TREE as the configuration name to match. This prevents the SPL from correctly selecting the appropriate DTB based on runtime board detection (e.g., from EEPROM).
Remove the conditional guard so that "default = conf-1" is always present in the FIT image, regardless of CONFIG_MULTI_DTB_FIT.
---
Changes in v2:
- None.
Changes in v3:
- None.
arch/riscv/dts/binman.dtsi | 2 -- 1 file changed, 2 deletions(-)
arch/riscv/dts/binman.dtsi +0 -2
@@ -93,9 +93,7 @@ configurations { -#ifndef CONFIG_MULTI_DTB_FIT default = "conf-1"; -#endif #if !defined(CONFIG_OF_BOARD) || defined(CONFIG_MULTI_DTB_FIT) @conf-SEQ {
Signature · 1 line
2.25.1
PATCH v3 6/9 spacemit: k1: Add multiple device tree support
In reply to Raymond MaoFrom: Guodong Xu <[email protected]>
Enable multiple DTB support in the FIT image for the Spacemit K1 SoC, allowing a single U-Boot binary to support different board variants.
The SPL reads the board type from EEPROM and selects the corresponding device tree at runtime via board_fit_config_name_match(), ensuring the correct hardware description is passed to U-Boot proper.
---
Changes in v2:
- Reworked. Drop the v1 approach (new local k1-muse-pi-pro.dts, enlarge SYS_MALLOC_F_LEN, MMODE switch).
- Use binman --fit-multi-config so u-boot.itb packs multiple board DTs from the upstream tree.
Changes in v3:
- Append CONFIG_SPL_BOARD_INIT. Move the operation on product name in board_init_r stage.
board/spacemit/k1/spl.c | 64 +++++++++++++++++++++++++++++------ configs/spacemit_k1_defconfig | 3 ++ 2 files changed, 56 insertions(+), 11 deletions(-)
board/spacemit/k1/spl.c +53 -11
@@ -55,6 +55,8 @@ struct ddr_cfg {binman_sym_declare (ulong, ddr_fw, image_pos);binman_sym_declare (ulong, ddr_fw, size); +char product_name[I2C_BUF_SIZE ] ="k1" ; +static void i2c_early_init (void ) {struct udevice *bus;
@@ -104,6 +106,37 @@ int read_product_name(char *name, int size)return -ENOENT ; } +static const struct { +const char *eeprom_name; +const char *fit_name; +} k1_board_map[] = { + {"k1-x_MUSE-Pi-Pro" ,"spacemit/k1-musepi-pro" }, + {"k1-x_deb1" ,"spacemit/k1-bananapi-f3" }, + {"k1-x_milkv-jupiter" ,"spacemit/k1-milkv-jupiter" }, +}; + +static void fixup_product_name (void ) +{ +char fdt_name[I2C_BUF_SIZE ]; +int i; + +memset (fdt_name,0 ,I2C_BUF_SIZE ); +for (i =0 ; i <ARRAY_SIZE (k1_board_map); i++) { +if (!strncmp (product_name, k1_board_map[i].eeprom_name, +strlen (k1_board_map[i].eeprom_name))) { +snprintf (fdt_name,I2C_BUF_SIZE ,"%s" , + k1_board_map[i].fit_name); +break ; + } + } +if (fdt_name[0 ] =='\0' ) { +/* set default board name */ +sprintf (fdt_name,CONFIG_DEFAULT_DEVICE_TREE ); + } +memset (product_name,0 ,I2C_BUF_SIZE ); +memcpy (product_name, fdt_name,I2C_BUF_SIZE ); +} +static void clk_early_init (void ) {struct udevice *dev;
@@ -322,14 +355,8 @@ void nor_early_init(void)udelay (10 ); } -void *board_spl_fit_buffer_addr (ulong fit_size,int sectors,int bl_len) -{ -return (void *)CONFIG_SPL_LOAD_FIT_ADDRESS ; -} -void board_init_f (ulong dummy) { -u8 i2c_buf[I2C_BUF_SIZE ] = {0 };int ret; ret =spl_early_init ();
@@ -344,11 +371,6 @@ void board_init_f(ulong dummy)preloader_console_init ();i2c_early_init (); - ret =read_product_name (i2c_buf,I2C_BUF_SIZE ); -if (ret) -log_info ("Fail to detect board:%d\n" , ret); -else -log_info ("Get board name:%s\n" , (char *)i2c_buf);pmic_init ();ddr_early_init ();
@@ -362,4 +384,24 @@ u32 spl_boot_device(void)void spl_board_init (void ) { +int ret; + + ret =read_product_name (product_name,I2C_BUF_SIZE ); +if (ret) +log_info ("Fail to detect board:%d\n" , ret); +else +log_info ("Get board name:%s\n" , product_name); +fixup_product_name (); +} + +int board_fit_config_name_match (const char *name) +{ +if (!strcmp (name, product_name)) +return 0 ; +return -ENOENT ; +} + +void *board_spl_fit_buffer_addr (ulong fit_size,int sectors,int bl_len) +{ +return (void *)CONFIG_SPL_LOAD_FIT_ADDRESS ; }
configs/spacemit_k1_defconfig +3 -0
@@ -5,6 +5,7 @@ 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-musepi-pro" +CONFIG_OF_LIST="spacemit/k1-bananapi-f3 spacemit/k1-musepi-pro spacemit/k1-milkv-jupiter" CONFIG_SPL_SYS_MALLOC_F_LEN=0x4000 CONFIG_SPL_STACK=0xc083fb00 CONFIG_SPL_TEXT_BASE=0xc0801000
@@ -27,6 +28,7 @@ CONFIG_SPL_RISCV_MMODE=y # CONFIG_SPL_SMP is not set CONFIG_STACK_SIZE=0x100000 CONFIG_FIT=y +CONFIG_MULTI_DTB_FIT=y CONFIG_SPL_HAS_LOAD_FIT_ADDRESS=y CONFIG_SPL_LOAD_FIT_ADDRESS=0x08000000 CONFIG_SUPPORT_RAW_INITRD=y
@@ -85,3 +87,4 @@ CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_SPI_LOAD=y CONFIG_SPL_SPI_FLASH_TINY=y CONFIG_SPL_SPI_FLASH_SUPPORT=y +CONFIG_SPL_BOARD_INIT=y
Signature · 1 line
2.25.1
PATCH v3 7/9 pinctrl: add pinctrl driver for Spacemit K1 SoC
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Add pinctrl driver for Spacemit K1 SoC.
---
Changes in v2:
- No change.
Changes in v3:
- Fix CONFIG_$(PHASE_)PINCTRL_SPACEMIT_K1 to CONFIG_PINCTRL_SPACEMIT_K1. Do not enable pinctrl driver in SPL stage.
drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/spacemit/Kconfig | 9 + drivers/pinctrl/spacemit/Makefile | 2 + drivers/pinctrl/spacemit/pinctrl-k1.c | 546 ++++++++++++++++++++++++++ 5 files changed, 559 insertions(+) create mode 100644 drivers/pinctrl/spacemit/Kconfig create mode 100644 drivers/pinctrl/spacemit/Makefile create mode 100644 drivers/pinctrl/spacemit/pinctrl-k1.c
drivers/pinctrl/Kconfig +1 -0
@@ -419,6 +419,7 @@ source "drivers/pinctrl/nxp/Kconfig" source "drivers/pinctrl/qcom/Kconfig" source "drivers/pinctrl/renesas/Kconfig" source "drivers/pinctrl/rockchip/Kconfig" +source "drivers/pinctrl/spacemit/Kconfig" source "drivers/pinctrl/sunxi/Kconfig" source "drivers/pinctrl/tegra/Kconfig" source "drivers/pinctrl/uniphier/Kconfig"
drivers/pinctrl/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_PINCTRL_SCMI) += pinctrl-scmi.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_STI) += pinctrl-sti.o obj-$(CONFIG_PINCTRL_STM32) += pinctrl_stm32.o +obj-$(CONFIG_PINCTRL_SPACEMIT_K1) += spacemit/ obj-$(CONFIG_$(PHASE_)PINCTRL_SX150X) += pinctrl-sx150x.o obj-$(CONFIG_$(PHASE_)PINCTRL_STMFX) += pinctrl-stmfx.o obj-$(CONFIG_PINCTRL_TH1520) += pinctrl-th1520.o
drivers/pinctrl/spacemit/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config PINCTRL_SPACEMIT_K1 + bool "Spacemit K1 SoC pinctrl driver" + depends on PINCTRL_GENERIC && DM + help + Supports pin multiplexing control on Spacemit K1 SoCs. + + The driver is controlled by a device tree node which contains both + the GPIO definitions and pin control functions for each available + multiplex function.
drivers/pinctrl/spacemit/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-y += pinctrl-k1.o
drivers/pinctrl/spacemit/pinctrl-k1.c new file +546 -0
546 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 8/9 gpio: add gpio driver for Spacemit K1 SoC
In reply to Raymond MaoFrom: Raymond Mao <[email protected]>
Enable gpio driver for Spacemit K1 SoC.
---
Changes in v2:
- Add .request and .rfree ops: delegate to pinctrl's gpio_request_enable / gpio_disable_free.
- xlate(): use gpio_flags_xlate() instead of raw flags. Changes in v3:
- None.
drivers/gpio/Kconfig | 8 ++ drivers/gpio/Makefile | 1 + drivers/gpio/spacemit_gpio.c | 253 +++++++++++++++++++++++++++++++++++ 3 files changed, 262 insertions(+) create mode 100644 drivers/gpio/spacemit_gpio.c
drivers/gpio/Kconfig +8 -0
@@ -449,6 +449,14 @@ config SANDBOX_GPIO_COUNT of 'anonymous' GPIOs that do not belong to any device or bank. Select a suitable value depending on your needs. +config SPACEMIT_GPIO + bool "Spacemit K1 GPIO driver" + depends on DM_GPIO && TARGET_SPACEMIT_K1 + help + Support the GPIO device in Spacemit SoCs. The GPIOs are arranged + into a number of banks (different for each SoC type) each with 32 + GPIOs. + config SUNXI_GPIO bool "Allwinner GPIO driver" depends on ARCH_SUNXI
drivers/gpio/Makefile +1 -0
@@ -66,6 +66,7 @@ obj-$(CONFIG_MVEBU_GPIO) += mvebu_gpio.o obj-$(CONFIG_MSM_GPIO) += msm_gpio.o obj-$(CONFIG_$(PHASE_)PCF8575_GPIO) += pcf8575_gpio.o obj-$(CONFIG_$(PHASE_)QCOM_PMIC_GPIO) += qcom_pmic_gpio.o qcom_spmi_gpio.o +obj-$(CONFIG_$(PHASE_)SPACEMIT_GPIO) += spacemit_gpio.o obj-$(CONFIG_MT7620_GPIO) += mt7620_gpio.o obj-$(CONFIG_MT7621_GPIO) += mt7621_gpio.o obj-$(CONFIG_MSCC_SGPIO) += mscc_sgpio.o
drivers/gpio/spacemit_gpio.c new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 9/9 configs: k1: enable pinctrl and gpio
In reply to Raymond MaoFrom: Guodong Xu <[email protected]>
Enable pinctrl and gpio configurations for Spacemit K1 SoC.
---
Changes in v2:
- Also enable CONFIG_CLK and CONFIG_CLK_CCF (U-Boot proper). Changes in v3:
- None.
board/spacemit/k1/MAINTAINERS | 3 +++ configs/spacemit_k1_defconfig | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
board/spacemit/k1/MAINTAINERS +3 -0
@@ -3,9 +3,12 @@ M: Huan Zhou <[email protected]> M: Guodong Xu <[email protected]> L: [email protected] S: Maintained +F: arch/riscv/dts/k1-*-u-boot.dtsi F: board/spacemit/k1/ F: configs/spacemit_k1_defconfig F: doc/board/spacemit/bananapi-f3.rst +F: drivers/gpio/spacemit_gpio.c F: drivers/i2c/k1_i2c.c +F: drivers/pinctrl/spacemit/ F: drivers/power/pmic/pmic_spacemit_p1.c F: drivers/power/regulator/spacemit_p1_regulator.c
configs/spacemit_k1_defconfig +7 -1
@@ -49,6 +49,8 @@ CONFIG_OF_UPSTREAM=y CONFIG_ENV_OVERWRITE=y CONFIG_SPL_REGMAP=y CONFIG_SPL_SYSCON=y +CONFIG_CLK=y +CONFIG_CLK_CCF=y CONFIG_SPL_CLK=y CONFIG_SPL_CLK_CCF=y CONFIG_CLK_SPACEMIT=y
@@ -59,7 +61,11 @@ CONFIG_MISC=y CONFIG_I2C_EEPROM=y CONFIG_SPL_I2C_EEPROM=y CONFIG_PINCTRL=y -CONFIG_PINCTRL_SINGLE=y +CONFIG_PINCTRL_SPACEMIT_K1=y +CONFIG_GPIO=y +CONFIG_DM_GPIO=y +CONFIG_CMD_GPIO=y +CONFIG_SPACEMIT_GPIO=y CONFIG_DM_PMIC=y CONFIG_PMIC_SPACEMIT_P1=y CONFIG_DM_REGULATOR=y
Signature · 1 line
2.25.1
Quoted 13 lines · Raymond Mao
From: Raymond Mao <[email protected]>
This series adds pinctrl, GPIO, and SPI NOR flash support for the SpacemiT K1. Drivers are usable in both SPL and U-Boot proper. In SPL, the QSPI controller and SPI NOR flash are probed during early init, and the SPL boot device is changed from memory-mapped NOR to SPI so the common loader reads the next-stage image from NOR. It sits on top of the K1 SPL bring-up series [1], which depends on the K1 clock/reset/dts migration series [2].
To apply on origin/master, two prerequisite series on lore must be applied first, in this order:
Quoted 6 lines
1. K1 clock/reset/dts migration [2] (8 patches) 2. K1 SPL bring-up v4 [1] (14 patches) 3. This series (9 patches)[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://lore.kernel.org/u-boot/20260510-b4-k1-clk-reset-upstream-dts-v1-0-db0b0503ee44@riscstar.com/
Just a correction about Link [2], I sent v2 of the migration series [3]. Please make sure you verified against that.
[3] https://lore.kernel.org/u-boot/20260526-b4-k1-clk-reset-upstream-dts-v2-0-af815e362b0c@riscstar.com/
BR,
Guodong Xu
Quoted 7 lines
Guodong Xu (3):
spl: k1: enable SPI NOR flash detection and boot
spacemit: k1: Add multiple device tree support
configs: k1: enable pinctrl and gpio