Christian Riesch | 23f16a8 | 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 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
| 26 | #include <spi_flash.h> |
Tom Rini | 1e2abf9 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 27 | #include <spl.h> |
Christian Riesch | 23f16a8 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 28 | |
| 29 | /* |
| 30 | * The main entry for SPI booting. It's necessary that SDRAM is already |
| 31 | * configured and available since this code loads the main U-Boot image |
| 32 | * from SPI into SDRAM and starts it from there. |
| 33 | */ |
Tom Rini | 1e2abf9 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 34 | void spl_spi_load_image(void) |
Christian Riesch | 23f16a8 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 35 | { |
| 36 | struct spi_flash *flash; |
Tom Rini | 1e2abf9 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 37 | struct image_header *header; |
Christian Riesch | 23f16a8 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * Load U-Boot image from SPI flash into RAM |
| 41 | */ |
| 42 | |
| 43 | flash = spi_flash_probe(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS, |
| 44 | CONFIG_SF_DEFAULT_SPEED, SPI_MODE_3); |
| 45 | if (!flash) { |
Tom Rini | 1e2abf9 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 46 | puts("SPI probe failed.\n"); |
Christian Riesch | 23f16a8 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 47 | hang(); |
| 48 | } |
| 49 | |
Tom Rini | 1e2abf9 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 50 | /* use CONFIG_SYS_TEXT_BASE as temporary storage area */ |
| 51 | header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); |
Christian Riesch | 23f16a8 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 52 | |
Tom Rini | 1e2abf9 | 2012-08-14 14:34:10 -0700 | [diff] [blame] | 53 | /* Load u-boot, mkimage header is 64 bytes. */ |
| 54 | spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40, |
| 55 | (void *) header); |
| 56 | spl_parse_image_header(header); |
| 57 | spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, |
| 58 | spl_image.size, (void *)spl_image.load_addr); |
Christian Riesch | 23f16a8 | 2011-12-09 09:47:35 +0000 | [diff] [blame] | 59 | } |