]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
rockchip: add /chosen/bootsource to U-Boot proper DT
authorQuentin Schulz <quentin.schulz@cherry.de>
Wed, 30 Jul 2025 12:03:18 +0000 (14:03 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 13 Aug 2025 18:42:05 +0000 (12:42 -0600)
U-Boot typically can be loaded from different storage media, such as
eMMC, SD card, SPI flash, but also from non-persistent media such as USB
(via proprietary protocols loading directly into SRAM, or fastboot, DFU,
 etc..), JTAG, ...

This information is usually reported by the BootROM via some proprietary
mechanism (some specific address in registers/DRAM for example). For
Rockchip, that information is stored in a register
(BROM_BOOTSOURCE_ID_ADDR).

While we already have the information about which medium was used to
load U-Boot proper from SPL (via /chosen/u-boot,spl-boot-device), this
new property represents the medium used to load U-Boot first phase
(depending on configuration, can be VPL/TPL/SPL) which absolutely may
differ from the one used to load U-Boot proper!

It would be useful to know which medium was used to load the first phase
of U-Boot, for example to check fallback mechanisms (proper loaded from
a different medium than first phase) are actually working.

For now, this only applies to Rockchip's U-Boot proper DT but could be
applied to the kernel's as well and possibly for other architectures or
vendors.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
arch/arm/mach-rockchip/spl-boot-order.c

index 3dce9b30898d49a86ec1963846ffdddea521e201..1bfd120adc46d4c847fc81112033bcf193be96d3 100644 (file)
@@ -242,30 +242,38 @@ int spl_decode_boot_device(u32 boot_device, char *buf, size_t buflen)
 
 void spl_perform_fixups(struct spl_image_info *spl_image)
 {
+       const char *bootrom_ofpath = board_spl_was_booted_from();
        void *blob = spl_image_fdt_addr(spl_image);
        char boot_ofpath[512];
        int chosen, ret;
 
-       /*
-        * Inject the ofpath of the device the full U-Boot (or Linux in
-        * Falcon-mode) was booted from into the FDT, if a FDT has been
-        * loaded at the same time.
-        */
        if (!blob)
                return;
 
-       ret = spl_decode_boot_device(spl_image->boot_device, boot_ofpath, sizeof(boot_ofpath));
-       if (ret) {
-               pr_err("%s: could not map boot_device to ofpath: %d\n", __func__, ret);
-               return;
-       }
-
        chosen = fdt_find_or_add_subnode(blob, 0, "chosen");
        if (chosen < 0) {
                pr_err("%s: could not find/create '/chosen'\n", __func__);
                return;
        }
-       fdt_setprop_string(blob, chosen,
-                          "u-boot,spl-boot-device", boot_ofpath);
+
+       /*
+        * Inject the ofpath of the device the full U-Boot (or Linux in
+        * Falcon-mode) was booted from into the FDT.
+        */
+       ret = spl_decode_boot_device(spl_image->boot_device, boot_ofpath, sizeof(boot_ofpath));
+       if (ret)
+               pr_err("%s: could not map boot_device to ofpath: %d\n", __func__, ret);
+       else
+               fdt_setprop_string(blob, chosen,
+                                  "u-boot,spl-boot-device", boot_ofpath);
+
+       /*
+        * Inject the ofpath of the device the BootROM loaded the very first
+        * stage from into the FDT.
+        */
+       if (!bootrom_ofpath)
+               pr_err("%s: could not map BootROM boot device to ofpath\n", __func__);
+       else
+               fdt_setprop_string(blob, chosen, "bootsource", bootrom_ofpath);
 }
 #endif