]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
rockchip: spl: Add support for booting from UFS
authorAlexey Charkov <alchark@flipper.net>
Wed, 11 Mar 2026 13:30:59 +0000 (17:30 +0400)
committerKever Yang <kever.yang@rock-chips.com>
Mon, 8 Jun 2026 13:32:40 +0000 (21:32 +0800)
Add the required architecture-specific lookups to enable U-boot SPL to
load images from UFS storage devices on Rockchip RK3576, which has a
boot ROM capable of loading the SPL image from UFS.

Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Alexey Charkov <alchark@flipper.net>
arch/arm/dts/rk3576-u-boot.dtsi
arch/arm/include/asm/arch-rockchip/bootrom.h
arch/arm/mach-rockchip/rk3576/rk3576.c
arch/arm/mach-rockchip/spl-boot-order.c

index 018c9cc8d6965b5c9cc39315c7b16a40a05b3980..8db9495c6d46e37b71ba5a9277ce3545c1fd0bc7 100644 (file)
@@ -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 {
        bootph-some-ram;
 };
 
+#ifdef CONFIG_SPL_UFS_SUPPORT
+&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;
+};
+#endif
+
 &ioc_grf {
        bootph-all;
 };
        bootph-some-ram;
 };
 
+&pcfg_pull_down {
+       bootph-pre-ram;
+       bootph-some-ram;
+};
+
 &pcfg_pull_none {
        bootph-all;
 };
        bootph-pre-ram;
 };
 
+&ufshc {
+       bootph-pre-ram;
+       bootph-some-ram;
+};
+
+&ufs_refclk {
+       bootph-pre-ram;
+       bootph-some-ram;
+};
+
+&ufs_rstgpio {
+       bootph-pre-ram;
+       bootph-some-ram;
+};
+
 &xin24m {
        bootph-all;
 };
index b15938c021d6c857550f320751d59d539ad7b975..f9ecb6858f04264e95e57f26348fc23379de5125 100644 (file)
@@ -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,
index c17ba418ced5856f6d8c8eb2572a4ca2ca49ebae..1def4e8797195bfc06a783c366489582e520eb50 100644 (file)
@@ -49,6 +49,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[] = {
index 6572dde29f65a586754026d9c531ce859b8f0ca4..d2dd5e10935f696c59d996e8982d009275af39a0 100644 (file)
@@ -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;