8 * Michal Simek <michal.simek@xilinx.com>
9 * Stefan Agner <stefan.agner@toradex.com>
11 * SPDX-License-Identifier: GPL-2.0+
14 #include <binman_sym.h>
19 #ifndef CONFIG_SPL_LOAD_FIT_ADDRESS
20 # define CONFIG_SPL_LOAD_FIT_ADDRESS 0
23 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
24 ulong count, void *buf)
26 debug("%s: sector %lx, count %lx, buf %lx\n",
27 __func__, sector, count, (ulong)buf);
28 memcpy(buf, (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS + sector), count);
32 static int spl_ram_load_image(struct spl_image_info *spl_image,
33 struct spl_boot_device *bootdev)
35 struct image_header *header;
37 header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS;
39 #if defined(CONFIG_SPL_DFU_SUPPORT)
40 if (bootdev->boot_device == BOOT_DEVICE_DFU)
41 spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
44 if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
45 image_get_magic(header) == FDT_MAGIC) {
46 struct spl_load_info load;
50 load.read = spl_ram_load_read;
51 spl_load_simple_fit(spl_image, &load, 0, header);
53 ulong u_boot_pos = binman_sym(ulong, u_boot_any, pos);
55 debug("Legacy image\n");
57 * Get the header. It will point to an address defined by
58 * handoff which will tell where the image located inside
61 debug("u_boot_pos = %lx\n", u_boot_pos);
62 if (u_boot_pos == BINMAN_SYM_MISSING) {
64 * No binman support or no information. For now, fix it
65 * to the address pointed to by U-Boot.
67 u_boot_pos = CONFIG_SYS_TEXT_BASE -
68 sizeof(struct image_header);
70 header = (struct image_header *)map_sysmem(u_boot_pos, 0);
72 spl_parse_image_header(spl_image, header);
77 #if defined(CONFIG_SPL_RAM_DEVICE)
78 SPL_LOAD_IMAGE_METHOD("RAM", 0, BOOT_DEVICE_RAM, spl_ram_load_image);
80 #if defined(CONFIG_SPL_DFU_SUPPORT)
81 SPL_LOAD_IMAGE_METHOD("DFU", 0, BOOT_DEVICE_DFU, spl_ram_load_image);