xref: /openbmc/u-boot/common/spl/spl_nor.c (revision 9d86f0c3)
1 /*
2  * Copyright (C) 2012 Stefan Roese <sr@denx.de>
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
15  * GNU General Public License for more details.
16  */
17 
18 #include <common.h>
19 #include <spl.h>
20 
21 void spl_nor_load_image(void)
22 {
23 	/*
24 	 * Loading of the payload to SDRAM is done with skipping of
25 	 * the mkimage header in this SPL NOR driver
26 	 */
27 	spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
28 
29 	if (spl_start_uboot()) {
30 		/*
31 		 * Load real U-Boot from its location in NOR flash to its
32 		 * defined location in SDRAM
33 		 */
34 		spl_parse_image_header(
35 			(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
36 
37 		memcpy((void *)spl_image.load_addr,
38 		       (void *)(CONFIG_SYS_UBOOT_BASE +
39 				sizeof(struct image_header)),
40 		       spl_image.size);
41 	} else {
42 		/*
43 		 * Load Linux from its location in NOR flash to its defined
44 		 * location in SDRAM
45 		 */
46 		spl_parse_image_header(
47 			(const struct image_header *)CONFIG_SYS_OS_BASE);
48 
49 		memcpy((void *)spl_image.load_addr,
50 		       (void *)(CONFIG_SYS_OS_BASE +
51 				sizeof(struct image_header)),
52 		       spl_image.size);
53 
54 		/*
55 		 * Copy DT blob (fdt) to SDRAM. Passing pointer to flash
56 		 * doesn't work (16 KiB should be enough for DT)
57 		 */
58 		memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
59 		       (void *)(CONFIG_SYS_FDT_BASE),
60 		       (16 << 10));
61 	}
62 }
63