Rockchip RK3576 can load its bootloader from UFS among other options, so this series adds the necessary bits and pieces to enable an end-to-end boot from UFS (boot ROM -> SPL -> U-boot proper -> kernel).
This series contains the Rockchip-specific code to enable UFS boot in SPL, and relies on the architecture-independent bits [1], [2] already applied by Neil Armstrong to the u-boot-ufs custodian tree. It also depends on the recent addition of Rockchip-specific code to allow DMA writes to PMU SRAM by Jonas Karlman [3] already applied by Kever Yang to the u-boot-rockchip custodian tree. To achieve the above, this series goes through the following: - Patches 1-2 cherry-pick recent additions to the upstream DTS files required to properly configure the pin mode for the UFS device reset pin on RK3576, as well as enable the UFSHC node on the NanoPi M5 board - Patch 3 adds an option to build the Rockchip reset driver for SPL - Patch 4 ties it all together for Rockchip RK3576 - Patches 5-6 update defconfigs for two example boards to enable UFS boot This has been tested on a FriendlyElec NanoPi M5 board with a Biwin BWU3AKC46C256G UFS module. Note that in my experience none of the RK3576 boards actually boot current mainline U-boot versions without a single-word SRAM write before jumping to DDR initialization, as done in Kwiboo's commit at [4]. Therefore, to test this series I additionally applied commits 117cd97627fd..04e6417226f5 from Kwiboo's rk3576 branch [5] (including 117cd97627fd), so any testers might want to: git cherry-pick 117cd97627fd^..04e6417226f5 from there before or after applying this series [1] https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/8ce3df3ebe6b8c0022a0c79780a2e1ce3e1c792a [2] https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/42dd7a5ae1b166127766ce7e39f98badb311e56d [3] https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/commit/4015faa32342fd9c494c318c21de106f98dd4674 [4] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commit/04e6417226f50e4e3cb04272280922eb425c18ab [5] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commits/rk3576?ref_type=heads Signed-off-by: Alexey Charkov <[email protected]> --- Changes in v6: - Dropped patches already applied by Neil to the u-boot-ufs custodian tree (thanks Neil) - Rebased to current next (thanks Jonas) - Fixed the dependency on SPL_CLK instead of CLK for the SPL reset driver (thanks Jonas) - Included newly required DT nodes into bootph-* filters for the u-boot-spl.dtb (thanks Jonas) - Cherry-picked the relevant DTS additions from devicetree-rebasing (thanks Jonas) - Added a preprocessor conditional around the GPIO4 bootph-* node to avoid its inclusion without CONFIG_SPL_UFS_SUPPORT (thanks Jonas) - Added relevant defconfig changes for Rock 4D and NanoPi M5 (thanks Jonas) - Link to v5: https://lore.kernel.org/r/[email protected] Changes in v5: - Reverse X-mas tree in spl_ufs:spl_ufs_load_image (thanks Quentin) - Explicit "depends on UFS" from CONFIG_SPL_UFS_SUPPORT (thanks Quentin). This also pulls in SCSI to avoid compilation errors. - Split out the patch enabling the Rockchip reset driver for SPL builds (thanks Quentin) - Reworded the error message when requesting the UFS reset GPIO fails (thanks Quentin) - Added a note in the commit message about reset-gpios being required by the DT binding (thanks Quentin) - Dropped the redundant check of GPIO validity in the reset function (thanks Quentin) - Added a note about GPIO4_D0 being the only GPIO usable for UFS reset on RK3576 (thanks Shawn) - Dropped "imply" symbols from the arch Kconfig, now that both GPIO and RESET drivers are explicitly depended on from the UFS driver (thanks Quentinq) - Link to v4: https://lore.kernel.org/r/[email protected] Changes in v4: - Added a dependency in b4 metadata on Jonas' new series enabling DMA writes to PMU SRAM (thanks Jonas) - Dropped the bounce buffer quirk altogether, as it now works as-is - Link to v3: https://lore.kernel.org/r/[email protected] Changes in v3: - Added a UFSHC quirk to use the SCSI bounce buffer for addresses outside SDRAM, and enabled it on Rockchip (thanks Neil and Tom) - Dropped the open-coded bounce buffer from spl_ufs.c, now unneeded - Link to v2: https://lore.kernel.org/r/[email protected] Changes in v2: - Rename the SPL UFS read helper function more self-descriptively (thanks Neil) - Add an option to configure the UFS LUN used to look for the U-boot image in raw offset mode - or rather the SCSI device number, which most of the time coincides with the UFS LUN as long as the UFS device is the only SCSI block device the SPL sees (thanks Neil) - Add an option to use a bounce buffer in RAM while loading U-boot from UFS, which helps avoid changes to common spl_fit.c code which in v1 achieved a similar result at a performance cost to unrelated platforms (thanks Jonas) - Link to v1: https://lore.kernel.org/r/[email protected] --- Alexey Charkov (5): arm64: dts: rockchip: Explicitly request UFS reset pin on RK3576 arm64: dts: rockchip: enable UFS controller on FriendlyElec NanoPi M5 reset: rockchip: make device resets available in SPL rockchip: spl: Add support for booting from UFS rockchip: rk3576-nanopi-m5: Enable UFS support Jonas Karlman (1): rockchip: rk3576-rock-4d: Enable UFS support arch/arm/dts/rk3576-u-boot.dtsi | 33 +++++++++++++++++++++- arch/arm/include/asm/arch-rockchip/bootrom.h | 1 + arch/arm/mach-rockchip/rk3576/rk3576.c | 1 + arch/arm/mach-rockchip/spl-boot-order.c | 14 +++++++++ configs/nanopi-m5-rk3576_defconfig | 7 +++++ configs/rock-4d-rk3576_defconfig | 7 +++++ drivers/reset/Kconfig | 9 ++++++ drivers/reset/Makefile | 2 +- .../src/arm64/rockchip/rk3576-nanopi-m5.dts | 24 ++++++++++++++++ .../src/arm64/rockchip/rk3576-pinctrl.dtsi | 7 +++++ dts/upstream/src/arm64/rockchip/rk3576.dtsi | 2 +- 11 files changed, 104 insertions(+), 3 deletions(-) --- base-commit: 8bc2a5196c1c0bb5dbdaca073323da0015a0de37 change-id: 20251210-rk3576-ufs-ac3bf4e87156 Best regards, -- Alexey Charkov <[email protected]>

