Rock-4D: Add Edge + RK3576 Mainline U-Boot (with UFS support) (#9421)

* Rock-4D: Edge (u-boot and kernel)

* RK3576: Mainline u-boot ufs boot enablement patches

* Rock-4D: Use Mainline u-boot 2026.04-rc2

* Rock-4D: Update KERNEL_TEST_TARGET to edge

* Rock-4D: Use Mainline u-boot on vendor and edge

* Remove vendor branch check for mainline uboot
This commit is contained in:
Mecid 2026-02-20 21:55:32 +01:00 committed by GitHub
parent 7a42186d40
commit 77f919f6cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 468 additions and 2 deletions

View File

@ -4,8 +4,8 @@ BOARD_VENDOR="radxa"
BOARDFAMILY="rk35xx"
BOARD_MAINTAINER="HeyMeco"
BOOTCONFIG="rock-4d-spi-rk3576_defconfig"
KERNEL_TARGET="vendor"
KERNEL_TEST_TARGET="vendor"
KERNEL_TARGET="vendor,edge"
KERNEL_TEST_TARGET="edge"
FULL_DESKTOP="yes"
BOOT_LOGO="desktop"
BOOT_FDT_FILE="rockchip/rk3576-rock-4d-spi.dtb"
@ -16,6 +16,79 @@ IMAGE_PARTITION_TABLE="gpt"
enable_extension "radxa-aic8800"
AIC8800_TYPE="usb"
# Mainline U-Boot
function post_family_config__rock4d_use_mainline_uboot() {
display_alert "$BOARD" "Using mainline U-Boot for $BOARD / $BRANCH" "info"
declare -g DDR_BLOB="rk35/rk3576_ddr_lp4_2112MHz_lp5_2736MHz_v1.09.bin"
# Use mainline ATF v2.14 (rk3576 support added in this release)
BOOT_SCENARIO="tpl-blob-atf-mainline"
prepare_boot_configuration
declare -g ATFBRANCH="tag:v2.14.0"
declare -g ATFPATCHDIR="atf-rockchip64/v2.14"
declare -g BOOTCONFIG="rock-4d-rk3576_defconfig"
declare -g BOOTDELAY=1
declare -g BOOTSOURCE="https://github.com/u-boot/u-boot.git"
declare -g BOOTBRANCH="tag:v2026.04-rc2"
declare -g BOOTPATCHDIR="v2026.04"
unset BOOT_FDT_FILE # mainline defconfig has DEFAULT_FDT_FILE set
# Binman produces both eMMC/SD and SPI images; mainline ATF bl31.elf + DDR blob
declare -g UBOOT_TARGET_MAP="BL31=bl31.elf ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB};;u-boot-rockchip.bin u-boot-rockchip-spi.bin"
# Disable vendor-specific postprocessing; binman does all the work
unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd
# Just use the binman-provided u-boot-rockchip.bin, which is ready-to-go
function write_uboot_platform() {
dd "if=$1/u-boot-rockchip.bin" "of=$2" bs=32k seek=1 conv=notrunc status=none
}
function write_uboot_platform_mtd() {
flashcp -v -p "$1/u-boot-rockchip-spi.bin" /dev/mtd0
}
}
# Enable UFS and SPI environment storage for mainline U-Boot
function post_config_uboot_target__rock4d_enable_ufs_and_spi_env() {
display_alert "$BOARD" "Enabling UFS and SPI env for ${BOOTBRANCH} u-boot" "info"
# Enable RK3576 UFS storage support
run_host_command_logged scripts/config --enable CONFIG_SCSI
run_host_command_logged scripts/config --enable CONFIG_CMD_SCSI
run_host_command_logged scripts/config --enable CONFIG_UFS
run_host_command_logged scripts/config --enable CONFIG_UFS_ROCKCHIP
# Enable SPL UFS boot support; SPL_DM_GPIO/SPL_GPIO/SPL_DM_RESET are required
# by UFS_ROCKCHIP when SPL_UFS_SUPPORT is set (no longer auto-implied by Kconfig in v5 patches)
run_host_command_logged scripts/config --enable CONFIG_SPL_UFS_SUPPORT
run_host_command_logged scripts/config --enable CONFIG_SPL_DM_GPIO
run_host_command_logged scripts/config --enable CONFIG_SPL_GPIO
run_host_command_logged scripts/config --enable CONFIG_SPL_DM_RESET
# Store U-Boot environment in SPI flash
run_host_command_logged scripts/config --set-val CONFIG_ENV_IS_NOWHERE "n"
run_host_command_logged scripts/config --set-val CONFIG_ENV_IS_IN_SPI_FLASH "y"
run_host_command_logged scripts/config --set-val CONFIG_ENV_SECT_SIZE_AUTO "y"
run_host_command_logged scripts/config --set-val CONFIG_ENV_OVERWRITE "y"
run_host_command_logged scripts/config --set-val CONFIG_ENV_SIZE "0x20000"
run_host_command_logged scripts/config --set-val CONFIG_ENV_OFFSET "0xc00000"
}
# "rockchip-common: boot SD card first, then eMMC, then UFS/NVMe"
# On Rock 4D, mmc0 is SD card, mmc1 is eMMC, scsi covers UFS
function pre_config_uboot_target__rock4d_boot_order() {
declare -a rockchip_uboot_targets=("mmc0" "mmc1" "scsi" "nvme" "usb" "pxe" "dhcp")
display_alert "u-boot for ${BOARD}/${BRANCH}" "u-boot: adjust boot order to '${rockchip_uboot_targets[*]}'" "info"
sed -i -e "s/#define BOOT_TARGETS.*/#define BOOT_TARGETS \"${rockchip_uboot_targets[*]}\"/" include/configs/rockchip-common.h
regular_git diff -u include/configs/rockchip-common.h || true
}
function post_family_tweaks__rock-4d_naming_audios() {
display_alert "$BOARD" "Renaming Rock-4D audios" "info"

View File

@ -0,0 +1,16 @@
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
#include "rk3576-u-boot.dtsi"
&sfc0 {
flash@0 {
bootph-pre-ram;
bootph-some-ram;
};
};
&ufshc {
vcc-supply = <&vcc_3v3_ufs_s0>;
vccq-supply = <&vcc_1v2_ufs_vccq_s0>;
vccq2-supply = <&vcc_1v8_ufs_vccq2_s0>;
};

View File

@ -0,0 +1,168 @@
diff --git a/MAINTAINERS b/MAINTAINERS
index 27ce73d83f48..ca31e57f018a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1861,6 +1861,7 @@ M: Neil Armstrong <neil.armstrong@linaro.org>
M: Bhupesh Sharma <bhupesh.linux@gmail.com>
M: Neha Malcom Francis <n-francis@ti.com>
S: Maintained
+F: common/spl/spl_ufs.c
F: drivers/ufs/
UPL
diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h
index ee79a19c05c9..dd462ea6ad82 100644
--- a/arch/arm/include/asm/spl.h
+++ b/arch/arm/include/asm/spl.h
@@ -30,6 +30,7 @@ enum {
BOOT_DEVICE_XIP,
BOOT_DEVICE_BOOTROM,
BOOT_DEVICE_SMH,
+ BOOT_DEVICE_UFS,
BOOT_DEVICE_NONE
};
#endif
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 4f4119f5806c..68f475717663 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1612,6 +1612,36 @@ config SPL_THERMAL
automatic power-off when the temperature gets too high or low. Other
devices may be discrete but connected on a suitable bus.
+config SPL_UFS_SUPPORT
+ bool "Support loading from UFS"
+ depends on UFS
+ select SPL_LOAD_BLOCK
+ help
+ Enable support for UFS in SPL. This allows
+ use of UFS devices such as hard drives and flash drivers for
+ loading U-Boot.
+
+config SPL_UFS_RAW_U_BOOT_DEVNUM
+ int "SCSI device number of the UFS device to load U-Boot from"
+ depends on SPL_UFS_SUPPORT
+ default 0
+ help
+ UFS devices are usually configured with multiple LUNs, which present
+ themselves as sequentially numbered SCSI devices. Usually one would
+ get a default LUN 0 taking up most of the space on the device, with
+ a number of smaller LUNs following it. This option controls which of
+ them the SPL will attempt to load U-Boot from. Note that this is the
+ SCSI device number, which might differ from the UFS LUN if you have
+ multiple SCSI devices attached and recognized by the SPL.
+
+config SPL_UFS_RAW_U_BOOT_SECTOR
+ hex "Address on the UFS to load U-Boot from"
+ depends on SPL_UFS_SUPPORT
+ default 0x800 if ARCH_ROCKCHIP
+ help
+ Address on the block device to load U-Boot from.
+ Units: UFS sectors (1 sector = 4096 bytes).
+
config SPL_WATCHDOG
bool "Support watchdog drivers"
imply SPL_WDT if !HW_WATCHDOG
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 4c9482bd3096..e18f3cf09484 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_$(PHASE_)DFU) += spl_dfu.o
obj-$(CONFIG_$(PHASE_)SPI_LOAD) += spl_spi.o
obj-$(CONFIG_$(PHASE_)RAM_SUPPORT) += spl_ram.o
obj-$(CONFIG_$(PHASE_)USB_SDP_SUPPORT) += spl_sdp.o
+obj-$(CONFIG_$(PHASE_)UFS_SUPPORT) += spl_ufs.o
endif
obj-$(CONFIG_$(PHASE_)UPL) += spl_upl.o
diff --git a/common/spl/spl_ufs.c b/common/spl/spl_ufs.c
new file mode 100644
index 000000000000..cef1843f40f3
--- /dev/null
+++ b/common/spl/spl_ufs.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2025 Alexey Charkov <alchark@gmail.com>
+ */
+
+#include <spl.h>
+#include <spl_load.h>
+#include <scsi.h>
+#include <errno.h>
+#include <image.h>
+#include <linux/compiler.h>
+#include <log.h>
+
+static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off, ulong size, void *buf)
+{
+ struct blk_desc *bd = load->priv;
+ lbaint_t sector = off >> bd->log2blksz;
+ lbaint_t count = size >> bd->log2blksz;
+
+ return blk_dread(bd, sector, count, buf) << bd->log2blksz;
+}
+
+static int spl_ufs_load_image(struct spl_image_info *spl_image,
+ struct spl_boot_device *bootdev)
+{
+ unsigned long sector = CONFIG_SPL_UFS_RAW_U_BOOT_SECTOR;
+ int devnum = CONFIG_SPL_UFS_RAW_U_BOOT_DEVNUM;
+ struct spl_load_info load;
+ struct blk_desc *bd;
+ int err;
+
+ /* try to recognize storage devices immediately */
+ scsi_scan(false);
+ bd = blk_get_devnum_by_uclass_id(UCLASS_SCSI, devnum);
+ if (!bd)
+ return -ENODEV;
+
+ spl_load_init(&load, spl_ufs_load_read, bd, bd->blksz);
+ err = spl_load(spl_image, bootdev, &load, 0, sector << bd->log2blksz);
+ if (err) {
+ puts("spl_ufs_load_image: ufs block read error\n");
+ log_debug("(error=%d)\n", err);
+ return err;
+ }
+
+ return 0;
+}
+
+SPL_LOAD_IMAGE_METHOD("UFS", 0, BOOT_DEVICE_UFS, spl_ufs_load_image);
diff --git a/drivers/Makefile b/drivers/Makefile
index de993ae42ac7..43d0ba332818 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -73,6 +73,7 @@ obj-$(CONFIG_SPL_USB_HOST) += usb/host/
obj-$(CONFIG_SPL_SATA) += ata/ scsi/
obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
obj-$(CONFIG_SPL_THERMAL) += thermal/
+obj-$(CONFIG_SPL_UFS_SUPPORT) += scsi/ ufs/
endif
endif
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index b76de1b22a8b..c9af60d5d03c 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -16,4 +16,7 @@ ifdef CONFIG_XPL_BUILD
ifdef CONFIG_SPL_SATA
obj-$(CONFIG_SCSI) += scsi.o scsi-uclass.o
endif
+ifdef CONFIG_SPL_UFS_SUPPORT
+obj-$(CONFIG_SCSI) += scsi.o scsi-uclass.o
+endif
endif
diff --git a/lib/Makefile b/lib/Makefile
index 70667f3728c2..d0ffabc2b476 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -147,6 +147,7 @@ else
obj-$(CONFIG_$(PHASE_)SPRINTF) += vsprintf.o
endif
obj-$(CONFIG_$(PHASE_)STRTO) += strto.o
+obj-$(CONFIG_$(PHASE_)UFS_SUPPORT) += charset.o
else
# Main U-Boot always uses the full printf support
obj-y += vsprintf.o strto.o

View File

@ -0,0 +1,33 @@
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 74c267dfc4e5..d35f3904e404 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -99,6 +99,15 @@ config RESET_ROCKCHIP
though is that some reset signals, like I2C or MISC reset multiple
devices.
+config SPL_RESET_ROCKCHIP
+ bool "SPL reset controller driver for Rockchip SoCs"
+ depends on SPL_DM_RESET && ARCH_ROCKCHIP && CLK
+ default y
+ help
+ Support for the reset controller on Rockchip SoCs in SPL. Select this
+ if you observe any reset-related warnings or errors when booting SPL,
+ such as when using UFS storage
+
config RESET_HSDK
bool "Synopsys HSDK Reset Driver"
depends on DM_RESET && TARGET_HSDK
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index ee5b009d1341..dc7d3b610e6e 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -16,7 +16,7 @@ obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o
obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
obj-$(CONFIG_RESET_AST2500) += reset-ast2500.o
obj-$(CONFIG_RESET_AST2600) += reset-ast2600.o
-obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o rst-rk3528.o rst-rk3576.o rst-rk3588.o
+obj-$(CONFIG_$(PHASE_)RESET_ROCKCHIP) += reset-rockchip.o rst-rk3528.o rst-rk3576.o rst-rk3588.o
obj-$(CONFIG_RESET_MESON) += reset-meson.o
obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o

View File

@ -0,0 +1,79 @@
diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig
index 6c75bb2a0790..49472933de36 100644
--- a/drivers/ufs/Kconfig
+++ b/drivers/ufs/Kconfig
@@ -76,6 +76,10 @@ config UFS_RENESAS_GEN5
config UFS_ROCKCHIP
bool "Rockchip specific hooks to UFS controller platform driver"
depends on UFS
+ depends on DM_GPIO
+ depends on RESET_ROCKCHIP
+ depends on SPL_DM_GPIO || !SPL_UFS_SUPPORT
+ depends on SPL_RESET_ROCKCHIP || !SPL_UFS_SUPPORT
help
This selects the Rockchip specific additions to UFSHCD platform driver.
diff --git a/drivers/ufs/ufs-rockchip.c b/drivers/ufs/ufs-rockchip.c
index 0384244387da..3576f6e7a2b6 100644
--- a/drivers/ufs/ufs-rockchip.c
+++ b/drivers/ufs/ufs-rockchip.c
@@ -5,6 +5,7 @@
* Copyright (C) 2025 Rockchip Electronics Co.Ltd.
*/
+#include <asm/gpio.h>
#include <asm/io.h>
#include <clk.h>
#include <dm.h>
@@ -153,11 +154,31 @@ static int ufs_rockchip_common_init(struct ufs_hba *hba)
return err;
}
+ err = gpio_request_by_name(dev, "reset-gpios", 0, &host->device_reset,
+ GPIOD_IS_OUT | GPIOD_ACTIVE_LOW);
+ if (err) {
+ dev_err(dev, "Cannot get reset GPIO\n");
+ return err;
+ }
+
host->hba = hba;
return 0;
}
+static int ufs_rockchip_device_reset(struct ufs_hba *hba)
+{
+ struct ufs_rockchip_host *host = dev_get_priv(hba->dev);
+
+ dm_gpio_set_value(&host->device_reset, true);
+ udelay(20);
+
+ dm_gpio_set_value(&host->device_reset, false);
+ udelay(20);
+
+ return 0;
+}
+
static int ufs_rockchip_rk3576_init(struct ufs_hba *hba)
{
int ret = 0;
@@ -175,6 +196,7 @@ static struct ufs_hba_ops ufs_hba_rk3576_vops = {
.init = ufs_rockchip_rk3576_init,
.phy_initialization = ufs_rockchip_rk3576_phy_init,
.hce_enable_notify = ufs_rockchip_hce_enable_notify,
+ .device_reset = ufs_rockchip_device_reset,
};
static const struct udevice_id ufs_rockchip_of_match[] = {
diff --git a/drivers/ufs/ufs-rockchip.h b/drivers/ufs/ufs-rockchip.h
index 3dcb80f57020..50c2539da78a 100644
--- a/drivers/ufs/ufs-rockchip.h
+++ b/drivers/ufs/ufs-rockchip.h
@@ -72,6 +72,7 @@ struct ufs_rockchip_host {
void __iomem *ufs_sys_ctrl;
void __iomem *mphy_base;
struct reset_ctl_bulk rsts;
+ struct gpio_desc device_reset;
struct clk ref_out_clk;
uint64_t caps;
uint32_t phy_config_mode;

View File

@ -0,0 +1,97 @@
diff --git a/arch/arm/dts/rk3576-u-boot.dtsi b/arch/arm/dts/rk3576-u-boot.dtsi
index dc3771b556a3..e442e94f7132 100644
--- a/arch/arm/dts/rk3576-u-boot.dtsi
+++ b/arch/arm/dts/rk3576-u-boot.dtsi
@@ -12,7 +12,7 @@
};
chosen {
- u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
+ u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci, &ufshc;
};
dmc {
@@ -81,6 +81,15 @@
bootph-some-ram;
};
+&gpio4 {
+ /* This is specifically for GPIO4_D0, which is the only 1.2V capable
+ * pin on RK3576 available for use as the UFS device reset, thus
+ * &gpio4 is required for booting from UFS on RK3576.
+ */
+ bootph-pre-ram;
+ bootph-some-ram;
+};
+
&ioc_grf {
bootph-all;
};
@@ -176,6 +185,11 @@
bootph-pre-ram;
};
+&ufshc {
+ bootph-pre-ram;
+ bootph-some-ram;
+};
+
&xin24m {
bootph-all;
};
diff --git a/arch/arm/include/asm/arch-rockchip/bootrom.h b/arch/arm/include/asm/arch-rockchip/bootrom.h
index b15938c021d6..f9ecb6858f04 100644
--- a/arch/arm/include/asm/arch-rockchip/bootrom.h
+++ b/arch/arm/include/asm/arch-rockchip/bootrom.h
@@ -51,6 +51,7 @@ enum {
BROM_BOOTSOURCE_SPINOR = 3,
BROM_BOOTSOURCE_SPINAND = 4,
BROM_BOOTSOURCE_SD = 5,
+ BROM_BOOTSOURCE_UFS = 7,
BROM_BOOTSOURCE_I2C = 8,
BROM_BOOTSOURCE_SPI = 9,
BROM_BOOTSOURCE_USB = 10,
diff --git a/arch/arm/mach-rockchip/rk3576/rk3576.c b/arch/arm/mach-rockchip/rk3576/rk3576.c
index a1e8a7572fa4..46cf60dc77c7 100644
--- a/arch/arm/mach-rockchip/rk3576/rk3576.c
+++ b/arch/arm/mach-rockchip/rk3576/rk3576.c
@@ -46,6 +46,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
[BROM_BOOTSOURCE_FSPI0] = "/soc/spi@2a340000/flash@0",
[BROM_BOOTSOURCE_FSPI1_M1] = "/soc/spi@2a300000/flash@0",
[BROM_BOOTSOURCE_SD] = "/soc/mmc@2a310000",
+ [BROM_BOOTSOURCE_UFS] = "/soc/ufshc@2a2d0000",
};
static struct mm_region rk3576_mem_map[] = {
diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
index 6572dde29f65..d2dd5e10935f 100644
--- a/arch/arm/mach-rockchip/spl-boot-order.c
+++ b/arch/arm/mach-rockchip/spl-boot-order.c
@@ -76,6 +76,9 @@ static int spl_node_to_boot_device(int node)
if (!uclass_find_device_by_of_offset(UCLASS_SPI_FLASH, node, &parent))
return BOOT_DEVICE_SPI;
+ if (!uclass_find_device_by_of_offset(UCLASS_UFS, node, &parent))
+ return BOOT_DEVICE_UFS;
+
return -1;
}
@@ -231,6 +234,17 @@ int spl_decode_boot_device(u32 boot_device, char *buf, size_t buflen)
return -ENODEV;
}
+ if (boot_device == BOOT_DEVICE_UFS) {
+ ret = uclass_find_device(UCLASS_UFS, 0, &dev);
+ if (ret) {
+ debug("%s: could not find device for UFS: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ return ofnode_get_path(dev_ofnode(dev), buf, buflen);
+ }
+
#if CONFIG_IS_ENABLED(BLK)
dev_num = (boot_device == BOOT_DEVICE_MMC1) ? 0 : 1;