#include <fat.h>
#include <errno.h>
#include <image.h>
+#include <libfdt.h>
static int fat_registered;
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)
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