summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLokesh Vutla <lokeshvutla@ti.com>2016-05-24 10:34:39 +0530
committerTom Rini <trini@konsulko.com>2016-05-27 15:41:40 -0400
commit97ca364fafe31dd986774d282674a3fe925a546a (patch)
tree964751a066ebd4a4b8e472d1c8a902f0fcb0f57d /common
parenteafd5410af2ade58f25da707edaba85e44999621 (diff)
downloadblackbird-obmc-uboot-97ca364fafe31dd986774d282674a3fe925a546a.tar.gz
blackbird-obmc-uboot-97ca364fafe31dd986774d282674a3fe925a546a.zip
spl: Support loading a FIT from FAT FS
Detect a FIT when loading from a FAT File system and handle it using the new FIT SPL support. Tested-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_fat.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 5b0d96925e..db676186d3 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -15,6 +15,7 @@
#include <fat.h>
#include <errno.h>
#include <image.h>
+#include <libfdt.h>
static int fat_registered;
@@ -39,6 +40,20 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
return err;
}
+static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,
+ ulong size, void *buf)
+{
+ loff_t actread;
+ int ret;
+ char *filename = (char *)load->filename;
+
+ ret = fat_read_file(filename, buf, file_offset, size, &actread);
+ if (ret)
+ return ret;
+
+ return actread;
+}
+
int spl_load_image_fat(struct blk_desc *block_dev,
int partition,
const char *filename)
@@ -57,11 +72,24 @@ int spl_load_image_fat(struct blk_desc *block_dev,
if (err <= 0)
goto end;
- err = spl_parse_image_header(header);
- if (err)
- goto end;
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+ image_get_magic(header) == FDT_MAGIC) {
+ struct spl_load_info load;
+
+ debug("Found FIT\n");
+ load.read = spl_fit_read;
+ load.bl_len = 1;
+ load.filename = (void *)filename;
+ load.priv = NULL;
- err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
+ return spl_load_simple_fit(&load, 0, header);
+ } else {
+ err = spl_parse_image_header(header);
+ if (err)
+ goto end;
+
+ err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
+ }
end:
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
OpenPOWER on IntegriCloud