From 5aa03ddd7ff67dce143a5ea5dbaa85e6aaaab23f Mon Sep 17 00:00:00 2001 From: Zhao Qiang Date: Thu, 25 May 2017 09:47:40 +0800 Subject: QE: add QE support on SD boot modify u_qe_init to upload QE firmware from SD card when it is SD boot Signed-off-by: Zhao Qiang Reviewed-by: York Sun --- drivers/qe/qe.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'drivers/qe/qe.c') diff --git a/drivers/qe/qe.c b/drivers/qe/qe.c index 4f0a27892f..24e764dc7c 100644 --- a/drivers/qe/qe.c +++ b/drivers/qe/qe.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -17,6 +18,10 @@ #include #endif +#ifdef CONFIG_SYS_QE_FMAN_FW_IN_MMC +#include +#endif + #define MPC85xx_DEVDISR_QE_DISABLE 0x1 qe_map_t *qe_immr = NULL; @@ -194,8 +199,37 @@ void u_qe_init(void) { qe_immr = (qe_map_t *)(CONFIG_SYS_IMMR + QE_IMMR_OFFSET); - u_qe_upload_firmware((const void *)CONFIG_SYS_QE_FW_ADDR); + void *addr = (void *)CONFIG_SYS_QE_FW_ADDR; +#ifdef CONFIG_SYS_QE_FMAN_FW_IN_MMC + int dev = CONFIG_SYS_MMC_ENV_DEV; + u32 cnt = CONFIG_SYS_QE_FMAN_FW_LENGTH / 512; + u32 blk = CONFIG_SYS_QE_FW_ADDR / 512; + + if (mmc_initialize(gd->bd)) { + printf("%s: mmc_initialize() failed\n", __func__); + return; + } + addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH); + struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); + + if (!mmc) { + free(addr); + printf("\nMMC cannot find device for ucode\n"); + } else { + printf("\nMMC read: dev # %u, block # %u, count %u ...\n", + dev, blk, cnt); + mmc_init(mmc); + (void)mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, + addr); + /* flush cache after read */ + flush_cache((ulong)addr, cnt * 512); + } +#endif + u_qe_upload_firmware(addr); out_be32(&qe_immr->iram.iready, QE_IRAM_READY); +#ifdef CONFIG_SYS_QE_FMAN_FW_IN_MMC + free(addr); +#endif } #endif -- cgit