summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2016-04-28 09:54:16 +0200
committerMichal Simek <michal.simek@xilinx.com>2016-05-24 11:15:01 +0200
commit8d16e1d5931bb1323ef5307204563b7afcb3b6c3 (patch)
treebb8c050013ff492df15798c524bd37235fddf4c1 /common
parentf44e603f73ea43268f0858b9aa4daf962f1eb347 (diff)
downloadtalos-obmc-uboot-8d16e1d5931bb1323ef5307204563b7afcb3b6c3.tar.gz
talos-obmc-uboot-8d16e1d5931bb1323ef5307204563b7afcb3b6c3.zip
SPL: FIT: Enable SPL_FIT_LOAD in RAM based boot mode
Support loading FIT in SPL for RAM bootmode. CONFIG_SPL_LOAD_FIT_ADRESS points to address where FIT image is stored in memory. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c
index caaf135f9a..bdde716918 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -140,20 +140,47 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
image_entry();
}
+#ifndef CONFIG_SPL_LOAD_FIT_ADDRESS
+# define CONFIG_SPL_LOAD_FIT_ADDRESS 0
+#endif
+
#ifdef CONFIG_SPL_RAM_DEVICE
+static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
+ ulong count, void *buf)
+{
+ debug("%s: sector %lx, count %lx, buf %lx\n",
+ __func__, sector, count, (ulong)buf);
+ memcpy(buf, (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + sector), count);
+ return count;
+}
+
static int spl_ram_load_image(void)
{
- const struct image_header *header;
+ struct image_header *header;
- /*
- * Get the header. It will point to an address defined by handoff
- * which will tell where the image located inside the flash. For
- * now, it will temporary fixed to address pointed by U-Boot.
- */
- header = (struct image_header *)
- (CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
+ header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
- spl_parse_image_header(header);
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+ image_get_magic(header) == FDT_MAGIC) {
+ struct spl_load_info load;
+
+ debug("Found FIT\n");
+ load.bl_len = 1;
+ load.read = spl_ram_load_read;
+ spl_load_simple_fit(&load, 0, header);
+ } else {
+ debug("Legacy image\n");
+ /*
+ * Get the header. It will point to an address defined by
+ * handoff which will tell where the image located inside
+ * the flash. For now, it will temporary fixed to address
+ * pointed by U-Boot.
+ */
+ header = (struct image_header *)
+ (CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
+
+ spl_parse_image_header(header);
+ }
return 0;
}
OpenPOWER on IntegriCloud