obj-y += cpu.o iomux.o fuse.o lpcg.o clock.o
obj-y += lowlevel_init.o
-obj-y += image.o
+obj-$(CONFIG_SPL_BUILD) += image.o
obj-$(CONFIG_SPL_BUILD) += parser.o
ifneq ($(CONFIG_SPL_BUILD),y)
obj-y += partition.o
#define MMC_DEV 0
#define QSPI_DEV 1
#define NAND_DEV 2
+#define QSPI_NOR_DEV 3
static int __get_container_size(ulong addr)
{
}
#endif
+#ifdef CONFIG_SPL_NOR_SUPPORT
+ if (dev_type == QSPI_NOR_DEV) {
+ memcpy(buf, (const void *)offset, CONTAINER_HDR_ALIGNMENT);
+ }
+#endif
+
ret = __get_container_size((ulong)buf);
free(buf);
offset = CONTAINER_HDR_QSPI_OFFSET;
} else if (dev_type == NAND_DEV) {
offset = CONTAINER_HDR_NAND_OFFSET;
+ } else if (dev_type == QSPI_NOR_DEV) {
+ offset = CONTAINER_HDR_QSPI_OFFSET + 0x08000000;
}
return offset;
return end;
}
#endif
+
+#ifdef CONFIG_SPL_NOR_SUPPORT
+unsigned long spl_nor_get_uboot_base(void)
+{
+ int end;
+
+ /* Calculate the image set end,
+ * if it is less than CONFIG_SYS_UBOOT_BASE(0x8281000),
+ * we use CONFIG_SYS_UBOOT_BASE
+ * Otherwise, use the calculated address
+ */
+ end = get_imageset_end((void *)NULL, QSPI_NOR_DEV);
+ if (end <= CONFIG_SYS_UBOOT_BASE)
+ end = CONFIG_SYS_UBOOT_BASE;
+ else
+ end = ROUND(end, SZ_1K);
+
+ printf("Load image from NOR 0x%x\n", end);
+
+ return end;
+}
+#endif
return ret;
}
+
+int __weak nor_load_image_parse_container(struct spl_image_info *spl_image,
+ unsigned long offset)
+{
+ int ret = 0;
+
+ current_dev_type = RAM_DEV;
+ device = NULL;
+
+ start_offset = offset;
+
+ ret = read_auth_container(spl_image);
+
+ return ret;
+}
}
#endif
+unsigned long __weak spl_nor_get_uboot_base(void)
+{
+ return CONFIG_SYS_UBOOT_BASE;
+}
+
+#ifdef CONFIG_PARSE_CONTAINER
+int __weak nor_load_image_parse_container(struct spl_image_info *spl_image,
+ unsigned long offset)
+{
+ return -EINVAL;
+}
+#endif
+
static int spl_nor_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
* defined location in SDRAM
*/
#ifdef CONFIG_SPL_LOAD_FIT
- header = (const struct image_header *)CONFIG_SYS_UBOOT_BASE;
+ header = (const struct image_header *)spl_nor_get_uboot_base();
if (image_get_magic(header) == FDT_MAGIC) {
debug("Found FIT format U-Boot\n");
load.bl_len = 1;
load.read = spl_nor_load_read;
ret = spl_load_simple_fit(spl_image, &load,
- CONFIG_SYS_UBOOT_BASE,
+ spl_nor_get_uboot_base(),
(void *)header);
return ret;
}
#endif
+
+#ifdef CONFIG_PARSE_CONTAINER
+ ret = nor_load_image_parse_container(spl_image,
+ spl_nor_get_uboot_base());
+ return ret;
+#else
ret = spl_parse_image_header(spl_image,
- (const struct image_header *)CONFIG_SYS_UBOOT_BASE);
+ (const struct image_header *)spl_nor_get_uboot_base());
if (ret)
return ret;
memcpy((void *)(unsigned long)spl_image->load_addr,
- (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
+ (void *)(spl_nor_get_uboot_base() + sizeof(struct image_header)),
spl_image->size);
+#endif
return 0;
}