Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 OMICRON electronics GmbH |
| 3 | * |
| 4 | * based on drivers/mtd/nand/nand_spl_load.c |
| 5 | * |
| 6 | * Copyright (C) 2011 |
| 7 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
| 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <spi_flash.h> |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 14 | #include <spl.h> |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 15 | |
| 16 | /* |
| 17 | * The main entry for SPI booting. It's necessary that SDRAM is already |
| 18 | * configured and available since this code loads the main U-Boot image |
| 19 | * from SPI into SDRAM and starts it from there. |
| 20 | */ |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 21 | void spl_spi_load_image(void) |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 22 | { |
| 23 | struct spi_flash *flash; |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 24 | struct image_header *header; |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * Load U-Boot image from SPI flash into RAM |
| 28 | */ |
| 29 | |
| 30 | flash = spi_flash_probe(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS, |
| 31 | CONFIG_SF_DEFAULT_SPEED, SPI_MODE_3); |
| 32 | if (!flash) { |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 33 | puts("SPI probe failed.\n"); |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 34 | hang(); |
| 35 | } |
| 36 | |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 37 | /* use CONFIG_SYS_TEXT_BASE as temporary storage area */ |
| 38 | header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 39 | |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 40 | /* Load u-boot, mkimage header is 64 bytes. */ |
| 41 | spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40, |
Jagannadha Sutradharudu Teki | 5928b9a | 2013-07-29 22:43:57 +0530 | [diff] [blame] | 42 | (void *)header); |
Tom Rini | a4cc1c4 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 43 | spl_parse_image_header(header); |
| 44 | spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, |
| 45 | spl_image.size, (void *)spl_image.load_addr); |
Christian Riesch | 32b1127 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 46 | } |