3 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
5 * SPDX-License-Identifier: GPL-2.0+
13 #if defined(CONFIG_SPL_NAND_RAW_ONLY)
14 int spl_nand_load_image(void)
18 nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
19 CONFIG_SYS_NAND_U_BOOT_SIZE,
20 (void *)CONFIG_SYS_NAND_U_BOOT_DST);
21 spl_set_header_raw_uboot();
27 static int spl_nand_load_element(int offset, struct image_header *header)
31 err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
35 err = spl_parse_image_header(header);
39 return nand_spl_load_image(offset, spl_image.size,
40 (void *)(unsigned long)spl_image.load_addr);
43 int spl_nand_load_image(void)
46 struct image_header *header;
47 int *src __attribute__((unused));
48 int *dst __attribute__((unused));
50 #ifdef CONFIG_SPL_NAND_SOFTECC
51 debug("spl: nand - using sw ecc\n");
53 debug("spl: nand - using hw ecc\n");
57 /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
58 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
59 #ifdef CONFIG_SPL_OS_BOOT
60 if (!spl_start_uboot()) {
62 * load parameter image
63 * load to temp position since nand_spl_load_image reads
64 * a whole block which is typically larger than
65 * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
66 * following sections like BSS
68 nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
69 CONFIG_CMD_SPL_WRITE_SIZE,
70 (void *)CONFIG_SYS_TEXT_BASE);
71 /* copy to destintion */
72 for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
73 src = (int *)CONFIG_SYS_TEXT_BASE;
74 src < (int *)(CONFIG_SYS_TEXT_BASE +
75 CONFIG_CMD_SPL_WRITE_SIZE);
77 writel(readl(src), dst);
81 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
82 sizeof(*header), (void *)header);
83 err = spl_parse_image_header(header);
86 if (header->ih_os == IH_OS_LINUX) {
87 /* happy - was a linux */
88 err = nand_spl_load_image(
89 CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
91 (void *)spl_image.load_addr);
95 puts("The Expected Linux image was not "
96 "found. Please check your NAND "
98 puts("Trying to start u-boot now...\n");
102 #ifdef CONFIG_NAND_ENV_DST
103 spl_nand_load_element(CONFIG_ENV_OFFSET, header);
104 #ifdef CONFIG_ENV_OFFSET_REDUND
105 spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
109 err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);