2011-09-14 19:33:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011
|
|
|
|
* Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
#include <common.h>
|
2012-08-14 15:50:58 +00:00
|
|
|
#include <asm/spl.h>
|
2011-09-14 19:33:34 +00:00
|
|
|
#include <asm/u-boot.h>
|
|
|
|
#include <asm/utils.h>
|
|
|
|
#include <asm/arch/sys_proto.h>
|
2012-03-15 04:01:36 +00:00
|
|
|
#include <asm/io.h>
|
2011-09-14 19:33:34 +00:00
|
|
|
#include <nand.h>
|
Move timestamp and version files into 'generated' subdir
There is a rather subtle build problem where the build time stamp is not
updated for out-of-tree builds if there exists an in-tree build which
has a valid timestamp file. So if you do an in-tree build, then an
out-of-tree build your timestamp will not change.
The correct timestamp_autogenerated.h lives in the object tree, but it
is not always found there. The source still lives in the source tree and
when compiling version.h, it includes timestamp_autogenerated.h. Since
the current directory is always searched first, this will come from the
source tree rather than the object tree if it exists there. This affects
dependency generation also, which means that common/cmd_version.o will not
even be rebuilt if you have ever done an in-tree build.
A similar problem exists with the version file.
This change moves both files into the 'generated' subdir, which is already
used for asm-offsets.h. Then timestamp.h and version.h are updated to
include the files from there.
There are other places where these generated files are included, but I
cannot see why these don't just use the timestamp.h and version.h headers.
So this change also tidies that up.
I have tested this with in- and out-of-tree builds, but not SPL. I have
looked at various other options for fixing this, including sed on the dep
files, -I- and -include flags to gcc, but I don't think they can be made
to work. Comments welcome.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
2011-10-10 08:55:19 +00:00
|
|
|
#include <version.h>
|
2011-09-14 19:33:34 +00:00
|
|
|
|
|
|
|
void spl_nand_load_image(void)
|
|
|
|
{
|
|
|
|
struct image_header *header;
|
2012-03-15 04:01:36 +00:00
|
|
|
int *src __attribute__((unused));
|
|
|
|
int *dst __attribute__((unused));
|
|
|
|
|
2012-08-13 21:11:06 +00:00
|
|
|
debug("spl: nand - using hw ecc\n");
|
|
|
|
gpmc_init();
|
|
|
|
nand_init();
|
2011-09-14 19:33:34 +00:00
|
|
|
|
|
|
|
/*use CONFIG_SYS_TEXT_BASE as temporary storage area */
|
|
|
|
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
|
2012-03-15 04:01:36 +00:00
|
|
|
#ifdef CONFIG_SPL_OS_BOOT
|
2012-03-15 04:01:38 +00:00
|
|
|
if (!spl_start_uboot()) {
|
2012-03-15 04:01:36 +00:00
|
|
|
/*
|
|
|
|
* load parameter image
|
|
|
|
* load to temp position since nand_spl_load_image reads
|
|
|
|
* a whole block which is typically larger than
|
2012-03-31 07:47:17 +00:00
|
|
|
* CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
|
2012-03-15 04:01:36 +00:00
|
|
|
* following sections like BSS
|
|
|
|
*/
|
|
|
|
nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
|
|
|
|
CONFIG_CMD_SPL_WRITE_SIZE,
|
|
|
|
(void *)CONFIG_SYS_TEXT_BASE);
|
|
|
|
/* copy to destintion */
|
|
|
|
for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
|
|
|
|
src = (int *)CONFIG_SYS_TEXT_BASE;
|
|
|
|
src < (int *)(CONFIG_SYS_TEXT_BASE +
|
|
|
|
CONFIG_CMD_SPL_WRITE_SIZE);
|
|
|
|
src++, dst++) {
|
|
|
|
writel(readl(src), dst);
|
|
|
|
}
|
2011-09-14 19:33:34 +00:00
|
|
|
|
2012-03-15 04:01:36 +00:00
|
|
|
/* load linux */
|
|
|
|
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
|
|
|
|
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
|
|
|
|
spl_parse_image_header(header);
|
2012-03-15 04:01:38 +00:00
|
|
|
if (header->ih_os == IH_OS_LINUX) {
|
|
|
|
/* happy - was a linux */
|
|
|
|
nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
|
|
|
|
spl_image.size, (void *)spl_image.load_addr);
|
|
|
|
nand_deselect();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
printf("The Expected Linux image was not"
|
|
|
|
"found. Please check your NAND"
|
|
|
|
"configuration.\n");
|
|
|
|
printf("Trying to start u-boot now...\n");
|
|
|
|
}
|
|
|
|
}
|
2012-03-15 04:01:36 +00:00
|
|
|
#endif
|
2011-09-14 19:33:34 +00:00
|
|
|
#ifdef CONFIG_NAND_ENV_DST
|
2012-03-15 04:01:38 +00:00
|
|
|
nand_spl_load_image(CONFIG_ENV_OFFSET,
|
|
|
|
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
|
|
|
|
spl_parse_image_header(header);
|
|
|
|
nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
|
|
|
|
(void *)spl_image.load_addr);
|
2011-09-14 19:33:34 +00:00
|
|
|
#ifdef CONFIG_ENV_OFFSET_REDUND
|
2012-03-15 04:01:38 +00:00
|
|
|
nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
|
|
|
|
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
|
|
|
|
spl_parse_image_header(header);
|
|
|
|
nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
|
|
|
|
(void *)spl_image.load_addr);
|
2011-09-14 19:33:34 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2012-03-15 04:01:38 +00:00
|
|
|
/* Load u-boot */
|
|
|
|
nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
|
|
|
|
CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
|
|
|
|
spl_parse_image_header(header);
|
|
|
|
nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
|
|
|
|
spl_image.size, (void *)spl_image.load_addr);
|
2011-09-14 19:33:34 +00:00
|
|
|
nand_deselect();
|
|
|
|
}
|