Commit 33d73935 authored by Ulf Hansson's avatar Ulf Hansson

mmc: sdhci-msm: Convert to mmc_send_tuning()

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: default avatarUlf Hansson <ulf.hansson@linaro.org>
Tested-by: default avatarGeorgi Djakov <gdjakov@mm-sol.com>
Acked-by: default avatarGeorgi Djakov <gdjakov@mm-sol.com>
Reviewed-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent d1785326
...@@ -339,9 +339,7 @@ static int msm_init_cm_dll(struct sdhci_host *host) ...@@ -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) static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
{ {
int tuning_seq_cnt = 3; int tuning_seq_cnt = 3;
u8 phase, *data_buf, tuned_phases[16], tuned_phase_cnt = 0; u8 phase, tuned_phases[16], tuned_phase_cnt = 0;
const u8 *tuning_block_pattern = tuning_blk_pattern_4bit;
int size = sizeof(tuning_blk_pattern_4bit);
int rc; int rc;
struct mmc_host *mmc = host->mmc; struct mmc_host *mmc = host->mmc;
struct mmc_ios ios = host->mmc->ios; struct mmc_ios ios = host->mmc->ios;
...@@ -355,53 +353,21 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) ...@@ -355,53 +353,21 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
(ios.timing == MMC_TIMING_UHS_SDR104))) (ios.timing == MMC_TIMING_UHS_SDR104)))
return 0; 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: retry:
/* First of all reset the tuning block */ /* First of all reset the tuning block */
rc = msm_init_cm_dll(host); rc = msm_init_cm_dll(host);
if (rc) if (rc)
goto out; return rc;
phase = 0; phase = 0;
do { 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 */ /* Set the phase in delay line hw block */
rc = msm_config_cm_dll_phase(host, phase); rc = msm_config_cm_dll_phase(host, phase);
if (rc) 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 && rc = mmc_send_tuning(mmc);
!memcmp(data_buf, tuning_block_pattern, size)) { if (!rc) {
/* Tuning is successful at this tuning point */ /* Tuning is successful at this tuning point */
tuned_phases[tuned_phase_cnt++] = phase; tuned_phases[tuned_phase_cnt++] = phase;
dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n", dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n",
...@@ -413,7 +379,7 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) ...@@ -413,7 +379,7 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
rc = msm_find_most_appropriate_phase(host, tuned_phases, rc = msm_find_most_appropriate_phase(host, tuned_phases,
tuned_phase_cnt); tuned_phase_cnt);
if (rc < 0) if (rc < 0)
goto out; return rc;
else else
phase = rc; phase = rc;
...@@ -423,7 +389,7 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) ...@@ -423,7 +389,7 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
*/ */
rc = msm_config_cm_dll_phase(host, phase); rc = msm_config_cm_dll_phase(host, phase);
if (rc) if (rc)
goto out; return rc;
dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n", dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n",
mmc_hostname(mmc), phase); mmc_hostname(mmc), phase);
} else { } else {
...@@ -435,8 +401,6 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) ...@@ -435,8 +401,6 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
rc = -EIO; rc = -EIO;
} }
out:
kfree(data_buf);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment