ARM: mach-k3: sysfw-loader: Use SPI memmapped addr when loading SYSFW
authorLokesh Vutla <lokeshvutla@ti.com>
Tue, 4 Feb 2020 05:39:50 +0000 (11:09 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Tue, 3 Mar 2020 07:38:13 +0000 (13:08 +0530)
Since ROM configures OSPI controller to be in memory mapped mode in OSPI
boot, R5 SPL can directly pass the memory mapped pointer to ROM. With
this ROM can directly pull the SYSFW image from OSPI.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
arch/arm/mach-k3/Kconfig
arch/arm/mach-k3/sysfw-loader.c

index 8f4272286c11d6046e4635d9034cb31161424ba5..a13cbef9b5c3f636feed7b1f6bc2731ac07437af 100644 (file)
@@ -126,6 +126,14 @@ config K3_SYSFW_IMAGE_SIZE_MAX
          tree blob. Keep it as tight as possible, as this directly affects the
          overall SPL memory footprint.
 
+config K3_SYSFW_IMAGE_SPI_OFFS
+       hex "SPI offset of SYSFW firmware and configuration blob"
+       depends on K3_LOAD_SYSFW
+       default 0x6C0000
+       help
+         Offset of the combined System Firmware and configuration image tree
+         blob to be loaded when booting from a SPI flash memory.
+
 config SYS_K3_SPL_ATF
        bool "Start Cortex-A from SPL"
        depends on SPL && CPU_V7R
index 94dbeb9437d9472ca3e469a741c82156bf44c896..3677a37f55a2d86f34259f25db61098acc3a1e4f 100644 (file)
@@ -14,6 +14,8 @@
 #include <g_dnl.h>
 #include <usb.h>
 #include <dfu.h>
+#include <dm/uclass-internal.h>
+#include <spi_flash.h>
 
 #include <asm/arch/sys_proto.h>
 #include "common.h"
@@ -197,12 +199,32 @@ exit:
 }
 #endif
 
+#if CONFIG_IS_ENABLED(SPI_LOAD)
+static void *k3_sysfw_get_spi_addr(void)
+{
+       struct udevice *dev;
+       fdt_addr_t addr;
+       int ret;
+
+       ret = uclass_find_device_by_seq(UCLASS_SPI, CONFIG_SF_DEFAULT_BUS,
+                                       true, &dev);
+       if (ret)
+               return NULL;
+
+       addr = dev_read_addr_index(dev, 1);
+       if (addr == FDT_ADDR_T_NONE)
+               return NULL;
+
+       return (void *)(addr + CONFIG_K3_SYSFW_IMAGE_SPI_OFFS);
+}
+#endif
+
 void k3_sysfw_loader(void (*config_pm_done_callback)(void))
 {
        struct spl_image_info spl_image = { 0 };
        struct spl_boot_device bootdev = { 0 };
        struct ti_sci_handle *ti_sci;
-       int ret;
+       int ret = 0;
 
        /* Reserve a block of aligned memory for loading the SYSFW image */
        sysfw_load_address = memalign(ARCH_DMA_MINALIGN,
@@ -243,6 +265,13 @@ void k3_sysfw_loader(void (*config_pm_done_callback)(void))
 #endif
                break;
 #endif
+#if CONFIG_IS_ENABLED(SPI_LOAD)
+       case BOOT_DEVICE_SPI:
+               sysfw_load_address = k3_sysfw_get_spi_addr();
+               if (!sysfw_load_address)
+                       ret = -ENODEV;
+               break;
+#endif
 #if CONFIG_IS_ENABLED(YMODEM_SUPPORT)
        case BOOT_DEVICE_UART:
 #ifdef CONFIG_K3_EARLY_CONS