diff options
author | Lokesh Vutla <lokeshvutla@ti.com> | 2016-05-24 10:34:40 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-05-27 15:41:40 -0400 |
commit | 00d559561ea7f774a7758c70b79e1e7e38b62459 (patch) | |
tree | c3e155b3ac4bf4c351bcc6725d5e46ff36523935 /drivers/mtd | |
parent | 97ca364fafe31dd986774d282674a3fe925a546a (diff) | |
download | u-boot-imx-00d559561ea7f774a7758c70b79e1e7e38b62459.zip u-boot-imx-00d559561ea7f774a7758c70b79e1e7e38b62459.tar.gz u-boot-imx-00d559561ea7f774a7758c70b79e1e7e38b62459.tar.bz2 |
spl: Support loading a FIT from SPI
Detect a FIT when loading from SPI and handle it using the
new FIT SPL support.
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/spi/spi_spl_load.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c index 46c98a9..bac1e85 100644 --- a/drivers/mtd/spi/spi_spl_load.c +++ b/drivers/mtd/spi/spi_spl_load.c @@ -48,6 +48,18 @@ static int spi_load_image_os(struct spi_flash *flash, } #endif +static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector, + ulong count, void *buf) +{ + struct spi_flash *flash = load->dev; + ulong ret; + + ret = spi_flash_read(flash, sector, count, buf); + if (!ret) + return count; + else + return 0; +} /* * 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 @@ -85,11 +97,26 @@ int spl_spi_load_image(void) if (err) return err; - err = spl_parse_image_header(header); - if (err) - return err; - err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, - spl_image.size, (void *)spl_image.load_addr); + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) { + struct spl_load_info load; + + debug("Found FIT\n"); + load.dev = flash; + load.priv = NULL; + load.filename = NULL; + load.bl_len = 1; + load.read = spl_spi_fit_read; + err = spl_load_simple_fit(&load, + CONFIG_SYS_SPI_U_BOOT_OFFS, + header); + } else { + err = spl_parse_image_header(header); + if (err) + return err; + err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, + spl_image.size, + (void *)spl_image.load_addr); + } } return err; |