]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mmc/fsl_esdhc_spl.c
karo: tx6ul: proper initialize second FEC if available
[karo-tx-uboot.git] / drivers / mmc / fsl_esdhc_spl.c
index 8fc263f4f40b864d8c9c8090c88896a7995a2a87..b1cb4b3534f8e68b2576d30cb5f021fde8a80133 100644 (file)
 #define MBRDBR_BOOT_SIG_AA     0x1ff
 #define CONFIG_CFG_DATA_SECTOR 0
 
+
+void mmc_spl_load_image(uint32_t offs, unsigned int size, void *vdst)
+{
+       uint blk_start, blk_cnt, err;
+
+       struct mmc *mmc = find_mmc_device(0);
+       if (!mmc) {
+               puts("spl: mmc device not found!!\n");
+               hang();
+       }
+
+       if (mmc_init(mmc)) {
+               puts("MMC init failed\n");
+               return;
+       }
+
+       blk_start = ALIGN(offs, mmc->read_bl_len) / mmc->read_bl_len;
+       blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
+
+       err = mmc->block_dev.block_read(0, blk_start, blk_cnt, vdst);
+       if (err != blk_cnt) {
+               puts("spl: mmc read failed!!\n");
+               hang();
+       }
+}
+
 /*
  * The main entry for mmc booting. It's necessary that SDRAM is already
  * configured and available since this code loads the main U-Boot image
@@ -29,10 +55,12 @@ void __noreturn mmc_boot(void)
 {
        __attribute__((noreturn)) void (*uboot)(void);
        uint blk_start, blk_cnt, err;
-       u32 blklen;
+#ifndef CONFIG_FSL_CORENET
        uchar *tmp_buf;
+       u32 blklen;
        uchar val;
        uint i, byte_num;
+#endif
        u32 offset, code_len;
        struct mmc *mmc;
 
@@ -102,7 +130,9 @@ void __noreturn mmc_boot(void)
                                        (uchar *)CONFIG_SYS_MMC_U_BOOT_DST);
        if (err != blk_cnt) {
                puts("spl: mmc read failed!!\n");
+#ifndef CONFIG_FSL_CORENET
                free(tmp_buf);
+#endif
                hang();
        }