Map the boot device reported by get_boot_device() to the device tree
node of the controller the ROM booted from. This allows us to record
the device the ROM booted from in /chosen/bootsource.

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

diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig
index a32ed3a9683..ab4927655c5 100644
--- a/arch/arm/mach-k3/Kconfig
+++ b/arch/arm/mach-k3/Kconfig
@@ -6,6 +6,7 @@ choice
 
 config SOC_K3_AM625
        bool "TI's K3 based AM625 SoC Family Support"
+       imply FDT_FIXUP_BOOTSOURCE if ARM64
 
 config SOC_K3_AM62A7
        bool "TI's K3 based AM62A7 SoC Family Support"
diff --git a/arch/arm/mach-k3/am62x/boot.c b/arch/arm/mach-k3/am62x/boot.c
index a3a6cda6bdb..b2efacd0d26 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,27 @@ 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:
+               return "/bus@f0000/bus@fc00000/spi@fc40000";
+       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);
-- 
2.48.1

Reply via email to