public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Y.b. Lu <yangbo.lu@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [v2, 3/3] mmc: fsl_esdhc: clarify i.MX eSDHC specific functions
Date: Fri, 15 Feb 2019 02:25:51 +0000	[thread overview]
Message-ID: <20190215022656.19310-3-yangbo.lu@nxp.com> (raw)
In-Reply-To: <20190215022656.19310-1-yangbo.lu@nxp.com>

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@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
Changes for v2:
	- Added "Reviewed-by: Peng Fan".
---
 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 e9622ce9a4..92924b63ac 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

  parent reply	other threads:[~2019-02-15  2:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15  2:25 [U-Boot] [v2, 1/3] mmc: fsl_esdhc: add esdhc_imx flag Y.b. Lu
2019-02-15  2:25 ` [U-Boot] [v2, 2/3] mmc: fsl_esdhc: clean up register definition Y.b. Lu
2019-02-15  2:25 ` Y.b. Lu [this message]
2019-02-15  5:14 ` [U-Boot] [v2, 1/3] mmc: fsl_esdhc: add esdhc_imx flag Peng Fan
2019-02-17 23:12 ` Lukasz Majewski
2019-02-19  4:02   ` Y.b. Lu
2019-02-19  6:39     ` Lukasz Majewski
2019-02-21  7:54       ` Y.b. Lu
2019-02-26  3:39         ` Y.b. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190215022656.19310-3-yangbo.lu@nxp.com \
    --to=yangbo.lu@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox