[v3 07/16] mmc: dwmmc: socfpga: Add ATF support for MMC driver

Tan, Ley Foon ley.foon.tan at intel.com
Thu Nov 12 11:27:54 CET 2020



> -----Original Message-----
> From: Lim, Elly Siew Chin <elly.siew.chin.lim at intel.com>
> Sent: Thursday, October 15, 2020 8:30 PM
> To: u-boot at lists.denx.de
> Cc: Marek Vasut <marex at denx.de>; Tan, Ley Foon
> <ley.foon.tan at intel.com>; See, Chin Liang <chin.liang.see at intel.com>;
> Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>; Chee, Tien Fong
> <tien.fong.chee at intel.com>; Westergreen, Dalon
> <dalon.westergreen at intel.com>; Simon Glass <sjg at chromium.org>; Ang,
> Chee Hong <chee.hong.ang at intel.com>; Lim, Elly Siew Chin
> <elly.siew.chin.lim at intel.com>
> Subject: [v3 07/16] mmc: dwmmc: socfpga: Add ATF support for MMC driver
> 
> From: Chee Hong Ang <chee.hong.ang at intel.com>
> 
> In non-secure mode (EL2), MMC driver calls the SMC/PSCI services provided
> by ATF to set SDMMC's DRVSEL and SMPLSEL.
> 
> Signed-off-by: Chee Hong Ang <chee.hong.ang at intel.com>
> Signed-off-by: Siew Chin Lim <elly.siew.chin.lim at intel.com>
> ---
>  drivers/mmc/socfpga_dw_mmc.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/mmc/socfpga_dw_mmc.c
> b/drivers/mmc/socfpga_dw_mmc.c index 0022f943bd..e5f68fa7fb 100644
> --- a/drivers/mmc/socfpga_dw_mmc.c
> +++ b/drivers/mmc/socfpga_dw_mmc.c
> @@ -6,6 +6,7 @@
>  #include <common.h>
>  #include <log.h>
>  #include <asm/arch/clock_manager.h>
> +#include <asm/arch/smc_api.h>
>  #include <asm/arch/system_manager.h>
>  #include <clk.h>
>  #include <dm.h>
> @@ -13,6 +14,7 @@
>  #include <errno.h>
>  #include <fdtdec.h>
>  #include <dm/device_compat.h>
> +#include <linux/intel-smc.h>
>  #include <linux/libfdt.h>
>  #include <linux/err.h>
>  #include <malloc.h>
> @@ -48,6 +50,10 @@ static void socfpga_dwmci_reset(struct udevice *dev)
> 
>  static void socfpga_dwmci_clksel(struct dwmci_host *host)  {
> +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ATF)
> +	u64 args[2];
> +#endif
> +
>  	struct dwmci_socfpga_priv_data *priv = host->priv;
>  	u32 sdmmc_mask = ((priv->smplsel & 0x7) <<
> SYSMGR_SDMMC_SMPLSEL_SHIFT) |
>  			 ((priv->drvsel & 0x7) <<
> SYSMGR_SDMMC_DRVSEL_SHIFT); @@ -58,10 +64,21 @@ static void
> socfpga_dwmci_clksel(struct dwmci_host *host)
> 
>  	debug("%s: drvsel %d smplsel %d\n", __func__,
>  	      priv->drvsel, priv->smplsel);
> +
> +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ATF)
> +	/* drvsel */
> +	args[0] = (sdmmc_mask >> SYSMGR_SDMMC_DRVSEL_SHIFT) & 0x7;
> +	/* smplsel */
> +	args[1] = (sdmmc_mask >> SYSMGR_SDMMC_SMPLSEL_SHIFT) & 0x7;
> +	if (invoke_smc(INTEL_SIP_SMC_HPS_SET_SDMMC_CCLK, args, 2,
> NULL, 0))
> +		dev_err(host->mmc->dev, "SMC call failed in %s\n",
> __func__);
> +
> +#else
>  	writel(sdmmc_mask, socfpga_get_sysmgr_addr() +
> SYSMGR_SDMMC);
> 
>  	debug("%s: SYSMGR_SDMMCGRP_CTRL_REG = 0x%x\n", __func__,
>  		readl(socfpga_get_sysmgr_addr() + SYSMGR_SDMMC));
> +#endif
Can move these code to new function, easier to read.

Regards
Ley Foon



More information about the U-Boot mailing list