public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vaishnav Achath <vaishnav.a@ti.com>
To: <hs@denx.de>, <u-boot@lists.denx.de>, <sjg@chromium.org>,
	<mr.nuke.me@gmail.com>, <jh80.chung@samsung.com>,
	<michal.simek@amd.com>, <marek.behun@nic.cz>, <pali@kernel.org>,
	<sr@denx.de>, <marex@denx.de>, <ricardo@foundries.io>,
	<vigneshr@ti.com>, <s-anna@ti.com>, <kishon@ti.com>,
	<j-keerthy@ti.com>, <p.yadav@ti.com>
Cc: <vaishnav.a@ti.com>
Subject: [PATCH v2 1/2] common: spl: spl_spi: add support for dynamic override of sf bus
Date: Wed, 11 May 2022 11:33:51 +0530	[thread overview]
Message-ID: <20220511060352.28140-2-vaishnav.a@ti.com> (raw)
In-Reply-To: <20220511060352.28140-1-vaishnav.a@ti.com>

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>
---
 common/spl/spl_spi.c | 16 +++++++++++++---
 include/spl.h        | 16 ++++++++++++++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index cf3f7ef4c0..3eef2f8d68 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -71,6 +71,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
@@ -83,15 +93,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) {
diff --git a/include/spl.h b/include/spl.h
index 6134aba857..438f2fdf7c 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -361,6 +361,22 @@ int spl_load_imx_container(struct spl_image_info *spl_image,
 void preloader_console_init(void);
 u32 spl_boot_device(void);
 
+/**
+ * spl_spi_boot_bus() - Lookup function for the SPI boot bus source.
+ *
+ * This function returns the SF bus to load from.
+ * If not overridden, it is weakly defined in common/spl/spl_spi.c.
+ */
+u32 spl_spi_boot_bus(void);
+
+/**
+ * spl_spi_boot_cs() - Lookup function for the SPI boot CS source.
+ *
+ * This function returns the SF CS to load from.
+ * If not overridden, it is weakly defined in common/spl/spl_spi.c.
+ */
+u32 spl_spi_boot_cs(void);
+
 /**
  * spl_mmc_boot_mode() - Lookup function for the mode of an MMC boot source.
  * @boot_device:	ID of the device which the MMC driver wants to read
-- 
2.17.1


  reply	other threads:[~2022-05-11  6:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11  6:03 [PATCH v2 0/2] Add support for dynamic overriding of default SF bus Vaishnav Achath
2022-05-11  6:03 ` Vaishnav Achath [this message]
2022-05-11  8:24   ` [PATCH v2 1/2] common: spl: spl_spi: add support for dynamic override of sf bus Heiko Schocher
2022-05-12  6:28     ` Vaishnav Achath
2022-05-31  8:59   ` Pratyush Yadav
2022-05-11  6:03 ` [PATCH v2 2/2] arm: k3: j721e: add dynamic sf bus override support for j721e Vaishnav Achath
2022-05-31 10:59   ` Pratyush Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220511060352.28140-2-vaishnav.a@ti.com \
    --to=vaishnav.a@ti.com \
    --cc=hs@denx.de \
    --cc=j-keerthy@ti.com \
    --cc=jh80.chung@samsung.com \
    --cc=kishon@ti.com \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=michal.simek@amd.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=p.yadav@ti.com \
    --cc=pali@kernel.org \
    --cc=ricardo@foundries.io \
    --cc=s-anna@ti.com \
    --cc=sjg@chromium.org \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox