]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/omap-common/spl_nand.c
Remove bogus check for NAND_MODE_HW_ECC
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / omap-common / spl_nand.c
1 /*
2  * Copyright (C) 2011
3  * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 #include <common.h>
24 #include <asm/u-boot.h>
25 #include <asm/utils.h>
26 #include <asm/arch/sys_proto.h>
27 #include <asm/io.h>
28 #include <nand.h>
29 #include <version.h>
30 #include <asm/omap_common.h>
31
32 void spl_nand_load_image(void)
33 {
34         struct image_header *header;
35         int *src __attribute__((unused));
36         int *dst __attribute__((unused));
37
38         debug("spl: nand - using hw ecc\n");
39         gpmc_init();
40         nand_init();
41
42         /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
43         header = (struct image_header *)CONFIG_SYS_TEXT_BASE;
44 #ifdef CONFIG_SPL_OS_BOOT
45         if (!spl_start_uboot()) {
46                 /*
47                  * load parameter image
48                  * load to temp position since nand_spl_load_image reads
49                  * a whole block which is typically larger than
50                  * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
51                  * following sections like BSS
52                  */
53                 nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
54                         CONFIG_CMD_SPL_WRITE_SIZE,
55                         (void *)CONFIG_SYS_TEXT_BASE);
56                 /* copy to destintion */
57                 for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
58                                 src = (int *)CONFIG_SYS_TEXT_BASE;
59                                 src < (int *)(CONFIG_SYS_TEXT_BASE +
60                                 CONFIG_CMD_SPL_WRITE_SIZE);
61                                 src++, dst++) {
62                         writel(readl(src), dst);
63                 }
64
65                 /* load linux */
66                 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
67                         CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
68                 spl_parse_image_header(header);
69                 if (header->ih_os == IH_OS_LINUX) {
70                         /* happy - was a linux */
71                         nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
72                                 spl_image.size, (void *)spl_image.load_addr);
73                         nand_deselect();
74                         return;
75                 } else {
76                         printf("The Expected Linux image was not"
77                                 "found. Please check your NAND"
78                                 "configuration.\n");
79                         printf("Trying to start u-boot now...\n");
80                 }
81         }
82 #endif
83 #ifdef CONFIG_NAND_ENV_DST
84         nand_spl_load_image(CONFIG_ENV_OFFSET,
85                 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
86         spl_parse_image_header(header);
87         nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
88                 (void *)spl_image.load_addr);
89 #ifdef CONFIG_ENV_OFFSET_REDUND
90         nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
91                 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
92         spl_parse_image_header(header);
93         nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
94                 (void *)spl_image.load_addr);
95 #endif
96 #endif
97         /* Load u-boot */
98         nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
99                 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
100         spl_parse_image_header(header);
101         nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
102                 spl_image.size, (void *)spl_image.load_addr);
103         nand_deselect();
104 }