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