[U-Boot] [PATCH] mmc: tmio: sdhi: Do not use auto-retuning in HS400 mode

Marek Vasut marek.vasut at gmail.com
Wed May 22 18:37:29 UTC 2019


The SDHI supports automatic correction of sampling point in
HS200/SDR104 modes. However, on R-Car Gen3, this feature is
not supported in HS400 mode.

Auto and manual correction cannot both be used in HS400 mode.
Therefore, in HS400 mode, disable auto correction and ignore
the error status.

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Peng Fan <peng.fan at nxp.com>
---
 drivers/mmc/renesas-sdhi.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 7c53aa221e..a36162fca6 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -265,7 +265,10 @@ static int renesas_sdhi_hs400(struct udevice *dev)
 	tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_CKSEL);
 
 	reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_RVSCNTL);
-	reg |= RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
+	if (hs400)
+		reg &= ~RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
+	else
+		reg |= RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
 	tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_RVSCNTL);
 
 	/* Execute adjust hs400 offset after setting to HS400 mode */
@@ -288,10 +291,13 @@ static unsigned int renesas_sdhi_compare_scc_data(struct tmio_sd_priv *priv)
 	return tmio_sd_readl(priv, RENESAS_SDHI_SCC_SMPCMP);
 }
 
-static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv,
+static int renesas_sdhi_select_tuning(struct udevice *dev,
 				     unsigned int tap_num, unsigned int taps,
 				     unsigned int smpcmp)
 {
+	struct tmio_sd_priv *priv = dev_get_priv(dev);
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct mmc *mmc = upriv->mmc;
 	unsigned long tap_cnt;  /* counter of tuning success */
 	unsigned long tap_start;/* start position of tuning success */
 	unsigned long tap_end;  /* end position of tuning success */
@@ -385,9 +391,12 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv,
 	/* Set SCC */
 	tmio_sd_writel(priv, priv->tap_set, RENESAS_SDHI_SCC_TAPSET);
 
-	/* Enable auto re-tuning */
+	/* Enable auto re-tuning in HS200/SDR104 modes */
 	reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_RVSCNTL);
-	reg |= RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
+	if (mmc->selected_mode == MMC_HS_400)
+		reg &= ~RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
+	else
+		reg |= RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
 	tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_RVSCNTL);
 
 	return 0;
@@ -447,7 +456,7 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode)
 		mdelay(1);
 	}
 
-	ret = renesas_sdhi_select_tuning(priv, tap_num, taps, smpcmp);
+	ret = renesas_sdhi_select_tuning(dev, tap_num, taps, smpcmp);
 
 out:
 	if (ret < 0) {
-- 
2.20.1



More information about the U-Boot mailing list