1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2011
4  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5  */
6 
7 #include <common.h>
8 #include <nand.h>
9 
10 /*
11  * The main entry for NAND booting. It's necessary that SDRAM is already
12  * configured and available since this code loads the main U-Boot image
13  * from NAND into SDRAM and starts it from there.
14  */
nand_boot(void)15 void nand_boot(void)
16 {
17 	__attribute__((noreturn)) void (*uboot)(void);
18 
19 	/*
20 	 * Load U-Boot image from NAND into RAM
21 	 */
22 	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
23 			CONFIG_SYS_NAND_U_BOOT_SIZE,
24 			(void *)CONFIG_SYS_NAND_U_BOOT_DST);
25 
26 #ifdef CONFIG_NAND_ENV_DST
27 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
28 			(void *)CONFIG_NAND_ENV_DST);
29 
30 #ifdef CONFIG_ENV_OFFSET_REDUND
31 	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE,
32 			(void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE);
33 #endif
34 #endif
35 
36 	/*
37 	 * Jump to U-Boot image
38 	 */
39 	uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START;
40 	(*uboot)();
41 }
42