All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 2/9] mmc: tmio: sdhi: Track SMPCMP valu in private data
Date: Sat, 23 Nov 2019 13:36:18 +0100	[thread overview]
Message-ID: <20191123123625.111794-2-marek.vasut+renesas@gmail.com> (raw)
In-Reply-To: <20191123123625.111794-1-marek.vasut+renesas@gmail.com>

Retain the SMPCMP value from last calibration in private data.
This will be later used for skipping bad taps.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
V2: Rebase on u-boot/master, no other change
---
 drivers/mmc/renesas-sdhi.c | 18 ++++++++++--------
 drivers/mmc/tmio-common.h  |  1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index acc44e5b90..2f34173d03 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -289,7 +289,7 @@ static unsigned int renesas_sdhi_compare_scc_data(struct tmio_sd_priv *priv)
 }
 
 static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv,
-				     unsigned int taps, unsigned int smpcmp)
+				     unsigned int taps)
 {
 	unsigned long tap_cnt;  /* counter of tuning success */
 	unsigned long tap_start;/* start position of tuning success */
@@ -311,9 +311,9 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv,
 			taps &= ~BIT(i % priv->tap_num);
 			taps &= ~BIT((i % priv->tap_num) + priv->tap_num);
 		}
-		if (!(smpcmp & BIT(i))) {
-			smpcmp &= ~BIT(i % priv->tap_num);
-			smpcmp &= ~BIT((i % priv->tap_num) + priv->tap_num);
+		if (!(priv->smpcmp & BIT(i))) {
+			priv->smpcmp &= ~BIT(i % priv->tap_num);
+			priv->smpcmp &= ~BIT((i % priv->tap_num) + priv->tap_num);
 		}
 	}
 
@@ -355,7 +355,7 @@ static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv,
 		tap_start = 0;
 		tap_end = 0;
 		for (i = 0; i < priv->tap_num * 2; i++) {
-			if (smpcmp & BIT(i))
+			if (priv->smpcmp & BIT(i))
 				ntap++;
 			else {
 				if (ntap > match_cnt) {
@@ -398,7 +398,7 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode)
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	struct mmc *mmc = upriv->mmc;
 	unsigned int tap_num;
-	unsigned int taps = 0, smpcmp = 0;
+	unsigned int taps = 0;
 	int i, ret = 0;
 	u32 caps;
 
@@ -426,6 +426,8 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode)
 		goto out;
 	}
 
+	priv->smpcmp = 0;
+
 	/* Issue CMD19 twice for each tap */
 	for (i = 0; i < 2 * priv->tap_num; i++) {
 		renesas_sdhi_prepare_tuning(priv, i % priv->tap_num);
@@ -443,12 +445,12 @@ int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode)
 
 		ret = renesas_sdhi_compare_scc_data(priv);
 		if (ret == 0)
-			smpcmp |= BIT(i);
+			priv->smpcmp |= BIT(i);
 
 		mdelay(1);
 	}
 
-	ret = renesas_sdhi_select_tuning(priv, taps, smpcmp);
+	ret = renesas_sdhi_select_tuning(priv, taps);
 
 out:
 	if (ret < 0) {
diff --git a/drivers/mmc/tmio-common.h b/drivers/mmc/tmio-common.h
index da89cc90c2..79f51d21af 100644
--- a/drivers/mmc/tmio-common.h
+++ b/drivers/mmc/tmio-common.h
@@ -137,6 +137,7 @@ struct tmio_sd_priv {
 	struct clk			clk;
 #endif
 #if CONFIG_IS_ENABLED(RENESAS_SDHI)
+	unsigned int			smpcmp;
 	u8				tap_set;
 	u8				tap_num;
 	u8				nrtaps;
-- 
2.24.0.359.ga6e4e5af0a

  reply	other threads:[~2019-11-23 12:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23 12:36 [U-Boot] [PATCH V2 1/9] mmc: tmio: sdhi: Track current tap number in private data Marek Vasut
2019-11-23 12:36 ` Marek Vasut [this message]
2019-11-23 12:36 ` [U-Boot] [PATCH V2 3/9] mmc: tmio: sdhi: Use 4 tuning taps on M3W up to ES1.2 Marek Vasut
2019-11-23 12:36 ` [U-Boot] [PATCH V2 4/9] mmc: tmio: sdhi: Adjust DT2FF settings for HS400 mode Marek Vasut
2019-11-23 12:36 ` [U-Boot] [PATCH V2 5/9] mmc: tmio: sdhi: Adjust HS400 calibration offsets Marek Vasut
2019-11-23 12:36 ` [U-Boot] [PATCH V2 6/9] mmc: tmio: sdhi: Disable auto-retuning in HS400 Marek Vasut
2019-11-23 12:36 ` [U-Boot] [PATCH V2 7/9] mmc: tmio: sdhi: Add SCC error checking Marek Vasut
2019-11-23 12:36 ` [U-Boot] [PATCH V2 8/9] mmc: tmio: sdhi: Skip bad taps Marek Vasut
2019-11-23 12:36 ` [U-Boot] [PATCH V2 9/9] mmc: tmio: sdhi: Add calibration tables Marek Vasut

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=20191123123625.111794-2-marek.vasut+renesas@gmail.com \
    --to=marek.vasut@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.