From: Ulf Hansson <ulf.hansson@linaro.org>
To: linux-mmc@vger.kernel.org, Ulf Hansson <ulf.hansson@linaro.org>,
Chris Ball <chris@printf.net>
Cc: Seungwon Jeon <tgih.jun@samsung.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Shawn Guo <shawn.guo@linaro.org>,
Sascha Hauer <kernel@pengutronix.de>,
Aisheng Dong <b29396@freescale.com>,
Stephen Boyd <sboyd@codeaurora.org>,
Minda Chen <Minda.Chen@csr.com>, Barry Song <Baohua.Song@csr.com>
Subject: [PATCH v2 2/4] mmc: sdhci-msm: Convert to mmc_send_tuning()
Date: Fri, 5 Dec 2014 12:59:41 +0100 [thread overview]
Message-ID: <1417780783-12939-3-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1417780783-12939-1-git-send-email-ulf.hansson@linaro.org>
Instead of having a local hack taking care of sending the tuning
command and as well to verify the response pattern, let's convert to
the common mmc_send_tuning() API instead.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Changes in v2:
Rebased, to get latest version of the mmc_send_tuning() API.
---
drivers/mmc/host/sdhci-msm.c | 50 +++++++-------------------------------------
1 file changed, 7 insertions(+), 43 deletions(-)
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 3080438..3d32ce8 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -339,9 +339,7 @@ static int msm_init_cm_dll(struct sdhci_host *host)
static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
{
int tuning_seq_cnt = 3;
- u8 phase, *data_buf, tuned_phases[16], tuned_phase_cnt = 0;
- const u8 *tuning_block_pattern = tuning_blk_pattern_4bit;
- int size = sizeof(tuning_blk_pattern_4bit);
+ u8 phase, tuned_phases[16], tuned_phase_cnt = 0;
int rc;
struct mmc_host *mmc = host->mmc;
struct mmc_ios ios = host->mmc->ios;
@@ -355,53 +353,21 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
(ios.timing == MMC_TIMING_UHS_SDR104)))
return 0;
- if ((opcode == MMC_SEND_TUNING_BLOCK_HS200) &&
- (mmc->ios.bus_width == MMC_BUS_WIDTH_8)) {
- tuning_block_pattern = tuning_blk_pattern_8bit;
- size = sizeof(tuning_blk_pattern_8bit);
- }
-
- data_buf = kmalloc(size, GFP_KERNEL);
- if (!data_buf)
- return -ENOMEM;
-
retry:
/* First of all reset the tuning block */
rc = msm_init_cm_dll(host);
if (rc)
- goto out;
+ return rc;
phase = 0;
do {
- struct mmc_command cmd = { 0 };
- struct mmc_data data = { 0 };
- struct mmc_request mrq = {
- .cmd = &cmd,
- .data = &data
- };
- struct scatterlist sg;
-
/* Set the phase in delay line hw block */
rc = msm_config_cm_dll_phase(host, phase);
if (rc)
- goto out;
+ return rc;
- cmd.opcode = opcode;
- cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
-
- data.blksz = size;
- data.blocks = 1;
- data.flags = MMC_DATA_READ;
- data.timeout_ns = NSEC_PER_SEC; /* 1 second */
-
- data.sg = &sg;
- data.sg_len = 1;
- sg_init_one(&sg, data_buf, size);
- memset(data_buf, 0, size);
- mmc_wait_for_req(mmc, &mrq);
-
- if (!cmd.error && !data.error &&
- !memcmp(data_buf, tuning_block_pattern, size)) {
+ rc = mmc_send_tuning(mmc);
+ if (!rc) {
/* Tuning is successful at this tuning point */
tuned_phases[tuned_phase_cnt++] = phase;
dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n",
@@ -413,7 +379,7 @@ retry:
rc = msm_find_most_appropriate_phase(host, tuned_phases,
tuned_phase_cnt);
if (rc < 0)
- goto out;
+ return rc;
else
phase = rc;
@@ -423,7 +389,7 @@ retry:
*/
rc = msm_config_cm_dll_phase(host, phase);
if (rc)
- goto out;
+ return rc;
dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n",
mmc_hostname(mmc), phase);
} else {
@@ -435,8 +401,6 @@ retry:
rc = -EIO;
}
-out:
- kfree(data_buf);
return rc;
}
--
1.9.1
next prev parent reply other threads:[~2014-12-05 11:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-05 11:59 [PATCH v2 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
2014-12-05 11:59 ` [PATCH v2 1/4] mmc: sdhci-esdhc-imx: Convert " Ulf Hansson
2014-12-05 11:59 ` Ulf Hansson [this message]
2014-12-05 16:29 ` [PATCH v2 2/4] mmc: sdhci-msm: " Georgi Djakov
2014-12-05 18:13 ` Stephen Boyd
2014-12-05 11:59 ` [PATCH v2 3/4] mmc: dw_mmc: " Ulf Hansson
2014-12-06 12:43 ` Alim Akhtar
2014-12-08 10:10 ` Ulf Hansson
2014-12-09 21:30 ` Alim Akhtar
2014-12-12 15:13 ` Jaehoon Chung
2014-12-15 4:48 ` Jaehoon Chung
2014-12-20 13:34 ` Alim Akhtar
2014-12-22 4:05 ` Jaehoon Chung
2014-12-20 13:18 ` Alim Akhtar
2014-12-22 14:41 ` Ulf Hansson
2014-12-23 9:49 ` Jaehoon Chung
2014-12-23 9:53 ` Jaehoon Chung
2014-12-23 10:21 ` Ulf Hansson
2014-12-24 1:43 ` Jaehoon Chung
2014-12-24 14:07 ` Alim Akhtar
2014-12-05 11:59 ` [PATCH v2 4/4] mmc: core: Make tuning block patterns static Ulf Hansson
2014-12-05 18:12 ` Stephen Boyd
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=1417780783-12939-3-git-send-email-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=Baohua.Song@csr.com \
--cc=Minda.Chen@csr.com \
--cc=b29396@freescale.com \
--cc=chris@printf.net \
--cc=jh80.chung@samsung.com \
--cc=kernel@pengutronix.de \
--cc=linux-mmc@vger.kernel.org \
--cc=sboyd@codeaurora.org \
--cc=shawn.guo@linaro.org \
--cc=tgih.jun@samsung.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).