aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
authorSujit Reddy Thumma <sthumma@codeaurora.org>2012-02-04 16:14:50 -0500
committerChris Ball <cjb@laptop.org>2012-02-13 20:38:58 -0500
commit2c4967f741e87cdd63de7271b97807041dccbf3b (patch)
treee9792b49e457393d275db4ab3948fa95f1ef57d6 /drivers/mmc/core/sd.c
parentb6bf30d912ddc9a3ac2ce264a04e3ec6d4e74a34 (diff)
mmc: core: Ensure clocks are always enabled before host interaction
Ensure clocks are always enabled before any interaction with the host controller driver. This makes sure that there is no race between host execution and the core layer turning off clocks in different context with clock gating framework. Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Per Forlin <per.forlin@stericsson.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index c63ad03c29c7..5017f9354ce2 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -451,9 +451,11 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)
451 * information and let the hardware specific code 451 * information and let the hardware specific code
452 * return what is possible given the options 452 * return what is possible given the options
453 */ 453 */
454 mmc_host_clk_hold(card->host);
454 drive_strength = card->host->ops->select_drive_strength( 455 drive_strength = card->host->ops->select_drive_strength(
455 card->sw_caps.uhs_max_dtr, 456 card->sw_caps.uhs_max_dtr,
456 host_drv_type, card_drv_type); 457 host_drv_type, card_drv_type);
458 mmc_host_clk_release(card->host);
457 459
458 err = mmc_sd_switch(card, 1, 2, drive_strength, status); 460 err = mmc_sd_switch(card, 1, 2, drive_strength, status);
459 if (err) 461 if (err)
@@ -660,9 +662,12 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)
660 goto out; 662 goto out;
661 663
662 /* SPI mode doesn't define CMD19 */ 664 /* SPI mode doesn't define CMD19 */
663 if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning) 665 if (!mmc_host_is_spi(card->host) && card->host->ops->execute_tuning) {
666 mmc_host_clk_hold(card->host);
664 err = card->host->ops->execute_tuning(card->host, 667 err = card->host->ops->execute_tuning(card->host,
665 MMC_SEND_TUNING_BLOCK); 668 MMC_SEND_TUNING_BLOCK);
669 mmc_host_clk_release(card->host);
670 }
666 671
667out: 672out:
668 kfree(status); 673 kfree(status);
@@ -850,8 +855,11 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
850 if (!reinit) { 855 if (!reinit) {
851 int ro = -1; 856 int ro = -1;
852 857
853 if (host->ops->get_ro) 858 if (host->ops->get_ro) {
859 mmc_host_clk_hold(card->host);
854 ro = host->ops->get_ro(host); 860 ro = host->ops->get_ro(host);
861 mmc_host_clk_release(card->host);
862 }
855 863
856 if (ro < 0) { 864 if (ro < 0) {
857 pr_warning("%s: host does not " 865 pr_warning("%s: host does not "
@@ -967,8 +975,11 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
967 * Since initialization is now complete, enable preset 975 * Since initialization is now complete, enable preset
968 * value registers for UHS-I cards. 976 * value registers for UHS-I cards.
969 */ 977 */
970 if (host->ops->enable_preset_value) 978 if (host->ops->enable_preset_value) {
979 mmc_host_clk_hold(card->host);
971 host->ops->enable_preset_value(host, true); 980 host->ops->enable_preset_value(host, true);
981 mmc_host_clk_release(card->host);
982 }
972 } else { 983 } else {
973 /* 984 /*
974 * Attempt to change to high-speed (if supported) 985 * Attempt to change to high-speed (if supported)
@@ -1151,8 +1162,11 @@ int mmc_attach_sd(struct mmc_host *host)
1151 return err; 1162 return err;
1152 1163
1153 /* Disable preset value enable if already set since last time */ 1164 /* Disable preset value enable if already set since last time */
1154 if (host->ops->enable_preset_value) 1165 if (host->ops->enable_preset_value) {
1166 mmc_host_clk_hold(host);
1155 host->ops->enable_preset_value(host, false); 1167 host->ops->enable_preset_value(host, false);
1168 mmc_host_clk_release(host);
1169 }
1156 1170
1157 err = mmc_send_app_op_cond(host, 0, &ocr); 1171 err = mmc_send_app_op_cond(host, 0, &ocr);
1158 if (err) 1172 if (err)