1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Stefan Roese <sr@denx.de>
9 #ifdef CONFIG_SPL_LOAD_FIT
10 static ulong spl_nor_load_read(struct spl_load_info *load, ulong sector,
11 ulong count, void *buf)
13 debug("%s: sector %lx, count %lx, buf %p\n",
14 __func__, sector, count, buf);
15 memcpy(buf, (void *)sector, count);
21 static int spl_nor_load_image(struct spl_image_info *spl_image,
22 struct spl_boot_device *bootdev)
25 __maybe_unused const struct image_header *header;
26 __maybe_unused struct spl_load_info load;
29 * Loading of the payload to SDRAM is done with skipping of
30 * the mkimage header in this SPL NOR driver
32 spl_image->flags |= SPL_COPY_PAYLOAD_ONLY;
34 #ifdef CONFIG_SPL_OS_BOOT
35 if (!spl_start_uboot()) {
37 * Load Linux from its location in NOR flash to its defined
40 header = (const struct image_header *)CONFIG_SYS_OS_BASE;
41 #ifdef CONFIG_SPL_LOAD_FIT
42 if (image_get_magic(header) == FDT_MAGIC) {
45 load.read = spl_nor_load_read;
47 ret = spl_load_simple_fit(spl_image, &load,
54 if (image_get_os(header) == IH_OS_LINUX) {
55 /* happy - was a Linux */
57 ret = spl_parse_image_header(spl_image, header);
61 memcpy((void *)spl_image->load_addr,
62 (void *)(CONFIG_SYS_OS_BASE +
63 sizeof(struct image_header)),
65 #ifdef CONFIG_SYS_FDT_BASE
66 spl_image->arg = (void *)CONFIG_SYS_FDT_BASE;
71 puts("The Expected Linux image was not found.\n"
72 "Please check your NOR configuration.\n"
73 "Trying to start u-boot now...\n");
79 * Load real U-Boot from its location in NOR flash to its
80 * defined location in SDRAM
82 #ifdef CONFIG_SPL_LOAD_FIT
83 header = (const struct image_header *)CONFIG_SYS_UBOOT_BASE;
84 if (image_get_magic(header) == FDT_MAGIC) {
85 debug("Found FIT format U-Boot\n");
87 load.read = spl_nor_load_read;
88 ret = spl_load_simple_fit(spl_image, &load,
89 CONFIG_SYS_UBOOT_BASE,
95 ret = spl_parse_image_header(spl_image,
96 (const struct image_header *)CONFIG_SYS_UBOOT_BASE);
100 memcpy((void *)(unsigned long)spl_image->load_addr,
101 (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
106 SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image);