diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2014-12-05 06:59:41 -0500 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2014-12-08 03:21:06 -0500 |
commit | 33d73935e4abb2c75f263dd31a314db09ccf41be (patch) | |
tree | 8d9882d1c7ef0da608d86a1889910702e78d09aa | |
parent | d1785326891c2f9919163be5dae8f2538cfcae58 (diff) |
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: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Georgi Djakov <gdjakov@mm-sol.com>
Acked-by: Georgi Djakov <gdjakov@mm-sol.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
-rw-r--r-- | drivers/mmc/host/sdhci-msm.c | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 30804385af6d..3d32ce896b09 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) | |||
339 | static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) | 339 | static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) |
340 | { | 340 | { |
341 | int tuning_seq_cnt = 3; | 341 | int tuning_seq_cnt = 3; |
342 | u8 phase, *data_buf, tuned_phases[16], tuned_phase_cnt = 0; | 342 | u8 phase, tuned_phases[16], tuned_phase_cnt = 0; |
343 | const u8 *tuning_block_pattern = tuning_blk_pattern_4bit; | ||
344 | int size = sizeof(tuning_blk_pattern_4bit); | ||
345 | int rc; | 343 | int rc; |
346 | struct mmc_host *mmc = host->mmc; | 344 | struct mmc_host *mmc = host->mmc; |
347 | struct mmc_ios ios = host->mmc->ios; | 345 | struct mmc_ios ios = host->mmc->ios; |
@@ -355,53 +353,21 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) | |||
355 | (ios.timing == MMC_TIMING_UHS_SDR104))) | 353 | (ios.timing == MMC_TIMING_UHS_SDR104))) |
356 | return 0; | 354 | return 0; |
357 | 355 | ||
358 | if ((opcode == MMC_SEND_TUNING_BLOCK_HS200) && | ||
359 | (mmc->ios.bus_width == MMC_BUS_WIDTH_8)) { | ||
360 | tuning_block_pattern = tuning_blk_pattern_8bit; | ||
361 | size = sizeof(tuning_blk_pattern_8bit); | ||
362 | } | ||
363 | |||
364 | data_buf = kmalloc(size, GFP_KERNEL); | ||
365 | if (!data_buf) | ||
366 | return -ENOMEM; | ||
367 | |||
368 | retry: | 356 | retry: |
369 | /* First of all reset the tuning block */ | 357 | /* First of all reset the tuning block */ |
370 | rc = msm_init_cm_dll(host); | 358 | rc = msm_init_cm_dll(host); |
371 | if (rc) | 359 | if (rc) |
372 | goto out; | 360 | return rc; |
373 | 361 | ||
374 | phase = 0; | 362 | phase = 0; |
375 | do { | 363 | do { |
376 | struct mmc_command cmd = { 0 }; | ||
377 | struct mmc_data data = { 0 }; | ||
378 | struct mmc_request mrq = { | ||
379 | .cmd = &cmd, | ||
380 | .data = &data | ||
381 | }; | ||
382 | struct scatterlist sg; | ||
383 | |||
384 | /* Set the phase in delay line hw block */ | 364 | /* Set the phase in delay line hw block */ |
385 | rc = msm_config_cm_dll_phase(host, phase); | 365 | rc = msm_config_cm_dll_phase(host, phase); |
386 | if (rc) | 366 | if (rc) |
387 | goto out; | 367 | return rc; |
388 | 368 | ||
389 | cmd.opcode = opcode; | 369 | rc = mmc_send_tuning(mmc); |
390 | cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; | 370 | if (!rc) { |
391 | |||
392 | data.blksz = size; | ||
393 | data.blocks = 1; | ||
394 | data.flags = MMC_DATA_READ; | ||
395 | data.timeout_ns = NSEC_PER_SEC; /* 1 second */ | ||
396 | |||
397 | data.sg = &sg; | ||
398 | data.sg_len = 1; | ||
399 | sg_init_one(&sg, data_buf, size); | ||
400 | memset(data_buf, 0, size); | ||
401 | mmc_wait_for_req(mmc, &mrq); | ||
402 | |||
403 | if (!cmd.error && !data.error && | ||
404 | !memcmp(data_buf, tuning_block_pattern, size)) { | ||
405 | /* Tuning is successful at this tuning point */ | 371 | /* Tuning is successful at this tuning point */ |
406 | tuned_phases[tuned_phase_cnt++] = phase; | 372 | tuned_phases[tuned_phase_cnt++] = phase; |
407 | dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n", | 373 | dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n", |
@@ -413,7 +379,7 @@ retry: | |||
413 | rc = msm_find_most_appropriate_phase(host, tuned_phases, | 379 | rc = msm_find_most_appropriate_phase(host, tuned_phases, |
414 | tuned_phase_cnt); | 380 | tuned_phase_cnt); |
415 | if (rc < 0) | 381 | if (rc < 0) |
416 | goto out; | 382 | return rc; |
417 | else | 383 | else |
418 | phase = rc; | 384 | phase = rc; |
419 | 385 | ||
@@ -423,7 +389,7 @@ retry: | |||
423 | */ | 389 | */ |
424 | rc = msm_config_cm_dll_phase(host, phase); | 390 | rc = msm_config_cm_dll_phase(host, phase); |
425 | if (rc) | 391 | if (rc) |
426 | goto out; | 392 | return rc; |
427 | dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n", | 393 | dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n", |
428 | mmc_hostname(mmc), phase); | 394 | mmc_hostname(mmc), phase); |
429 | } else { | 395 | } else { |
@@ -435,8 +401,6 @@ retry: | |||
435 | rc = -EIO; | 401 | rc = -EIO; |
436 | } | 402 | } |
437 | 403 | ||
438 | out: | ||
439 | kfree(data_buf); | ||
440 | return rc; | 404 | return rc; |
441 | } | 405 | } |
442 | 406 | ||