3 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
5 * SPDX-License-Identifier: GPL-2.0+
13 void spl_nand_load_image(void)
15 struct image_header *header;
16 int *src __attribute__((unused));
17 int *dst __attribute__((unused));
19 debug("spl: nand - using hw ecc\n");
22 /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
23 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
24 #ifdef CONFIG_SPL_OS_BOOT
25 if (!spl_start_uboot()) {
27 * load parameter image
28 * load to temp position since nand_spl_load_image reads
29 * a whole block which is typically larger than
30 * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
31 * following sections like BSS
33 nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
34 CONFIG_CMD_SPL_WRITE_SIZE,
35 (void *)CONFIG_SYS_TEXT_BASE);
36 /* copy to destintion */
37 for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
38 src = (int *)CONFIG_SYS_TEXT_BASE;
39 src < (int *)(CONFIG_SYS_TEXT_BASE +
40 CONFIG_CMD_SPL_WRITE_SIZE);
42 writel(readl(src), dst);
46 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
47 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
48 spl_parse_image_header(header);
49 if (header->ih_os == IH_OS_LINUX) {
50 /* happy - was a linux */
51 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
52 spl_image.size, (void *)spl_image.load_addr);
56 puts("The Expected Linux image was not "
57 "found. Please check your NAND "
59 puts("Trying to start u-boot now...\n");
63 #ifdef CONFIG_NAND_ENV_DST
64 nand_spl_load_image(CONFIG_ENV_OFFSET,
65 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
66 spl_parse_image_header(header);
67 nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
68 (void *)spl_image.load_addr);
69 #ifdef CONFIG_ENV_OFFSET_REDUND
70 nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
71 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
72 spl_parse_image_header(header);
73 nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
74 (void *)spl_image.load_addr);
78 nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
79 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
80 spl_parse_image_header(header);
81 nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
82 spl_image.size, (void *)spl_image.load_addr);