summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVaishnav Achath <vaishnav.a@ti.com>2022-05-30 12:16:42 +0530
committerAnand Gadiyar <gadiyar@ti.com>2022-06-02 20:10:00 -0500
commit6fc85e5c8bf51ac680cfcfff074809c69bef2d89 (patch)
treee4efa30808c89baa1ec949850d6fb92e0a3d01fc /common
parent76952048bb80dddea35475985232e73a9ff5d501 (diff)
common: spl: spl_spi: add support for dynamic override of sf bus
Currently the SPI flash to load from is defined through the compile time config CONFIG_SF_DEFAULT_BUS and CONFIG_SF_DEFAULT_CS, this prevents the loading of binaries from different SPI flash using the same build.E.g. supporting QSPI flash boot and OSPI flash boot on J721E platform is not possible due to this limitation. This commit adds lookup functions spl_spi_boot_bus() and spl_spi_boot_cs for identifying the flash device based on the selected boot device, when not overridden the lookup functions are weakly defined in common/spl/spl_spi.c. Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_spi.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 2744fb5d52..d6528f078f 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -70,6 +70,16 @@ unsigned int __weak spl_spi_get_uboot_offs(struct spi_flash *flash)
return CONFIG_SYS_SPI_U_BOOT_OFFS;
}
+u32 __weak spl_spi_boot_bus(void)
+{
+ return CONFIG_SF_DEFAULT_BUS;
+}
+
+u32 __weak spl_spi_boot_cs(void)
+{
+ return CONFIG_SF_DEFAULT_CS;
+}
+
/*
* The main entry for SPI booting. It's necessary that SDRAM is already
* configured and available since this code loads the main U-Boot image
@@ -82,15 +92,15 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
unsigned int payload_offs;
struct spi_flash *flash;
struct image_header *header;
+ unsigned int sf_bus = spl_spi_boot_bus();
+ unsigned int sf_cs = spl_spi_boot_cs();
/*
* Load U-Boot image from SPI flash into RAM
* In DM mode: defaults speed and mode will be
* taken from DT when available
*/
-
- flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
- CONFIG_SF_DEFAULT_CS,
+ flash = spi_flash_probe(sf_bus, sf_cs,
CONFIG_SF_DEFAULT_SPEED,
CONFIG_SF_DEFAULT_MODE);
if (!flash) {