aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 74972c241dff..9e645e19cec6 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -444,8 +444,7 @@ static void sd_update_bus_speed_mode(struct mmc_card *card)
444 * If the host doesn't support any of the UHS-I modes, fallback on 444 * If the host doesn't support any of the UHS-I modes, fallback on
445 * default speed. 445 * default speed.
446 */ 446 */
447 if (!(card->host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | 447 if (!mmc_host_uhs(card->host)) {
448 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) {
449 card->sd_bus_speed = 0; 448 card->sd_bus_speed = 0;
450 return; 449 return;
451 } 450 }
@@ -713,6 +712,14 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
713{ 712{
714 int err; 713 int err;
715 u32 max_current; 714 u32 max_current;
715 int retries = 10;
716
717try_again:
718 if (!retries) {
719 ocr &= ~SD_OCR_S18R;
720 pr_warning("%s: Skipping voltage switch\n",
721 mmc_hostname(host));
722 }
716 723
717 /* 724 /*
718 * Since we're changing the OCR value, we seem to 725 * Since we're changing the OCR value, we seem to
@@ -734,10 +741,10 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
734 741
735 /* 742 /*
736 * If the host supports one of UHS-I modes, request the card 743 * If the host supports one of UHS-I modes, request the card
737 * to switch to 1.8V signaling level. 744 * to switch to 1.8V signaling level. If the card has failed
745 * repeatedly to switch however, skip this.
738 */ 746 */
739 if (host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | 747 if (retries && mmc_host_uhs(host))
740 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))
741 ocr |= SD_OCR_S18R; 748 ocr |= SD_OCR_S18R;
742 749
743 /* 750 /*
@@ -748,7 +755,6 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr)
748 if (max_current > 150) 755 if (max_current > 150)
749 ocr |= SD_OCR_XPC; 756 ocr |= SD_OCR_XPC;
750 757
751try_again:
752 err = mmc_send_app_op_cond(host, ocr, rocr); 758 err = mmc_send_app_op_cond(host, ocr, rocr);
753 if (err) 759 if (err)
754 return err; 760 return err;
@@ -759,9 +765,12 @@ try_again:
759 */ 765 */
760 if (!mmc_host_is_spi(host) && rocr && 766 if (!mmc_host_is_spi(host) && rocr &&
761 ((*rocr & 0x41000000) == 0x41000000)) { 767 ((*rocr & 0x41000000) == 0x41000000)) {
762 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, true); 768 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);
763 if (err) { 769 if (err == -EAGAIN) {
764 ocr &= ~SD_OCR_S18R; 770 retries--;
771 goto try_again;
772 } else if (err) {
773 retries = 0;
765 goto try_again; 774 goto try_again;
766 } 775 }
767 } 776 }
@@ -960,16 +969,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
960 969
961 /* Card is an ultra-high-speed card */ 970 /* Card is an ultra-high-speed card */
962 mmc_card_set_uhs(card); 971 mmc_card_set_uhs(card);
963
964 /*
965 * Since initialization is now complete, enable preset
966 * value registers for UHS-I cards.
967 */
968 if (host->ops->enable_preset_value) {
969 mmc_host_clk_hold(card->host);
970 host->ops->enable_preset_value(host, true);
971 mmc_host_clk_release(card->host);
972 }
973 } else { 972 } else {
974 /* 973 /*
975 * Attempt to change to high-speed (if supported) 974 * Attempt to change to high-speed (if supported)
@@ -1148,13 +1147,6 @@ int mmc_attach_sd(struct mmc_host *host)
1148 BUG_ON(!host); 1147 BUG_ON(!host);
1149 WARN_ON(!host->claimed); 1148 WARN_ON(!host->claimed);
1150 1149
1151 /* Disable preset value enable if already set since last time */
1152 if (host->ops->enable_preset_value) {
1153 mmc_host_clk_hold(host);
1154 host->ops->enable_preset_value(host, false);
1155 mmc_host_clk_release(host);
1156 }
1157
1158 err = mmc_send_app_op_cond(host, 0, &ocr); 1150 err = mmc_send_app_op_cond(host, 0, &ocr);
1159 if (err) 1151 if (err)
1160 return err; 1152 return err;