[U-Boot] [PATCH 3/3] mmc: fsl_esdhc: clarify i.MX eSDHC specific functions

Peng Fan peng.fan at nxp.com
Thu Feb 14 09:17:05 UTC 2019



> -----Original Message-----
> From: Y.b. Lu
> Sent: 2019年2月14日 16:21
> To: u-boot at lists.denx.de
> Cc: Jaehoon Chung <jh80.chung at samsung.com>; Prabhakar Kushwaha
> <prabhakar.kushwaha at nxp.com>; Peng Fan <peng.fan at nxp.com>; Y.b. Lu
> <yangbo.lu at nxp.com>
> Subject: [PATCH 3/3] mmc: fsl_esdhc: clarify i.MX eSDHC specific functions
> 
> A previous patch had added SDR104/HS200 support for fsl_esdhc.
> However this was only for i.MX eSDHC, and QorIQ eSDHC used different
> registers and method.
> 
> This patch is to clarify i.MX eSDHC specific functions defined in that patch, and
> to use them only for i.MX eSDHC. The QorIQ eSDHC SDR104/HS200 support
> will be added in the future.
> 
> Fixes: 51313b49f2b8 (mmc: fsl_esdhc: support SDR104 and HS200)
> Signed-off-by: Yangbo Lu <yangbo.lu at nxp.com>


Reviewed-by: Peng Fan <peng.fan at nxp.com>

> ---
>  drivers/mmc/fsl_esdhc.c | 79 +++++++++++++++++++++--------------------
>  1 file changed, 41 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index
> 63f922382f..44c040eb8d 100644
> --- a/drivers/mmc/fsl_esdhc.c
> +++ b/drivers/mmc/fsl_esdhc.c
> @@ -682,7 +682,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv
> *priv, bool enable)  #endif
> 
>  #ifdef MMC_SUPPORTS_TUNING
> -static int esdhc_change_pinstate(struct udevice *dev)
> +static int esdhc_imx_change_pinstate(struct udevice *dev)
>  {
>  	struct fsl_esdhc_priv *priv = dev_get_priv(dev);
>  	int ret;
> @@ -708,7 +708,7 @@ static int esdhc_change_pinstate(struct udevice
> *dev)
>  	return ret;
>  }
> 
> -static void esdhc_reset_tuning(struct mmc *mmc)
> +static void esdhc_imx_reset_tuning(struct mmc *mmc)
>  {
>  	struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
>  	struct fsl_esdhc *regs = priv->esdhc_regs; @@ -722,7 +722,7 @@ static
> void esdhc_reset_tuning(struct mmc *mmc)
>  	}
>  }
> 
> -static void esdhc_set_strobe_dll(struct mmc *mmc)
> +static void esdhc_imx_set_strobe_dll(struct mmc *mmc)
>  {
>  	struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
>  	struct fsl_esdhc *regs = priv->esdhc_regs; @@ -749,7 +749,7 @@ static
> void esdhc_set_strobe_dll(struct mmc *mmc)
>  	}
>  }
> 
> -static int esdhc_set_timing(struct mmc *mmc)
> +static int esdhc_imx_set_timing(struct mmc *mmc)
>  {
>  	struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
>  	struct fsl_esdhc *regs = priv->esdhc_regs; @@ -761,13 +761,13 @@
> static int esdhc_set_timing(struct mmc *mmc)
>  	switch (mmc->selected_mode) {
>  	case MMC_LEGACY:
>  	case SD_LEGACY:
> -		esdhc_reset_tuning(mmc);
> +		esdhc_imx_reset_tuning(mmc);
>  		writel(mixctrl, &regs->mixctrl);
>  		break;
>  	case MMC_HS_400:
>  		mixctrl |= MIX_CTRL_DDREN | MIX_CTRL_HS400_EN;
>  		writel(mixctrl, &regs->mixctrl);
> -		esdhc_set_strobe_dll(mmc);
> +		esdhc_imx_set_strobe_dll(mmc);
>  		break;
>  	case MMC_HS:
>  	case MMC_HS_52:
> @@ -791,14 +791,13 @@ static int esdhc_set_timing(struct mmc *mmc)
> 
>  	priv->mode = mmc->selected_mode;
> 
> -	return esdhc_change_pinstate(mmc->dev);
> +	return esdhc_imx_change_pinstate(mmc->dev);
>  }
> 
> -static int esdhc_set_voltage(struct mmc *mmc)
> +static int esdhc_imx_set_voltage(struct mmc *mmc)
>  {
>  	struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
>  	struct fsl_esdhc *regs = priv->esdhc_regs;
> -	int ret;
> 
>  	priv->signal_voltage = mmc->signal_voltage;
>  	switch (mmc->signal_voltage) {
> @@ -975,18 +974,18 @@ static int esdhc_set_ios_common(struct
> fsl_esdhc_priv *priv, struct mmc *mmc)  #endif
>  	}
> 
> -	if (priv->mode != mmc->selected_mode) {
> -		ret = esdhc_set_timing(mmc);
> +	if (priv->esdhc_imx && priv->mode != mmc->selected_mode) {
> +		ret = esdhc_imx_set_timing(mmc);
>  		if (ret) {
> -			printf("esdhc_set_timing error %d\n", ret);
> +			printf("esdhc_imx_set_timing error %d\n", ret);
>  			return ret;
>  		}
>  	}
> 
> -	if (priv->signal_voltage != mmc->signal_voltage) {
> -		ret = esdhc_set_voltage(mmc);
> +	if (priv->esdhc_imx && priv->signal_voltage != mmc->signal_voltage) {
> +		ret = esdhc_imx_set_voltage(mmc);
>  		if (ret) {
> -			printf("esdhc_set_voltage error %d\n", ret);
> +			printf("esdhc_imx_set_voltage error %d\n", ret);
>  			return ret;
>  		}
>  	}
> @@ -1267,20 +1266,21 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv
> *priv,
> 
>  	cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
> 
> -	writel(0, &regs->dllctrl);
> -	if (priv->flags & ESDHC_FLAG_USDHC) {
> -		if (priv->flags & ESDHC_FLAG_STD_TUNING) {
> -			u32 val = readl(&regs->tuning_ctrl);
> -
> -			val |= STD_TUNING_EN;
> -			val &= ~TUNING_START_TAP_MASK;
> -			val |= priv->tuning_start_tap;
> -			val &= ~TUNING_STEP_MASK;
> -			val |= (priv->tuning_step) << TUNING_STEP_SHIFT;
> -			writel(val, &regs->tuning_ctrl);
> +	if (priv->esdhc_imx) {
> +		writel(0, &regs->dllctrl);
> +		if (priv->flags & ESDHC_FLAG_USDHC) {
> +			if (priv->flags & ESDHC_FLAG_STD_TUNING) {
> +				u32 val = readl(&regs->tuning_ctrl);
> +
> +				val |= STD_TUNING_EN;
> +				val &= ~TUNING_START_TAP_MASK;
> +				val |= priv->tuning_start_tap;
> +				val &= ~TUNING_STEP_MASK;
> +				val |= priv->tuning_step << TUNING_STEP_SHIFT;
> +				writel(val, &regs->tuning_ctrl);
> +			}
>  		}
>  	}
> -
>  	return 0;
>  }
> 
> @@ -1481,14 +1481,17 @@ static int fsl_esdhc_probe(struct udevice *dev)
>  	else
>  		priv->bus_width = 1;
> 
> -	val = fdtdec_get_int(fdt, node, "fsl,tuning-step", 1);
> -	priv->tuning_step = val;
> -	val = fdtdec_get_int(fdt, node, "fsl,tuning-start-tap",
> -			     TUNING_START_TAP_DEFAULT);
> -	priv->tuning_start_tap = val;
> -	val = fdtdec_get_int(fdt, node, "fsl,strobe-dll-delay-target",
> -			     STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT);
> -	priv->strobe_dll_delay_target = val;
> +	if (priv->esdhc_imx) {
> +		priv->tuning_step =
> +			fdtdec_get_int(fdt, node, "fsl,tuning-step", 1);
> +		priv->tuning_start_tap =
> +			fdtdec_get_int(fdt, node, "fsl,tuning-start-tap",
> +				       TUNING_START_TAP_DEFAULT);
> +		priv->strobe_dll_delay_target =
> +			fdtdec_get_int(fdt, node,
> +				       "fsl,strobe-dll-delay-target",
> +				       STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT);
> +	}
> 
>  	if (dev_read_bool(dev, "non-removable")) {
>  		priv->non_removable = 1;
> @@ -1628,9 +1631,9 @@ static const struct dm_mmc_ops fsl_esdhc_ops =
> {  #endif
> 
>  static struct esdhc_soc_data usdhc_imx7d_data = {
> -	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
> -			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
> -			| ESDHC_FLAG_HS400,
> +	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING |
> +		 ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 |
> +		 ESDHC_FLAG_HS400,
>  	.caps = UHS_CAPS | MMC_MODE_HS200 | MMC_MODE_DDR_52MHz |
>  		MMC_MODE_HS_52MHz | MMC_MODE_HS,
>  };
> --
> 2.17.1



More information about the U-Boot mailing list