diff mbox series

[U-Boot,9/9] spl: spi: Add support for fetching image position from control DT

Message ID 20171228120621.4039-10-marex@denx.de
State Changes Requested
Delegated to: Tom Rini
Headers show
Series spl: Add full fit and u-boot dto support | expand

Commit Message

Marek Vasut Dec. 28, 2017, 12:06 p.m. UTC
Add support for fetching the image position in RAM from control DT
rather than hard-coding it. While doing so, return the return value
of spl_parse_header_image() to make it possible to test application
of DTOs on U-Boot's control DT.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
---
 common/spl/spl_spi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Lukasz Majewski Dec. 28, 2017, 2:29 p.m. UTC | #1
Hi Marek,

> Add support for fetching the image position in RAM from control DT
> rather than hard-coding it. While doing so, return the return value
> of spl_parse_header_image() to make it possible to test application
> of DTOs on U-Boot's control DT.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  common/spl/spl_spi.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
> index 42880d56b9..c2613a494b 100644
> --- a/common/spl/spl_spi.c
> +++ b/common/spl/spl_spi.c
> @@ -75,6 +75,7 @@ static int spl_spi_load_image(struct spl_image_info
> *spl_image, unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
>  	struct spi_flash *flash;
>  	struct image_header *header;
> +	unsigned image_offs, image_size;
>  
>  	/*
>  	 * Load U-Boot image from SPI flash into RAM
> @@ -96,6 +97,18 @@ static int spl_spi_load_image(struct
> spl_image_info *spl_image, payload_offs =
> fdtdec_get_config_int(gd->fdt_blob, "u-boot,spl-payload-offset",
>  					     payload_offs);
> +	image_offs = fdtdec_get_config_int(gd->fdt_blob,
> +
> "u-boot,spl-image-offset", 0);
> +	image_size = fdtdec_get_config_int(gd->fdt_blob,
> +					   "u-boot,spl-image-size",
> 0);
> +	if (image_size) {
> +		err = spi_flash_read(flash, image_offs,
> +				     image_size,
> +				     (void *)CONFIG_SYS_TEXT_BASE);
> +		if (err)
> +			return err;
> +		return spl_parse_image_header(spl_image, header);
> +	}
>  #endif
>  
>  #ifdef CONFIG_SPL_OS_BOOT

Reviewed-by: Lukasz Majewski <lukma@denx.de>

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
Simon Glass Jan. 8, 2018, 4:37 a.m. UTC | #2
Hi Marek,

On 28 December 2017 at 07:29, Lukasz Majewski <lukma@denx.de> wrote:
> Hi Marek,
>
>> Add support for fetching the image position in RAM from control DT
>> rather than hard-coding it. While doing so, return the return value
>> of spl_parse_header_image() to make it possible to test application
>> of DTOs on U-Boot's control DT.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>>  common/spl/spl_spi.c | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)

See comments on previous patch about using binman / adding docs/test.

Regards,
Simon
diff mbox series

Patch

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 42880d56b9..c2613a494b 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -75,6 +75,7 @@  static int spl_spi_load_image(struct spl_image_info *spl_image,
 	unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
 	struct spi_flash *flash;
 	struct image_header *header;
+	unsigned image_offs, image_size;
 
 	/*
 	 * Load U-Boot image from SPI flash into RAM
@@ -96,6 +97,18 @@  static int spl_spi_load_image(struct spl_image_info *spl_image,
 	payload_offs = fdtdec_get_config_int(gd->fdt_blob,
 					     "u-boot,spl-payload-offset",
 					     payload_offs);
+	image_offs = fdtdec_get_config_int(gd->fdt_blob,
+					   "u-boot,spl-image-offset", 0);
+	image_size = fdtdec_get_config_int(gd->fdt_blob,
+					   "u-boot,spl-image-size", 0);
+	if (image_size) {
+		err = spi_flash_read(flash, image_offs,
+				     image_size,
+				     (void *)CONFIG_SYS_TEXT_BASE);
+		if (err)
+			return err;
+		return spl_parse_image_header(spl_image, header);
+	}
 #endif
 
 #ifdef CONFIG_SPL_OS_BOOT