Commit 1eaa742d85a59ed3602a78445adf903f26d9b594
Committed by
York Sun
1 parent
e278ddcd7f
Exists in
v2017.01-smarct4x
and in
40 other branches
driver: Add support of image load for MMC & SPI in SPL
Add support of loading image, binary for MMC and SPI during SPL boot. Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com> Reviewed-by: York Sun <yorksun@freescale.com>
Showing 4 changed files with 42 additions and 0 deletions Side-by-side Diff
drivers/mmc/fsl_esdhc_spl.c
... | ... | @@ -19,6 +19,32 @@ |
19 | 19 | #define MBRDBR_BOOT_SIG_AA 0x1ff |
20 | 20 | #define CONFIG_CFG_DATA_SECTOR 0 |
21 | 21 | |
22 | + | |
23 | +void mmc_spl_load_image(uint32_t offs, unsigned int size, void *vdst) | |
24 | +{ | |
25 | + uint blk_start, blk_cnt, err; | |
26 | + | |
27 | + struct mmc *mmc = find_mmc_device(0); | |
28 | + if (!mmc) { | |
29 | + puts("spl: mmc device not found!!\n"); | |
30 | + hang(); | |
31 | + } | |
32 | + | |
33 | + if (mmc_init(mmc)) { | |
34 | + puts("MMC init failed\n"); | |
35 | + return; | |
36 | + } | |
37 | + | |
38 | + blk_start = ALIGN(offs, mmc->read_bl_len) / mmc->read_bl_len; | |
39 | + blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len; | |
40 | + | |
41 | + err = mmc->block_dev.block_read(0, blk_start, blk_cnt, vdst); | |
42 | + if (err != blk_cnt) { | |
43 | + puts("spl: mmc read failed!!\n"); | |
44 | + hang(); | |
45 | + } | |
46 | +} | |
47 | + | |
22 | 48 | /* |
23 | 49 | * The main entry for mmc booting. It's necessary that SDRAM is already |
24 | 50 | * configured and available since this code loads the main U-Boot image |
drivers/mtd/spi/fsl_espi_spl.c
... | ... | @@ -12,6 +12,20 @@ |
12 | 12 | #define ESPI_BOOT_IMAGE_ADDR 0x50 |
13 | 13 | #define CONFIG_CFG_DATA_SECTOR 0 |
14 | 14 | |
15 | +void spi_spl_load_image(uint32_t offs, unsigned int size, void *vdst) | |
16 | +{ | |
17 | + struct spi_flash *flash; | |
18 | + | |
19 | + flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, | |
20 | + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); | |
21 | + if (flash == NULL) { | |
22 | + puts("\nspi_flash_probe failed"); | |
23 | + hang(); | |
24 | + } | |
25 | + | |
26 | + spi_flash_read(flash, offs, size, vdst); | |
27 | +} | |
28 | + | |
15 | 29 | /* |
16 | 30 | * The main entry for SPI booting. It's necessary that SDRAM is already |
17 | 31 | * configured and available since this code loads the main U-Boot image |
include/fsl_esdhc.h