diff mbox

[U-Boot,1/3] spl: spi: override CONFIG_SYS_SPI_U_BOOT_OFFS via /config-property

Message ID 1492443913-51501-1-git-send-email-philipp.tomsich@theobroma-systems.com
State Accepted
Commit 2bac55bc16aca60346dabfdda4ca7e0d19c2cff3
Delegated to: Tom Rini
Headers show

Commit Message

Philipp Tomsich April 17, 2017, 3:45 p.m. UTC
For the RK3399-Q7, we need some flexibility (depending on the feature
set we include in the SPL stage and how large our SPI flash is) in
positioning the SPL payload (i.e. the FIT image containing U-Boot, ATF
and the M0 payload) in our SPI flash.

To avoid having to deal with this through different U-Boot images, we
introduce a the '/config/u-boot,spl-payload-offset' property node
allow it to override the default setting.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

---

 common/spl/spl_spi.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Simon Glass April 18, 2017, 4 a.m. UTC | #1
On 17 April 2017 at 09:45, Philipp Tomsich <
philipp.tomsich@theobroma-systems.com> wrote:
> For the RK3399-Q7, we need some flexibility (depending on the feature
> set we include in the SPL stage and how large our SPI flash is) in
> positioning the SPL payload (i.e. the FIT image containing U-Boot, ATF
> and the M0 payload) in our SPI flash.
>
> To avoid having to deal with this through different U-Boot images, we
> introduce a the '/config/u-boot,spl-payload-offset' property node
> allow it to override the default setting.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>
> ---
>
> common/spl/spl_spi.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Tom Rini May 12, 2017, 5:18 p.m. UTC | #2
On Mon, Apr 17, 2017 at 05:45:11PM +0200, Philipp Tomsich wrote:

> For the RK3399-Q7, we need some flexibility (depending on the feature
> set we include in the SPL stage and how large our SPI flash is) in
> positioning the SPL payload (i.e. the FIT image containing U-Boot, ATF
> and the M0 payload) in our SPI flash.
> 
> To avoid having to deal with this through different U-Boot images, we
> introduce a the '/config/u-boot,spl-payload-offset' property node
> allow it to override the default setting.
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 925a1b1..42880d5 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -15,6 +15,8 @@ 
 #include <errno.h>
 #include <spl.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef CONFIG_SPL_OS_BOOT
 /*
  * Load the kernel, check for a valid header we can parse, and if found load
@@ -70,6 +72,7 @@  static int spl_spi_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
 	int err = 0;
+	unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
 	struct spi_flash *flash;
 	struct image_header *header;
 
@@ -89,12 +92,18 @@  static int spl_spi_load_image(struct spl_image_info *spl_image,
 	/* use CONFIG_SYS_TEXT_BASE as temporary storage area */
 	header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
 
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+	payload_offs = fdtdec_get_config_int(gd->fdt_blob,
+					     "u-boot,spl-payload-offset",
+					     payload_offs);
+#endif
+
 #ifdef CONFIG_SPL_OS_BOOT
 	if (spl_start_uboot() || spi_load_image_os(spl_image, flash, header))
 #endif
 	{
 		/* Load u-boot, mkimage header is 64 bytes. */
-		err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
+		err = spi_flash_read(flash, payload_offs, 0x40,
 				     (void *)header);
 		if (err) {
 			debug("%s: Failed to read from SPI flash (err=%d)\n",
@@ -113,13 +122,13 @@  static int spl_spi_load_image(struct spl_image_info *spl_image,
 			load.bl_len = 1;
 			load.read = spl_spi_fit_read;
 			err = spl_load_simple_fit(spl_image, &load,
-						  CONFIG_SYS_SPI_U_BOOT_OFFS,
+						  payload_offs,
 						  header);
 		} else {
 			err = spl_parse_image_header(spl_image, header);
 			if (err)
 				return err;
-			err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
+			err = spi_flash_read(flash, payload_offs,
 					     spl_image->size,
 					     (void *)spl_image->load_addr);
 		}