]>
Commit | Line | Data |
---|---|---|
9ea5c6ef SS |
1 | /* |
2 | * Copyright (C) 2011 | |
3 | * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
9ea5c6ef SS |
6 | */ |
7 | #include <common.h> | |
d97b4ce8 | 8 | #include <config.h> |
47f7bcae | 9 | #include <spl.h> |
df163a59 | 10 | #include <asm/io.h> |
9ea5c6ef | 11 | #include <nand.h> |
9ea5c6ef | 12 | |
0c3117b1 HS |
13 | #if defined(CONFIG_SPL_NAND_RAW_ONLY) |
14 | void spl_nand_load_image(void) | |
15 | { | |
16 | nand_init(); | |
17 | ||
18 | nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, | |
19 | CONFIG_SYS_NAND_U_BOOT_SIZE, | |
20 | (void *)CONFIG_SYS_NAND_U_BOOT_DST); | |
21 | spl_set_header_raw_uboot(); | |
22 | nand_deselect(); | |
23 | } | |
24 | #else | |
9ea5c6ef SS |
25 | void spl_nand_load_image(void) |
26 | { | |
27 | struct image_header *header; | |
df163a59 SS |
28 | int *src __attribute__((unused)); |
29 | int *dst __attribute__((unused)); | |
30 | ||
8082fda9 | 31 | debug("spl: nand - using hw ecc\n"); |
8082fda9 | 32 | nand_init(); |
9ea5c6ef SS |
33 | |
34 | /*use CONFIG_SYS_TEXT_BASE as temporary storage area */ | |
35 | header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); | |
df163a59 | 36 | #ifdef CONFIG_SPL_OS_BOOT |
379c19ab | 37 | if (!spl_start_uboot()) { |
df163a59 SS |
38 | /* |
39 | * load parameter image | |
40 | * load to temp position since nand_spl_load_image reads | |
41 | * a whole block which is typically larger than | |
b6e95fd4 | 42 | * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite |
df163a59 SS |
43 | * following sections like BSS |
44 | */ | |
45 | nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, | |
46 | CONFIG_CMD_SPL_WRITE_SIZE, | |
47 | (void *)CONFIG_SYS_TEXT_BASE); | |
48 | /* copy to destintion */ | |
49 | for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR, | |
50 | src = (int *)CONFIG_SYS_TEXT_BASE; | |
51 | src < (int *)(CONFIG_SYS_TEXT_BASE + | |
52 | CONFIG_CMD_SPL_WRITE_SIZE); | |
53 | src++, dst++) { | |
54 | writel(readl(src), dst); | |
55 | } | |
9ea5c6ef | 56 | |
df163a59 SS |
57 | /* load linux */ |
58 | nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, | |
c13bb167 | 59 | sizeof(*header), (void *)header); |
df163a59 | 60 | spl_parse_image_header(header); |
379c19ab SS |
61 | if (header->ih_os == IH_OS_LINUX) { |
62 | /* happy - was a linux */ | |
63 | nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS, | |
64 | spl_image.size, (void *)spl_image.load_addr); | |
65 | nand_deselect(); | |
66 | return; | |
67 | } else { | |
d97b4ce8 TR |
68 | puts("The Expected Linux image was not " |
69 | "found. Please check your NAND " | |
379c19ab | 70 | "configuration.\n"); |
d97b4ce8 | 71 | puts("Trying to start u-boot now...\n"); |
379c19ab SS |
72 | } |
73 | } | |
df163a59 | 74 | #endif |
9ea5c6ef | 75 | #ifdef CONFIG_NAND_ENV_DST |
379c19ab | 76 | nand_spl_load_image(CONFIG_ENV_OFFSET, |
c13bb167 | 77 | sizeof(*header), (void *)header); |
379c19ab SS |
78 | spl_parse_image_header(header); |
79 | nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size, | |
80 | (void *)spl_image.load_addr); | |
9ea5c6ef | 81 | #ifdef CONFIG_ENV_OFFSET_REDUND |
379c19ab | 82 | nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, |
c13bb167 | 83 | sizeof(*header), (void *)header); |
379c19ab SS |
84 | spl_parse_image_header(header); |
85 | nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size, | |
86 | (void *)spl_image.load_addr); | |
9ea5c6ef SS |
87 | #endif |
88 | #endif | |
379c19ab SS |
89 | /* Load u-boot */ |
90 | nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, | |
50c8d66d | 91 | sizeof(*header), (void *)header); |
379c19ab SS |
92 | spl_parse_image_header(header); |
93 | nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS, | |
b2d5ac59 | 94 | spl_image.size, (void *)(unsigned long)spl_image.load_addr); |
9ea5c6ef SS |
95 | nand_deselect(); |
96 | } | |
0c3117b1 | 97 | #endif |