xref: /openbmc/u-boot/common/spl/spl_nor.c (revision 3765b3e7)
1 /*
2  * Copyright (C) 2012 Stefan Roese <sr@denx.de>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <spl.h>
9 
10 void spl_nor_load_image(void)
11 {
12 	/*
13 	 * Loading of the payload to SDRAM is done with skipping of
14 	 * the mkimage header in this SPL NOR driver
15 	 */
16 	spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
17 
18 	if (spl_start_uboot()) {
19 		/*
20 		 * Load real U-Boot from its location in NOR flash to its
21 		 * defined location in SDRAM
22 		 */
23 		spl_parse_image_header(
24 			(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
25 
26 		memcpy((void *)spl_image.load_addr,
27 		       (void *)(CONFIG_SYS_UBOOT_BASE +
28 				sizeof(struct image_header)),
29 		       spl_image.size);
30 	} else {
31 		/*
32 		 * Load Linux from its location in NOR flash to its defined
33 		 * location in SDRAM
34 		 */
35 		spl_parse_image_header(
36 			(const struct image_header *)CONFIG_SYS_OS_BASE);
37 
38 		memcpy((void *)spl_image.load_addr,
39 		       (void *)(CONFIG_SYS_OS_BASE +
40 				sizeof(struct image_header)),
41 		       spl_image.size);
42 
43 		/*
44 		 * Copy DT blob (fdt) to SDRAM. Passing pointer to flash
45 		 * doesn't work (16 KiB should be enough for DT)
46 		 */
47 		memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
48 		       (void *)(CONFIG_SYS_FDT_BASE),
49 		       (16 << 10));
50 	}
51 }
52