Skip to content

Commit 83b600b

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Control the delay between tuning commands
The delay between tuning commands for SD cards is not part of the specification. A driver that needs it probably needs it for eMMC too, whereas most drivers would probably like to set it to 0. Make it a host member (host->tuning_delay) that defaults to the existing behaviour. Drivers can set it to zero to eliminate the delay, or set it to a positive value to always have a delay. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ba49cbd commit 83b600b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,9 +2108,9 @@ static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
21082108
break;
21092109
}
21102110

2111-
/* eMMC spec does not require a delay between tuning cycles */
2112-
if (opcode == MMC_SEND_TUNING_BLOCK)
2113-
mdelay(1);
2111+
/* Spec does not require a delay between tuning cycles */
2112+
if (host->tuning_delay > 0)
2113+
mdelay(host->tuning_delay);
21142114
}
21152115

21162116
pr_info("%s: Tuning failed, falling back to fixed sampling clock\n",
@@ -2172,6 +2172,9 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
21722172

21732173
host->mmc->retune_period = tuning_count;
21742174

2175+
if (host->tuning_delay < 0)
2176+
host->tuning_delay = opcode == MMC_SEND_TUNING_BLOCK;
2177+
21752178
sdhci_start_tuning(host);
21762179

21772180
__sdhci_execute_tuning(host, opcode);
@@ -3114,6 +3117,8 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
31143117
host->cqe_ier = SDHCI_CQE_INT_MASK;
31153118
host->cqe_err_ier = SDHCI_CQE_INT_ERR_MASK;
31163119

3120+
host->tuning_delay = -1;
3121+
31173122
return host;
31183123
}
31193124

drivers/mmc/host/sdhci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ struct sdhci_host {
538538
#define SDHCI_TUNING_MODE_1 0
539539
#define SDHCI_TUNING_MODE_2 1
540540
#define SDHCI_TUNING_MODE_3 2
541+
/* Delay (ms) between tuning commands */
542+
int tuning_delay;
541543

542544
unsigned long private[0] ____cacheline_aligned;
543545
};

0 commit comments

Comments
 (0)