]>
Commit | Line | Data |
---|---|---|
33d34646 SR |
1 | /* |
2 | * Copyright (C) 2012 Stefan Roese <sr@denx.de> | |
3 | * | |
1a459660 | 4 | * SPDX-License-Identifier: GPL-2.0+ |
33d34646 SR |
5 | */ |
6 | ||
7 | #include <common.h> | |
8 | #include <spl.h> | |
9 | ||
2a2ee2ac SG |
10 | static int spl_nor_load_image(struct spl_image_info *spl_image, |
11 | struct spl_boot_device *bootdev) | |
33d34646 | 12 | { |
7e0f2267 | 13 | int ret; |
33d34646 SR |
14 | /* |
15 | * Loading of the payload to SDRAM is done with skipping of | |
16 | * the mkimage header in this SPL NOR driver | |
17 | */ | |
2a2ee2ac | 18 | spl_image->flags |= SPL_COPY_PAYLOAD_ONLY; |
33d34646 | 19 | |
9f9d8704 MY |
20 | #ifdef CONFIG_SPL_OS_BOOT |
21 | if (!spl_start_uboot()) { | |
b9ea0c3a | 22 | const struct image_header *header; |
33d34646 | 23 | |
33d34646 SR |
24 | /* |
25 | * Load Linux from its location in NOR flash to its defined | |
26 | * location in SDRAM | |
27 | */ | |
9f9d8704 | 28 | header = (const struct image_header *)CONFIG_SYS_OS_BASE; |
33d34646 | 29 | |
9f9d8704 MY |
30 | if (image_get_os(header) == IH_OS_LINUX) { |
31 | /* happy - was a Linux */ | |
33d34646 | 32 | |
2a2ee2ac | 33 | ret = spl_parse_image_header(spl_image, header); |
7e0f2267 MV |
34 | if (ret) |
35 | return ret; | |
9f9d8704 | 36 | |
2a2ee2ac | 37 | memcpy((void *)spl_image->load_addr, |
9f9d8704 MY |
38 | (void *)(CONFIG_SYS_OS_BASE + |
39 | sizeof(struct image_header)), | |
2a2ee2ac | 40 | spl_image->size); |
9f9d8704 | 41 | |
5bf5250e | 42 | spl_image->arg = (void *)CONFIG_SYS_FDT_BASE; |
9f9d8704 | 43 | |
36afd451 | 44 | return 0; |
9f9d8704 MY |
45 | } else { |
46 | puts("The Expected Linux image was not found.\n" | |
47 | "Please check your NOR configuration.\n" | |
48 | "Trying to start u-boot now...\n"); | |
49 | } | |
33d34646 | 50 | } |
9f9d8704 MY |
51 | #endif |
52 | ||
53 | /* | |
54 | * Load real U-Boot from its location in NOR flash to its | |
55 | * defined location in SDRAM | |
56 | */ | |
2a2ee2ac | 57 | ret = spl_parse_image_header(spl_image, |
9f9d8704 | 58 | (const struct image_header *)CONFIG_SYS_UBOOT_BASE); |
7e0f2267 MV |
59 | if (ret) |
60 | return ret; | |
9f9d8704 | 61 | |
2a2ee2ac | 62 | memcpy((void *)(unsigned long)spl_image->load_addr, |
9f9d8704 | 63 | (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)), |
2a2ee2ac | 64 | spl_image->size); |
36afd451 NK |
65 | |
66 | return 0; | |
33d34646 | 67 | } |
ebc4ef61 | 68 | SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image); |