Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Stefan Roese <sr@denx.de> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 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 | |
Masahiro Yamada | 225581b | 2015-01-08 19:23:35 +0900 | [diff] [blame] | 18 | #ifdef CONFIG_SPL_OS_BOOT |
| 19 | if (!spl_start_uboot()) { |
Heiko Schocher | 329b72a | 2015-02-06 09:31:36 +0100 | [diff] [blame] | 20 | const struct image_header *header; |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 21 | |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 22 | /* |
| 23 | * Load Linux from its location in NOR flash to its defined |
| 24 | * location in SDRAM |
| 25 | */ |
Masahiro Yamada | 225581b | 2015-01-08 19:23:35 +0900 | [diff] [blame] | 26 | header = (const struct image_header *)CONFIG_SYS_OS_BASE; |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 27 | |
Masahiro Yamada | 225581b | 2015-01-08 19:23:35 +0900 | [diff] [blame] | 28 | if (image_get_os(header) == IH_OS_LINUX) { |
| 29 | /* happy - was a Linux */ |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 30 | |
Masahiro Yamada | 225581b | 2015-01-08 19:23:35 +0900 | [diff] [blame] | 31 | spl_parse_image_header(header); |
| 32 | |
| 33 | memcpy((void *)spl_image.load_addr, |
| 34 | (void *)(CONFIG_SYS_OS_BASE + |
| 35 | sizeof(struct image_header)), |
| 36 | spl_image.size); |
| 37 | |
| 38 | /* |
| 39 | * Copy DT blob (fdt) to SDRAM. Passing pointer to |
| 40 | * flash doesn't work (16 KiB should be enough for DT) |
| 41 | */ |
| 42 | memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR, |
| 43 | (void *)(CONFIG_SYS_FDT_BASE), |
| 44 | (16 << 10)); |
| 45 | |
| 46 | return; |
| 47 | } else { |
| 48 | puts("The Expected Linux image was not found.\n" |
| 49 | "Please check your NOR configuration.\n" |
| 50 | "Trying to start u-boot now...\n"); |
| 51 | } |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 52 | } |
Masahiro Yamada | 225581b | 2015-01-08 19:23:35 +0900 | [diff] [blame] | 53 | #endif |
| 54 | |
| 55 | /* |
| 56 | * Load real U-Boot from its location in NOR flash to its |
| 57 | * defined location in SDRAM |
| 58 | */ |
| 59 | spl_parse_image_header( |
| 60 | (const struct image_header *)CONFIG_SYS_UBOOT_BASE); |
| 61 | |
| 62 | memcpy((void *)spl_image.load_addr, |
| 63 | (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)), |
| 64 | spl_image.size); |
Stefan Roese | 900c177 | 2012-08-27 12:50:59 +0200 | [diff] [blame] | 65 | } |