[PATCH 2/2] arm: k3: j721e: enable dynamic sf bus detect support for j721e

Vaishnav Achath vaishnav.a at ti.com
Mon May 9 08:43:03 CEST 2022


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.

Also enable the CONFIG_SPL_DYNAMIC_SF_BUS_DETECT for j721e R5
and A72.

Signed-off-by: Vaishnav Achath <vaishnav.a at ti.com>
---
 arch/arm/mach-k3/j721e_init.c   | 17 +++++++++++++++++
 arch/arm/mach-k3/sysfw-loader.c |  6 ++++--
 configs/j721e_evm_a72_defconfig |  1 +
 configs/j721e_evm_r5_defconfig  |  1 +
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index f503f15f19..82391b5cf8 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -355,6 +355,23 @@ 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;
+}
+
+/* both OSPI and QSPI flash are in CS0 */
+u32 spl_spi_boot_cs(void)
+{
+	return 0;
+}
+
 u32 spl_boot_device(void)
 {
 	u32 wkup_devstat = readl(CTRLMMR_WKUP_DEVSTAT);
diff --git a/arch/arm/mach-k3/sysfw-loader.c b/arch/arm/mach-k3/sysfw-loader.c
index 5e48c36ccd..ef9d7e9c91 100644
--- a/arch/arm/mach-k3/sysfw-loader.c
+++ b/arch/arm/mach-k3/sysfw-loader.c
@@ -324,9 +324,11 @@ static void *k3_sysfw_get_spi_addr(void)
 	struct udevice *dev;
 	fdt_addr_t addr;
 	int ret;
+	unsigned int sf_bus = CONFIG_SF_DEFAULT_BUS;
 
-	ret = uclass_find_device_by_seq(UCLASS_SPI, CONFIG_SF_DEFAULT_BUS,
-					&dev);
+	if (IS_ENABLED(CONFIG_SPL_DYNAMIC_SF_BUS_DETECT))
+		sf_bus = spl_spi_boot_bus();
+	ret = uclass_find_device_by_seq(UCLASS_SPI, sf_bus, &dev);
 	if (ret)
 		return NULL;
 
diff --git a/configs/j721e_evm_a72_defconfig b/configs/j721e_evm_a72_defconfig
index 931abf5e59..18ba759da3 100644
--- a/configs/j721e_evm_a72_defconfig
+++ b/configs/j721e_evm_a72_defconfig
@@ -127,6 +127,7 @@ CONFIG_MMC_SDHCI_AM654=y
 CONFIG_MTD=y
 CONFIG_DM_MTD=y
 CONFIG_MTD_NOR_FLASH=y
+CONFIG_SPL_DYNAMIC_SF_BUS_DETECT=y
 CONFIG_CFI_FLASH=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_FLASH_CFI_MTD=y
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index 6553212de8..c437d3c118 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
+CONFIG_SPL_DYNAMIC_SF_BUS_DETECT=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x80080000
-- 
2.17.1



More information about the U-Boot mailing list