]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: k3: sysfw-loader: add hyperflash support
authorVaishnav Achath <vaishnav.a@ti.com>
Mon, 9 May 2022 06:20:14 +0000 (11:50 +0530)
committerTom Rini <trini@konsulko.com>
Fri, 10 Jun 2022 13:03:22 +0000 (09:03 -0400)
add support for loading system firmware from hyperflash.

Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
arch/arm/mach-k3/sysfw-loader.c

index 5e48c36ccd58cf79c7a045699e25d37413e001df..988e75862929d1893310f8fe1074d48f29ccc283 100644 (file)
@@ -346,6 +346,25 @@ static void k3_sysfw_spi_copy(u32 *dst, u32 *src, size_t len)
 }
 #endif
 
+#if CONFIG_IS_ENABLED(NOR_SUPPORT)
+static void *get_sysfw_hf_addr(void)
+{
+       struct udevice *dev;
+       fdt_addr_t addr;
+       int ret;
+
+       ret = uclass_find_first_device(UCLASS_MTD, &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(bool rom_loaded_sysfw,
                     void (*config_pm_pre_callback)(void),
                     void (*config_pm_done_callback)(void))
@@ -413,6 +432,15 @@ void k3_sysfw_loader(bool rom_loaded_sysfw,
                                  CONFIG_K3_SYSFW_IMAGE_SIZE_MAX);
                break;
 #endif
+#if CONFIG_IS_ENABLED(NOR_SUPPORT)
+       case BOOT_DEVICE_HYPERFLASH:
+               sysfw_spi_base = get_sysfw_hf_addr();
+               if (!sysfw_spi_base)
+                       ret = -ENODEV;
+               k3_sysfw_spi_copy(sysfw_load_address, sysfw_spi_base,
+                                 CONFIG_K3_SYSFW_IMAGE_SIZE_MAX);
+               break;
+#endif
 #if CONFIG_IS_ENABLED(YMODEM_SUPPORT)
        case BOOT_DEVICE_UART:
 #ifdef CONFIG_K3_EARLY_CONS