Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2011 |
| 4 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 7 | #include <common.h> |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 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 | */ |
| 15 | void nand_boot(void) |
| 16 | { |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 17 | __attribute__((noreturn)) void (*uboot)(void); |
| 18 | |
| 19 | /* |
| 20 | * Load U-Boot image from NAND into RAM |
| 21 | */ |
Anatolij Gustschin | 8eb4d98 | 2011-12-03 06:46:09 +0000 | [diff] [blame] | 22 | nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 23 | CFG_SYS_NAND_U_BOOT_SIZE, |
| 24 | (void *)CFG_SYS_NAND_U_BOOT_DST); |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 25 | |
| 26 | #ifdef CONFIG_NAND_ENV_DST |
Anatolij Gustschin | 8eb4d98 | 2011-12-03 06:46:09 +0000 | [diff] [blame] | 27 | nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, |
| 28 | (void *)CONFIG_NAND_ENV_DST); |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 29 | |
| 30 | #ifdef CONFIG_ENV_OFFSET_REDUND |
Anatolij Gustschin | 8eb4d98 | 2011-12-03 06:46:09 +0000 | [diff] [blame] | 31 | nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, |
| 32 | (void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 33 | #endif |
| 34 | #endif |
| 35 | |
| 36 | /* |
| 37 | * Jump to U-Boot image |
| 38 | */ |
Tom Rini | b421349 | 2022-11-12 17:36:51 -0500 | [diff] [blame] | 39 | uboot = (void *)CFG_SYS_NAND_U_BOOT_START; |
Heiko Schocher | 565a09c | 2011-11-01 20:00:29 +0000 | [diff] [blame] | 40 | (*uboot)(); |
| 41 | } |