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)
20 ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
21 CONFIG_SYS_NAND_U_BOOT_SIZE,
22 (void *)CONFIG_SYS_NAND_U_BOOT_DST);
27 spl_set_header_raw_uboot();
31 int spl_nand_load_image(void)
34 struct image_header *header;
35 int *src __attribute__((unused));
36 int *dst __attribute__((unused));
38 debug("spl: nand - using hw ecc\n");
41 /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
42 header = (struct image_header *)CONFIG_SYS_TEXT_BASE;
43 #ifdef CONFIG_SPL_OS_BOOT
44 if (!spl_start_uboot()) {
46 * load parameter image
47 * load to temp position since nand_spl_load_image reads
48 * a whole block which is typically larger than
49 * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
50 * following sections like BSS
52 nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
53 CONFIG_CMD_SPL_WRITE_SIZE,
54 (void *)CONFIG_SYS_TEXT_BASE);
55 /* copy to destintion */
56 for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
57 src = (int *)CONFIG_SYS_TEXT_BASE;
58 src < (int *)(CONFIG_SYS_TEXT_BASE +
59 CONFIG_CMD_SPL_WRITE_SIZE);
61 writel(readl(src), dst);
65 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
66 sizeof(*header), (void *)header);
67 spl_parse_image_header(header);
68 if (header->ih_os == IH_OS_LINUX) {
69 /* happy - was a linux */
70 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
71 spl_image.size, (void *)spl_image.load_addr);
75 printf("The Expected Linux image was not"
76 "found. Please check your NAND"
78 printf("Trying to start u-boot now...\n");
82 #ifdef CONFIG_NAND_ENV_DST
83 nand_spl_load_image(CONFIG_ENV_OFFSET,
84 sizeof(*header), (void *)header);
85 spl_parse_image_header(header);
86 nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
87 (void *)spl_image.load_addr);
88 #ifdef CONFIG_ENV_OFFSET_REDUND
89 nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
90 sizeof(*header), (void *)header);
91 spl_parse_image_header(header);
92 nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
93 (void *)spl_image.load_addr);
97 ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
98 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
100 spl_parse_image_header(header);
101 ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
102 spl_image.size, (void *)spl_image.load_addr);