summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorLokesh Vutla <lokeshvutla@ti.com>2016-05-24 10:34:42 +0530
committerTom Rini <trini@konsulko.com>2016-05-27 15:47:14 -0400
commit8bd887727913e9393ef467cdf8b0146babb2673d (patch)
tree7d96dda79f1fce3c0711281df72d7cd368770b31 /common/spl
parent0985294604bb713d56c8dbedf1da462c7f86f90f (diff)
downloadu-boot-imx-8bd887727913e9393ef467cdf8b0146babb2673d.zip
u-boot-imx-8bd887727913e9393ef467cdf8b0146babb2673d.tar.gz
u-boot-imx-8bd887727913e9393ef467cdf8b0146babb2673d.tar.bz2
spl: Support loading a FIT from NAND
Detect a FIT when loading from NAND and handle it using the new FIT SPL support. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> [trini: Make sure we continue to use (void *)(unsigned long) for load_addr]. Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/spl_nand.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index bbd9546..7cf0d1b 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -9,6 +9,8 @@
#include <spl.h>
#include <asm/io.h>
#include <nand.h>
+#include <libfdt_env.h>
+#include <fdt.h>
#if defined(CONFIG_SPL_NAND_RAW_ONLY)
int spl_nand_load_image(void)
@@ -24,6 +26,19 @@ int spl_nand_load_image(void)
return 0;
}
#else
+
+static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
+ ulong size, void *dst)
+{
+ int ret;
+
+ ret = nand_spl_load_image(offs, size, dst);
+ if (!ret)
+ return size;
+ else
+ return 0;
+}
+
static int spl_nand_load_element(int offset, struct image_header *header)
{
int err;
@@ -32,12 +47,24 @@ static int spl_nand_load_element(int offset, struct image_header *header)
if (err)
return err;
- err = spl_parse_image_header(header);
- if (err)
- return err;
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+ image_get_magic(header) == FDT_MAGIC) {
+ struct spl_load_info load;
- return nand_spl_load_image(offset, spl_image.size,
- (void *)(unsigned long)spl_image.load_addr);
+ debug("Found FIT\n");
+ load.dev = NULL;
+ load.priv = NULL;
+ load.filename = NULL;
+ load.bl_len = 1;
+ load.read = spl_nand_fit_read;
+ return spl_load_simple_fit(&load, offset, header);
+ } else {
+ err = spl_parse_image_header(header);
+ if (err)
+ return err;
+ return nand_spl_load_image(offset, spl_image.size,
+ (void *)(ulong)spl_image.load_addr);
+ }
}
int spl_nand_load_image(void)