2012-08-27 10:50:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Stefan Roese <sr@denx.de>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2012-08-27 10:50:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <spl.h>
|
|
|
|
|
2015-11-08 15:11:49 +00:00
|
|
|
int spl_nor_load_image(void)
|
2012-08-27 10:50:59 +00:00
|
|
|
{
|
2016-04-28 22:44:54 +00:00
|
|
|
int ret;
|
2012-08-27 10:50:59 +00:00
|
|
|
/*
|
|
|
|
* Loading of the payload to SDRAM is done with skipping of
|
|
|
|
* the mkimage header in this SPL NOR driver
|
|
|
|
*/
|
|
|
|
spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
|
|
|
|
|
2015-01-08 10:23:35 +00:00
|
|
|
#ifdef CONFIG_SPL_OS_BOOT
|
|
|
|
if (!spl_start_uboot()) {
|
2015-02-06 08:31:36 +00:00
|
|
|
const struct image_header *header;
|
2012-08-27 10:50:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Load Linux from its location in NOR flash to its defined
|
|
|
|
* location in SDRAM
|
|
|
|
*/
|
2015-01-08 10:23:35 +00:00
|
|
|
header = (const struct image_header *)CONFIG_SYS_OS_BASE;
|
2012-08-27 10:50:59 +00:00
|
|
|
|
2015-01-08 10:23:35 +00:00
|
|
|
if (image_get_os(header) == IH_OS_LINUX) {
|
|
|
|
/* happy - was a Linux */
|
2012-08-27 10:50:59 +00:00
|
|
|
|
2016-04-28 22:44:54 +00:00
|
|
|
ret = spl_parse_image_header(header);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-01-08 10:23:35 +00:00
|
|
|
|
|
|
|
memcpy((void *)spl_image.load_addr,
|
|
|
|
(void *)(CONFIG_SYS_OS_BASE +
|
|
|
|
sizeof(struct image_header)),
|
|
|
|
spl_image.size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy DT blob (fdt) to SDRAM. Passing pointer to
|
|
|
|
* flash doesn't work (16 KiB should be enough for DT)
|
|
|
|
*/
|
|
|
|
memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
|
|
|
|
(void *)(CONFIG_SYS_FDT_BASE),
|
|
|
|
(16 << 10));
|
|
|
|
|
2015-11-08 15:11:49 +00:00
|
|
|
return 0;
|
2015-01-08 10:23:35 +00:00
|
|
|
} else {
|
|
|
|
puts("The Expected Linux image was not found.\n"
|
|
|
|
"Please check your NOR configuration.\n"
|
|
|
|
"Trying to start u-boot now...\n");
|
|
|
|
}
|
2012-08-27 10:50:59 +00:00
|
|
|
}
|
2015-01-08 10:23:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load real U-Boot from its location in NOR flash to its
|
|
|
|
* defined location in SDRAM
|
|
|
|
*/
|
2016-04-28 22:44:54 +00:00
|
|
|
ret = spl_parse_image_header(
|
2015-01-08 10:23:35 +00:00
|
|
|
(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
|
2016-04-28 22:44:54 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-01-08 10:23:35 +00:00
|
|
|
|
2016-02-29 11:50:34 +00:00
|
|
|
memcpy((void *)(unsigned long)spl_image.load_addr,
|
2015-01-08 10:23:35 +00:00
|
|
|
(void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
|
|
|
|
spl_image.size);
|
2015-11-08 15:11:49 +00:00
|
|
|
|
|
|
|
return 0;
|
2012-08-27 10:50:59 +00:00
|
|
|
}
|