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 spl_parse_image_header(header);
36 return nand_spl_load_image(offset, spl_image.size,
37 (void *)(unsigned long)spl_image.load_addr);
40 int spl_nand_load_image(void)
43 struct image_header *header;
44 int *src __attribute__((unused));
45 int *dst __attribute__((unused));
47 debug("spl: nand - using hw ecc\n");
50 /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
51 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
52 #ifdef CONFIG_SPL_OS_BOOT
53 if (!spl_start_uboot()) {
55 * load parameter image
56 * load to temp position since nand_spl_load_image reads
57 * a whole block which is typically larger than
58 * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
59 * following sections like BSS
61 nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
62 CONFIG_CMD_SPL_WRITE_SIZE,
63 (void *)CONFIG_SYS_TEXT_BASE);
64 /* copy to destintion */
65 for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
66 src = (int *)CONFIG_SYS_TEXT_BASE;
67 src < (int *)(CONFIG_SYS_TEXT_BASE +
68 CONFIG_CMD_SPL_WRITE_SIZE);
70 writel(readl(src), dst);
74 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
75 sizeof(*header), (void *)header);
76 spl_parse_image_header(header);
77 if (header->ih_os == IH_OS_LINUX) {
78 /* happy - was a linux */
79 err = nand_spl_load_image(
80 CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
82 (void *)spl_image.load_addr);
86 puts("The Expected Linux image was not "
87 "found. Please check your NAND "
89 puts("Trying to start u-boot now...\n");
93 #ifdef CONFIG_NAND_ENV_DST
94 spl_nand_load_element(CONFIG_ENV_OFFSET, header);
95 #ifdef CONFIG_ENV_OFFSET_REDUND
96 spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
100 err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);