aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-12-05 12:40:59 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2015-01-19 03:56:30 -0500
commit63e415c64003fd62a302a1dc19f082e2c6f1b7cc (patch)
tree87a6a228a7f2b2fc19c9e3f67b1339181b930f05
parentfdb9de129e1d68e1b804bc9c8b3027bea9b88bc8 (diff)
mmc: core: Simplify by adding mmc_execute_tuning()
For each MMC, SD and SDIO there is code that holds the clock, calls ops->execute_tuning, and releases the clock. Simplify the code a bit by providing a separate function to do that. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/core.c24
-rw-r--r--drivers/mmc/core/core.h3
-rw-r--r--drivers/mmc/core/mmc.c14
-rw-r--r--drivers/mmc/core/sd.c13
-rw-r--r--drivers/mmc/core/sdio.c14
5 files changed, 36 insertions, 32 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 2cdb06e0643e..dc9eb013db5f 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1077,6 +1077,30 @@ void mmc_set_ungated(struct mmc_host *host)
1077} 1077}
1078#endif 1078#endif
1079 1079
1080int mmc_execute_tuning(struct mmc_card *card)
1081{
1082 struct mmc_host *host = card->host;
1083 u32 opcode;
1084 int err;
1085
1086 if (!host->ops->execute_tuning)
1087 return 0;
1088
1089 if (mmc_card_mmc(card))
1090 opcode = MMC_SEND_TUNING_BLOCK_HS200;
1091 else
1092 opcode = MMC_SEND_TUNING_BLOCK;
1093
1094 mmc_host_clk_hold(host);
1095 err = host->ops->execute_tuning(host, opcode);
1096 mmc_host_clk_release(host);
1097
1098 if (err)
1099 pr_err("%s: tuning execution failed\n", mmc_hostname(host));
1100
1101 return err;
1102}
1103
1080/* 1104/*
1081 * Change the bus mode (open drain/push-pull) of a host. 1105 * Change the bus mode (open drain/push-pull) of a host.
1082 */ 1106 */
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index a0bccbc4c5ea..cfba3c05aab1 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -86,5 +86,8 @@ void mmc_add_card_debugfs(struct mmc_card *card);
86void mmc_remove_card_debugfs(struct mmc_card *card); 86void mmc_remove_card_debugfs(struct mmc_card *card);
87 87
88void mmc_init_context_info(struct mmc_host *host); 88void mmc_init_context_info(struct mmc_host *host);
89
90int mmc_execute_tuning(struct mmc_card *card);
91
89#endif 92#endif
90 93
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index d5d576a4bcbb..1fc48a280659 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1162,7 +1162,6 @@ bus_speed:
1162static int mmc_hs200_tuning(struct mmc_card *card) 1162static int mmc_hs200_tuning(struct mmc_card *card)
1163{ 1163{
1164 struct mmc_host *host = card->host; 1164 struct mmc_host *host = card->host;
1165 int err = 0;
1166 1165
1167 /* 1166 /*
1168 * Timing should be adjusted to the HS400 target 1167 * Timing should be adjusted to the HS400 target
@@ -1173,18 +1172,7 @@ static int mmc_hs200_tuning(struct mmc_card *card)
1173 if (host->ops->prepare_hs400_tuning) 1172 if (host->ops->prepare_hs400_tuning)
1174 host->ops->prepare_hs400_tuning(host, &host->ios); 1173 host->ops->prepare_hs400_tuning(host, &host->ios);
1175 1174
1176 if (host->ops->execute_tuning) { 1175 return mmc_execute_tuning(card);
1177 mmc_host_clk_hold(host);
1178 err = host->ops->execute_tuning(host,
1179 MMC_SEND_TUNING_BLOCK_HS200);
1180 mmc_host_clk_release(host);
1181
1182 if (err)
1183 pr_err("%s: tuning execution failed\n",
1184 mmc_hostname(host));
1185 }
1186
1187 return err;
1188} 1176}
1189 1177
1190/* 1178/*
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 36d5333838cb..ad4d43eae99d 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -660,15 +660,10 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
660 * SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and 660 * SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
661 * SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. 661 * SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
662 */ 662 */
663 if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning && 663 if (!mmc_host_is_spi(card->host) &&
664 (card->sd_bus_speed == UHS_SDR50_BUS_SPEED || 664 (card->sd_bus_speed == UHS_SDR50_BUS_SPEED ||
665 card->sd_bus_speed == UHS_SDR104_BUS_SPEED)) { 665 card->sd_bus_speed == UHS_SDR104_BUS_SPEED))
666 mmc_host_clk_hold(card->host); 666 err = mmc_execute_tuning(card);
667 err = card->host->ops->execute_tuning(card->host,
668 MMC_SEND_TUNING_BLOCK);
669 mmc_host_clk_release(card->host);
670 }
671
672out: 667out:
673 kfree(status); 668 kfree(status);
674 669
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index fd0750b5a634..ce6cc47206b0 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -567,17 +567,11 @@ static int mmc_sdio_init_uhs_card(struct mmc_card *card)
567 * SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and 567 * SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and
568 * SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. 568 * SDR104 mode SD-cards. Note that tuning is mandatory for SDR104.
569 */ 569 */
570 if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning && 570 if (!mmc_host_is_spi(card->host) &&
571 ((card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR50) || 571 ((card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR50) ||
572 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104))) { 572 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)))
573 mmc_host_clk_hold(card->host); 573 err = mmc_execute_tuning(card);
574 err = card->host->ops->execute_tuning(card->host,
575 MMC_SEND_TUNING_BLOCK);
576 mmc_host_clk_release(card->host);
577 }
578
579out: 574out:
580
581 return err; 575 return err;
582} 576}
583 577