8 * Michal Simek <michal.simek@xilinx.com>
9 * Stefan Agner <stefan.agner@toradex.com>
11 * SPDX-License-Identifier: GPL-2.0+
17 #ifndef CONFIG_SPL_LOAD_FIT_ADDRESS
18 # define CONFIG_SPL_LOAD_FIT_ADDRESS 0
21 static ulong
spl_ram_load_read(struct spl_load_info
*load
, ulong sector
,
22 ulong count
, void *buf
)
24 debug("%s: sector %lx, count %lx, buf %lx\n",
25 __func__
, sector
, count
, (ulong
)buf
);
26 memcpy(buf
, (void *)(CONFIG_SPL_LOAD_FIT_ADDRESS
+ sector
), count
);
30 static int spl_ram_load_image(struct spl_image_info
*spl_image
,
31 struct spl_boot_device
*bootdev
)
33 struct image_header
*header
;
35 header
= (struct image_header
*)CONFIG_SPL_LOAD_FIT_ADDRESS
;
37 #if defined(CONFIG_SPL_DFU_SUPPORT)
38 if (bootdev
->boot_device
== BOOT_DEVICE_DFU
)
39 spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0");
42 if (IS_ENABLED(CONFIG_SPL_LOAD_FIT
) &&
43 image_get_magic(header
) == FDT_MAGIC
) {
44 struct spl_load_info load
;
48 load
.read
= spl_ram_load_read
;
49 spl_load_simple_fit(spl_image
, &load
, 0, header
);
51 debug("Legacy image\n");
53 * Get the header. It will point to an address defined by
54 * handoff which will tell where the image located inside
55 * the flash. For now, it will temporary fixed to address
58 header
= (struct image_header
*)
59 (CONFIG_SYS_TEXT_BASE
- sizeof(struct image_header
));
61 spl_parse_image_header(spl_image
, header
);
66 #if defined(CONFIG_SPL_RAM_DEVICE)
67 SPL_LOAD_IMAGE_METHOD("RAM", 0, BOOT_DEVICE_RAM
, spl_ram_load_image
);
69 #if defined(CONFIG_SPL_DFU_SUPPORT)
70 SPL_LOAD_IMAGE_METHOD("DFU", 0, BOOT_DEVICE_DFU
, spl_ram_load_image
);