]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: k3: j721e: add dynamic sf bus override support for j721e
authorVaishnav Achath <vaishnav.a@ti.com>
Fri, 3 Jun 2022 06:02:16 +0000 (11:32 +0530)
committerTom Rini <trini@konsulko.com>
Wed, 6 Jul 2022 18:30:08 +0000 (14:30 -0400)
implement overrides for spl_spi_boot_bus() and spl_spi_boot_cs()
lookup functions according to bootmode selection, so as to support
both QSPI and OSPI boot using the same build.

Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
arch/arm/mach-k3/j721e_init.c
arch/arm/mach-k3/sysfw-loader.c

index f503f15f192ac83b9e1d09d52c2e9c3b3bc843c4..e56ca6d0f5ff91616f532be9197032451f5b1328 100644 (file)
@@ -355,6 +355,17 @@ static u32 __get_primary_bootmedia(u32 main_devstat, u32 wkup_devstat)
        return bootmode;
 }
 
+u32 spl_spi_boot_bus(void)
+{
+       u32 wkup_devstat = readl(CTRLMMR_WKUP_DEVSTAT);
+       u32 main_devstat = readl(CTRLMMR_MAIN_DEVSTAT);
+       u32 bootmode = ((wkup_devstat & WKUP_DEVSTAT_PRIMARY_BOOTMODE_MASK) >>
+                       WKUP_DEVSTAT_PRIMARY_BOOTMODE_SHIFT) |
+                       ((main_devstat & MAIN_DEVSTAT_BOOT_MODE_B_MASK) << BOOT_MODE_B_SHIFT);
+
+       return (bootmode == BOOT_DEVICE_QSPI) ? 1 : 0;
+}
+
 u32 spl_boot_device(void)
 {
        u32 wkup_devstat = readl(CTRLMMR_WKUP_DEVSTAT);
index 988e75862929d1893310f8fe1074d48f29ccc283..b3beeca9472edf18bcf2d7df8aeb1491704dbfc8 100644 (file)
@@ -324,9 +324,9 @@ static void *k3_sysfw_get_spi_addr(void)
        struct udevice *dev;
        fdt_addr_t addr;
        int ret;
+       unsigned int sf_bus = spl_spi_boot_bus();
 
-       ret = uclass_find_device_by_seq(UCLASS_SPI, CONFIG_SF_DEFAULT_BUS,
-                                       &dev);
+       ret = uclass_find_device_by_seq(UCLASS_SPI, sf_bus, &dev);
        if (ret)
                return NULL;