]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/mtd/spi/spi_spl_load.c
Merge branch 'u-boot-ti/master' into 'u-boot-arm/master'
[people/ms/u-boot.git] / drivers / mtd / spi / spi_spl_load.c
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 * SPDX-License-Identifier: GPL-2.0+
10 */
11
12 #include <common.h>
13 #include <spi_flash.h>
14 #include <spl.h>
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 */
21 void spl_spi_load_image(void)
22 {
23 struct spi_flash *flash;
24 struct image_header *header;
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) {
33 puts("SPI probe failed.\n");
34 hang();
35 }
36
37 /* use CONFIG_SYS_TEXT_BASE as temporary storage area */
38 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
39
40 /* Load u-boot, mkimage header is 64 bytes. */
41 spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
42 (void *)header);
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);
46 }