[U-Boot] [PATCH] QE: add QE support on SD boot

York Sun york.sun at nxp.com
Wed Apr 19 15:56:54 UTC 2017


On 04/13/2017 06:17 PM, Zhao Qiang wrote:
> modify u_qe_init to upload QE firmware from SD card when it is SD
> boot
>
> Signed-off-by: Zhao Qiang <qiang.zhao at nxp.com>
> ---
>  drivers/qe/qe.c                  | 34 +++++++++++++++++++++++++++++++++-
>  include/configs/ls1043a_common.h |  4 ++++
>  include/configs/ls1043ardb.h     |  7 -------
>  3 files changed, 37 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/qe/qe.c b/drivers/qe/qe.c
> index 4231594..5f3124a 100644
> --- a/drivers/qe/qe.c
> +++ b/drivers/qe/qe.c
> @@ -8,6 +8,7 @@
>   */
>
>  #include <common.h>
> +#include <malloc.h>
>  #include <command.h>
>  #include <linux/errno.h>
>  #include <asm/io.h>
> @@ -17,6 +18,10 @@
>  #include <asm/arch/immap_ls102xa.h>
>  #endif
>
> +#ifdef CONFIG_SYS_QE_FMAN_FW_IN_MMC
> +#include <mmc.h>
> +#endif
> +
>  #define MPC85xx_DEVDISR_QE_DISABLE	0x1
>
>  qe_map_t		*qe_immr = NULL;
> @@ -194,7 +199,34 @@ 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);
> +#if defined(CONFIG_SYS_QE_FMAN_FW_IN_NOR)
> +	void *addr = (void *)CONFIG_SYS_QE_FW_ADDR;
> +#elif defined(CONFIG_SYS_QE_FMAN_FW_IN_MMC)
> +	int dev = CONFIG_SYS_MMC_ENV_DEV;
> +	void *addr = (void *)malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);

Do you really need to cast the return value? I think malloc() returns a
void *.

> +	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;
> +	}
> +	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
> +
> +	if (!mmc) {
> +		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);
>  }
>  #endif

After uploading the firmware, do you still need memory at *addr? If not, 
free it.

York


More information about the U-Boot mailing list