mmc: fsl_esdhc: Fix SDR104 and HS200 support
[oweals/u-boot.git] / common / spl / spl_fat.c
index 87dd5532103a455a7614c6fc305b89096dfb3042..c2eb097365ffbea29c16610d305c3e44d6d1107d 100644 (file)
@@ -9,6 +9,8 @@
  */
 
 #include <common.h>
+#include <env.h>
+#include <log.h>
 #include <spl.h>
 #include <asm/u-boot.h>
 #include <fat.h>
@@ -63,14 +65,24 @@ int spl_load_image_fat(struct spl_image_info *spl_image,
        if (err)
                goto end;
 
-       header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
-                                               sizeof(struct image_header));
+       header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
 
        err = file_fat_read(filename, header, sizeof(struct image_header));
        if (err <= 0)
                goto end;
 
-       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+       if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) &&
+           image_get_magic(header) == FDT_MAGIC) {
+               err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0);
+               if (err <= 0)
+                       goto end;
+               err = spl_parse_image_header(spl_image,
+                               (struct image_header *)CONFIG_SYS_LOAD_ADDR);
+               if (err == -EAGAIN)
+                       return err;
+               if (err == 0)
+                       err = 1;
+       } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
            image_get_magic(header) == FDT_MAGIC) {
                struct spl_load_info load;