From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-mmc@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Masaharu Hayakawa" <masaharu.hayakawa.ry@renesas.com>,
"Takeshi Saito" <takeshi.saito.xv@renesas.com>
Subject: [PATCH RFT 3/3] mmc: renesas_sdhi: improve TAP selection if all TAPs are good
Date: Fri, 6 Mar 2020 10:31:59 +0100 [thread overview]
Message-ID: <20200306093159.6155-4-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20200306093159.6155-1-wsa+renesas@sang-engineering.com>
When tuning HS400, if all TAPS are good, we can utilize the SMPCMP
register to select the optimal TAP. For that, we populate a second
bitmap with SMPCMP results and query it in case the regular bitmap is
full (= all good).
Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
Signed-off-by: Takeshi Saito <takeshi.saito.xv@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/mmc/host/renesas_sdhi.h | 2 ++
drivers/mmc/host/renesas_sdhi_core.c | 26 +++++++++++++++++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index 2a4c83a5f32e..12d8016672b0 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -61,6 +61,8 @@ struct renesas_sdhi {
/* Tuning values: 1 for success, 0 for failure */
DECLARE_BITMAP(taps, BITS_PER_LONG);
+ /* Sampling data comparison: 1 for match, 0 for mismatch */
+ DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
unsigned int tap_num;
unsigned long tap_set;
};
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index beac70a0defb..4a5abf28dee5 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -428,7 +428,8 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
{
struct renesas_sdhi *priv = host_to_priv(host);
unsigned int tap_start = 0, tap_end = 0, tap_cnt = 0, rs, re, i;
- unsigned int taps_size = priv->tap_num * 2;
+ unsigned int taps_size = priv->tap_num * 2, min_tap_row;
+ unsigned long *bitmap;
priv->doing_tune = false;
sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ, 0);
@@ -443,6 +444,21 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
if (!test_bit(i, priv->taps))
clear_bit(i + offset, priv->taps);
+
+ if (!test_bit(i, priv->smpcmp))
+ clear_bit(i + offset, priv->smpcmp);
+ }
+
+ /*
+ * If all TAP are OK, the sampling clock position is selected by
+ * identifying the change point of data.
+ */
+ if (bitmap_full(priv->taps, taps_size)) {
+ bitmap = priv->smpcmp;
+ min_tap_row = 1;
+ } else {
+ bitmap = priv->taps;
+ min_tap_row = SH_MOBILE_SDHI_MIN_TAP_ROW;
}
/*
@@ -450,7 +466,7 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
* is at least SH_MOBILE_SDHI_MIN_TAP_ROW probes long then use the
* center index as the tap, otherwise bail out.
*/
- bitmap_for_each_set_region(priv->taps, rs, re, 0, taps_size) {
+ bitmap_for_each_set_region(bitmap, rs, re, 0, taps_size) {
if (re - 1 - rs > tap_cnt) {
tap_end = re - 1;
tap_start = rs;
@@ -458,7 +474,7 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)
}
}
- if (tap_cnt >= SH_MOBILE_SDHI_MIN_TAP_ROW)
+ if (tap_cnt >= min_tap_row)
priv->tap_set = (tap_start + tap_end) / 2 % priv->tap_num;
else
return -EIO;
@@ -491,6 +507,7 @@ static int renesas_sdhi_execute_tuning(struct tmio_mmc_host *host, u32 opcode)
priv->doing_tune = true;
bitmap_zero(priv->taps, priv->tap_num * 2);
+ bitmap_zero(priv->smpcmp, priv->tap_num * 2);
/* Issue CMD19 twice for each tap */
for (i = 0; i < 2 * priv->tap_num; i++) {
@@ -499,6 +516,9 @@ static int renesas_sdhi_execute_tuning(struct tmio_mmc_host *host, u32 opcode)
if (mmc_send_tuning(host->mmc, opcode, NULL) == 0)
set_bit(i, priv->taps);
+
+ if (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_SMPCMP) == 0)
+ set_bit(i, priv->smpcmp);
}
return renesas_sdhi_select_tuning(host);
--
2.20.1
next prev parent reply other threads:[~2020-03-06 9:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-06 9:31 [PATCH RFT 0/3] mmc: renesas_sdhi: improve TAP selection if all TAPs are good Wolfram Sang
2020-03-06 9:31 ` [PATCH RFT 1/3] mmc: renesas_sdhi: refactor calculation of best TAP Wolfram Sang
2020-03-26 7:04 ` Yoshihiro Shimoda
2020-04-07 15:06 ` Wolfram Sang
2020-03-06 9:31 ` [PATCH RFT 2/3] mmc: renesas_sdhi: clarify handling of selecting TAPs Wolfram Sang
2020-03-26 7:06 ` Yoshihiro Shimoda
2020-03-06 9:31 ` Wolfram Sang [this message]
2020-03-26 7:14 ` [PATCH RFT 3/3] mmc: renesas_sdhi: improve TAP selection if all TAPs are good Yoshihiro Shimoda
2020-03-26 8:38 ` [PATCH RFT 0/3] " Yoshihiro Shimoda
2020-04-07 15:07 ` Wolfram Sang
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=20200306093159.6155-4-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=masaharu.hayakawa.ry@renesas.com \
--cc=niklas.soderlund@ragnatech.se \
--cc=takeshi.saito.xv@renesas.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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;
as well as URLs for NNTP newsgroup(s).