Call fdt_fixup_bootsource() from spl_perform_arch_fixups() so the next
boot stage knows the device the ROM booted from.

Implement bootsource_get_ofpath() for AM62x by mapping the boot device
from get_boot_device() to its device tree node. For OSPI boot the path
points to the flash chip and not the controller, since the flash node
is what the OS maps to an MTD device. All AM62 boards name it flash@0.

Signed-off-by: Wadim Egorov <[email protected]>
---
 arch/arm/mach-k3/am62x/boot.c | 27 +++++++++++++++++++++++++++
 arch/arm/mach-k3/common.c     |  1 +
 2 files changed, 28 insertions(+)

diff --git a/arch/arm/mach-k3/am62x/boot.c b/arch/arm/mach-k3/am62x/boot.c
index a3a6cda6bdb..96052f44831 100644
--- a/arch/arm/mach-k3/am62x/boot.c
+++ b/arch/arm/mach-k3/am62x/boot.c
@@ -2,6 +2,7 @@
 #include <asm/io.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/am62_spl.h>
+#include <fdt_support.h>
 
 static u32 __get_backup_bootmedia(u32 devstat)
 {
@@ -102,6 +103,32 @@ u32 get_boot_device(void)
        return bootmedia;
 }
 
+const char *bootsource_get_ofpath(void)
+{
+       switch (get_boot_device()) {
+       case BOOT_DEVICE_MMC1:
+               return "/bus@f0000/mmc@fa10000";
+       case BOOT_DEVICE_MMC2:
+               return "/bus@f0000/mmc@fa00000";
+       case BOOT_DEVICE_SPI:
+               /*
+                * The flash chip is described by the board device tree. All
+                * AM62 boards name it flash@0, a tree that uses another name
+                * gets no bootsource property.
+                */
+               return "/bus@f0000/bus@fc00000/spi@fc40000/flash@0";
+       case BOOT_DEVICE_ETHERNET:
+               return "/bus@f0000/ethernet@8000000/ethernet-ports/port@1";
+       case BOOT_DEVICE_UART:
+               return "/bus@f0000/serial@2800000";
+       case BOOT_DEVICE_USB:
+       case BOOT_DEVICE_DFU:
+               return "/bus@f0000/dwc3-usb@f900000/usb@31000000";
+       }
+
+       return NULL;
+}
+
 const char *get_reset_reason(void)
 {
        u32 reset_reason = readl(CTRLMMR_MCU_RST_SRC);
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 6e382efdb3b..c7fd7b4f44c 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -570,6 +570,7 @@ void spl_perform_arch_fixups(struct spl_image_info 
*spl_image)
                return;
 
        fdt_fixup_reserved(fdt);
+       fdt_fixup_bootsource(fdt);
 
        if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
                k3_falcon_fdt_fixup(fdt);
-- 
2.48.1

Reply via email to