2 * Copyright (C) 2011 OMICRON electronics GmbH
4 * based on drivers/mtd/nand/nand_spl_load.c
7 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
9 * SPDX-License-Identifier: GPL-2.0+
13 #include <spi_flash.h>
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.
21 void spl_spi_load_image(void)
23 struct spi_flash *flash;
24 struct image_header *header;
27 * Load U-Boot image from SPI flash into RAM
30 flash = spi_flash_probe(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS,
31 CONFIG_SF_DEFAULT_SPEED, SPI_MODE_3);
33 puts("SPI probe failed.\n");
37 /* use CONFIG_SYS_TEXT_BASE as temporary storage area */
38 header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
40 /* Load u-boot, mkimage header is 64 bytes. */
41 spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
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);