aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sdhci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/sdhci.c')
-rw-r--r--drivers/mmc/host/sdhci.c150
1 files changed, 99 insertions, 51 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 19ed580f2cab..8d66706824a6 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -49,7 +49,7 @@ static void sdhci_finish_data(struct sdhci_host *);
49 49
50static void sdhci_send_command(struct sdhci_host *, struct mmc_command *); 50static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
51static void sdhci_finish_command(struct sdhci_host *); 51static void sdhci_finish_command(struct sdhci_host *);
52static int sdhci_execute_tuning(struct mmc_host *mmc); 52static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
53static void sdhci_tuning_timer(unsigned long data); 53static void sdhci_tuning_timer(unsigned long data);
54 54
55#ifdef CONFIG_PM_RUNTIME 55#ifdef CONFIG_PM_RUNTIME
@@ -146,10 +146,8 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
146{ 146{
147 u32 present, irqs; 147 u32 present, irqs;
148 148
149 if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) 149 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
150 return; 150 !mmc_card_is_removable(host->mmc))
151
152 if (host->quirks2 & SDHCI_QUIRK2_OWN_CARD_DETECTION)
153 return; 151 return;
154 152
155 present = sdhci_readl(host, SDHCI_PRESENT_STATE) & 153 present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
@@ -214,6 +212,11 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
214 212
215 if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET) 213 if (host->quirks & SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)
216 sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier); 214 sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier);
215
216 if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) {
217 if ((host->ops->enable_dma) && (mask & SDHCI_RESET_ALL))
218 host->ops->enable_dma(host);
219 }
217} 220}
218 221
219static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); 222static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
@@ -423,12 +426,12 @@ static void sdhci_transfer_pio(struct sdhci_host *host)
423static char *sdhci_kmap_atomic(struct scatterlist *sg, unsigned long *flags) 426static char *sdhci_kmap_atomic(struct scatterlist *sg, unsigned long *flags)
424{ 427{
425 local_irq_save(*flags); 428 local_irq_save(*flags);
426 return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; 429 return kmap_atomic(sg_page(sg)) + sg->offset;
427} 430}
428 431
429static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) 432static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags)
430{ 433{
431 kunmap_atomic(buffer, KM_BIO_SRC_IRQ); 434 kunmap_atomic(buffer);
432 local_irq_restore(*flags); 435 local_irq_restore(*flags);
433} 436}
434 437
@@ -1016,7 +1019,8 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
1016 flags |= SDHCI_CMD_INDEX; 1019 flags |= SDHCI_CMD_INDEX;
1017 1020
1018 /* CMD19 is special in that the Data Present Select should be set */ 1021 /* CMD19 is special in that the Data Present Select should be set */
1019 if (cmd->data || (cmd->opcode == MMC_SEND_TUNING_BLOCK)) 1022 if (cmd->data || cmd->opcode == MMC_SEND_TUNING_BLOCK ||
1023 cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200)
1020 flags |= SDHCI_CMD_DATA; 1024 flags |= SDHCI_CMD_DATA;
1021 1025
1022 sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND); 1026 sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
@@ -1066,12 +1070,15 @@ static void sdhci_finish_command(struct sdhci_host *host)
1066static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 1070static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
1067{ 1071{
1068 int div = 0; /* Initialized for compiler warning */ 1072 int div = 0; /* Initialized for compiler warning */
1073 int real_div = div, clk_mul = 1;
1069 u16 clk = 0; 1074 u16 clk = 0;
1070 unsigned long timeout; 1075 unsigned long timeout;
1071 1076
1072 if (clock == host->clock) 1077 if (clock && clock == host->clock)
1073 return; 1078 return;
1074 1079
1080 host->mmc->actual_clock = 0;
1081
1075 if (host->ops->set_clock) { 1082 if (host->ops->set_clock) {
1076 host->ops->set_clock(host, clock); 1083 host->ops->set_clock(host, clock);
1077 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) 1084 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK)
@@ -1109,6 +1116,8 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
1109 * Control register. 1116 * Control register.
1110 */ 1117 */
1111 clk = SDHCI_PROG_CLOCK_MODE; 1118 clk = SDHCI_PROG_CLOCK_MODE;
1119 real_div = div;
1120 clk_mul = host->clk_mul;
1112 div--; 1121 div--;
1113 } 1122 }
1114 } else { 1123 } else {
@@ -1122,6 +1131,7 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
1122 break; 1131 break;
1123 } 1132 }
1124 } 1133 }
1134 real_div = div;
1125 div >>= 1; 1135 div >>= 1;
1126 } 1136 }
1127 } else { 1137 } else {
@@ -1130,9 +1140,13 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
1130 if ((host->max_clk / div) <= clock) 1140 if ((host->max_clk / div) <= clock)
1131 break; 1141 break;
1132 } 1142 }
1143 real_div = div;
1133 div >>= 1; 1144 div >>= 1;
1134 } 1145 }
1135 1146
1147 if (real_div)
1148 host->mmc->actual_clock = (host->max_clk * clk_mul) / real_div;
1149
1136 clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT; 1150 clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT;
1137 clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN) 1151 clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN)
1138 << SDHCI_DIVIDER_HI_SHIFT; 1152 << SDHCI_DIVIDER_HI_SHIFT;
@@ -1160,7 +1174,7 @@ out:
1160 host->clock = clock; 1174 host->clock = clock;
1161} 1175}
1162 1176
1163static void sdhci_set_power(struct sdhci_host *host, unsigned short power) 1177static int sdhci_set_power(struct sdhci_host *host, unsigned short power)
1164{ 1178{
1165 u8 pwr = 0; 1179 u8 pwr = 0;
1166 1180
@@ -1183,13 +1197,13 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
1183 } 1197 }
1184 1198
1185 if (host->pwr == pwr) 1199 if (host->pwr == pwr)
1186 return; 1200 return -1;
1187 1201
1188 host->pwr = pwr; 1202 host->pwr = pwr;
1189 1203
1190 if (pwr == 0) { 1204 if (pwr == 0) {
1191 sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); 1205 sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
1192 return; 1206 return 0;
1193 } 1207 }
1194 1208
1195 /* 1209 /*
@@ -1216,6 +1230,8 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
1216 */ 1230 */
1217 if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER) 1231 if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER)
1218 mdelay(10); 1232 mdelay(10);
1233
1234 return power;
1219} 1235}
1220 1236
1221/*****************************************************************************\ 1237/*****************************************************************************\
@@ -1277,7 +1293,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1277 if ((host->flags & SDHCI_NEEDS_RETUNING) && 1293 if ((host->flags & SDHCI_NEEDS_RETUNING) &&
1278 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) { 1294 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
1279 spin_unlock_irqrestore(&host->lock, flags); 1295 spin_unlock_irqrestore(&host->lock, flags);
1280 sdhci_execute_tuning(mmc); 1296 sdhci_execute_tuning(mmc, mrq->cmd->opcode);
1281 spin_lock_irqsave(&host->lock, flags); 1297 spin_lock_irqsave(&host->lock, flags);
1282 1298
1283 /* Restore original mmc_request structure */ 1299 /* Restore original mmc_request structure */
@@ -1297,12 +1313,17 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1297static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) 1313static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
1298{ 1314{
1299 unsigned long flags; 1315 unsigned long flags;
1316 int vdd_bit = -1;
1300 u8 ctrl; 1317 u8 ctrl;
1301 1318
1302 spin_lock_irqsave(&host->lock, flags); 1319 spin_lock_irqsave(&host->lock, flags);
1303 1320
1304 if (host->flags & SDHCI_DEVICE_DEAD) 1321 if (host->flags & SDHCI_DEVICE_DEAD) {
1305 goto out; 1322 spin_unlock_irqrestore(&host->lock, flags);
1323 if (host->vmmc && ios->power_mode == MMC_POWER_OFF)
1324 mmc_regulator_set_ocr(host->mmc, host->vmmc, 0);
1325 return;
1326 }
1306 1327
1307 /* 1328 /*
1308 * Reset the chip on each power off. 1329 * Reset the chip on each power off.
@@ -1316,9 +1337,15 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
1316 sdhci_set_clock(host, ios->clock); 1337 sdhci_set_clock(host, ios->clock);
1317 1338
1318 if (ios->power_mode == MMC_POWER_OFF) 1339 if (ios->power_mode == MMC_POWER_OFF)
1319 sdhci_set_power(host, -1); 1340 vdd_bit = sdhci_set_power(host, -1);
1320 else 1341 else
1321 sdhci_set_power(host, ios->vdd); 1342 vdd_bit = sdhci_set_power(host, ios->vdd);
1343
1344 if (host->vmmc && vdd_bit != -1) {
1345 spin_unlock_irqrestore(&host->lock, flags);
1346 mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd_bit);
1347 spin_lock_irqsave(&host->lock, flags);
1348 }
1322 1349
1323 if (host->ops->platform_send_init_74_clocks) 1350 if (host->ops->platform_send_init_74_clocks)
1324 host->ops->platform_send_init_74_clocks(host, ios->power_mode); 1351 host->ops->platform_send_init_74_clocks(host, ios->power_mode);
@@ -1361,11 +1388,11 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
1361 unsigned int clock; 1388 unsigned int clock;
1362 1389
1363 /* In case of UHS-I modes, set High Speed Enable */ 1390 /* In case of UHS-I modes, set High Speed Enable */
1364 if ((ios->timing == MMC_TIMING_UHS_SDR50) || 1391 if ((ios->timing == MMC_TIMING_MMC_HS200) ||
1392 (ios->timing == MMC_TIMING_UHS_SDR50) ||
1365 (ios->timing == MMC_TIMING_UHS_SDR104) || 1393 (ios->timing == MMC_TIMING_UHS_SDR104) ||
1366 (ios->timing == MMC_TIMING_UHS_DDR50) || 1394 (ios->timing == MMC_TIMING_UHS_DDR50) ||
1367 (ios->timing == MMC_TIMING_UHS_SDR25) || 1395 (ios->timing == MMC_TIMING_UHS_SDR25))
1368 (ios->timing == MMC_TIMING_UHS_SDR12))
1369 ctrl |= SDHCI_CTRL_HISPD; 1396 ctrl |= SDHCI_CTRL_HISPD;
1370 1397
1371 ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); 1398 ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
@@ -1415,7 +1442,9 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
1415 ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); 1442 ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
1416 /* Select Bus Speed Mode for host */ 1443 /* Select Bus Speed Mode for host */
1417 ctrl_2 &= ~SDHCI_CTRL_UHS_MASK; 1444 ctrl_2 &= ~SDHCI_CTRL_UHS_MASK;
1418 if (ios->timing == MMC_TIMING_UHS_SDR12) 1445 if (ios->timing == MMC_TIMING_MMC_HS200)
1446 ctrl_2 |= SDHCI_CTRL_HS_SDR200;
1447 else if (ios->timing == MMC_TIMING_UHS_SDR12)
1419 ctrl_2 |= SDHCI_CTRL_UHS_SDR12; 1448 ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
1420 else if (ios->timing == MMC_TIMING_UHS_SDR25) 1449 else if (ios->timing == MMC_TIMING_UHS_SDR25)
1421 ctrl_2 |= SDHCI_CTRL_UHS_SDR25; 1450 ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
@@ -1443,7 +1472,6 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
1443 if(host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS) 1472 if(host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
1444 sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); 1473 sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
1445 1474
1446out:
1447 mmiowb(); 1475 mmiowb();
1448 spin_unlock_irqrestore(&host->lock, flags); 1476 spin_unlock_irqrestore(&host->lock, flags);
1449} 1477}
@@ -1663,7 +1691,7 @@ static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
1663 return err; 1691 return err;
1664} 1692}
1665 1693
1666static int sdhci_execute_tuning(struct mmc_host *mmc) 1694static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
1667{ 1695{
1668 struct sdhci_host *host; 1696 struct sdhci_host *host;
1669 u16 ctrl; 1697 u16 ctrl;
@@ -1671,6 +1699,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
1671 int tuning_loop_counter = MAX_TUNING_LOOP; 1699 int tuning_loop_counter = MAX_TUNING_LOOP;
1672 unsigned long timeout; 1700 unsigned long timeout;
1673 int err = 0; 1701 int err = 0;
1702 bool requires_tuning_nonuhs = false;
1674 1703
1675 host = mmc_priv(mmc); 1704 host = mmc_priv(mmc);
1676 1705
@@ -1681,13 +1710,19 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
1681 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); 1710 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
1682 1711
1683 /* 1712 /*
1684 * Host Controller needs tuning only in case of SDR104 mode 1713 * The Host Controller needs tuning only in case of SDR104 mode
1685 * and for SDR50 mode when Use Tuning for SDR50 is set in 1714 * and for SDR50 mode when Use Tuning for SDR50 is set in the
1686 * Capabilities register. 1715 * Capabilities register.
1716 * If the Host Controller supports the HS200 mode then the
1717 * tuning function has to be executed.
1687 */ 1718 */
1719 if (((ctrl & SDHCI_CTRL_UHS_MASK) == SDHCI_CTRL_UHS_SDR50) &&
1720 (host->flags & SDHCI_SDR50_NEEDS_TUNING ||
1721 host->flags & SDHCI_HS200_NEEDS_TUNING))
1722 requires_tuning_nonuhs = true;
1723
1688 if (((ctrl & SDHCI_CTRL_UHS_MASK) == SDHCI_CTRL_UHS_SDR104) || 1724 if (((ctrl & SDHCI_CTRL_UHS_MASK) == SDHCI_CTRL_UHS_SDR104) ||
1689 (((ctrl & SDHCI_CTRL_UHS_MASK) == SDHCI_CTRL_UHS_SDR50) && 1725 requires_tuning_nonuhs)
1690 (host->flags & SDHCI_SDR50_NEEDS_TUNING)))
1691 ctrl |= SDHCI_CTRL_EXEC_TUNING; 1726 ctrl |= SDHCI_CTRL_EXEC_TUNING;
1692 else { 1727 else {
1693 spin_unlock(&host->lock); 1728 spin_unlock(&host->lock);
@@ -1723,7 +1758,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
1723 if (!tuning_loop_counter && !timeout) 1758 if (!tuning_loop_counter && !timeout)
1724 break; 1759 break;
1725 1760
1726 cmd.opcode = MMC_SEND_TUNING_BLOCK; 1761 cmd.opcode = opcode;
1727 cmd.arg = 0; 1762 cmd.arg = 0;
1728 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; 1763 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1729 cmd.retries = 0; 1764 cmd.retries = 0;
@@ -1738,7 +1773,17 @@ static int sdhci_execute_tuning(struct mmc_host *mmc)
1738 * block to the Host Controller. So we set the block size 1773 * block to the Host Controller. So we set the block size
1739 * to 64 here. 1774 * to 64 here.
1740 */ 1775 */
1741 sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, 64), SDHCI_BLOCK_SIZE); 1776 if (cmd.opcode == MMC_SEND_TUNING_BLOCK_HS200) {
1777 if (mmc->ios.bus_width == MMC_BUS_WIDTH_8)
1778 sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, 128),
1779 SDHCI_BLOCK_SIZE);
1780 else if (mmc->ios.bus_width == MMC_BUS_WIDTH_4)
1781 sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, 64),
1782 SDHCI_BLOCK_SIZE);
1783 } else {
1784 sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, 64),
1785 SDHCI_BLOCK_SIZE);
1786 }
1742 1787
1743 /* 1788 /*
1744 * The tuning block is sent by the card to the host controller. 1789 * The tuning block is sent by the card to the host controller.
@@ -2121,12 +2166,14 @@ static void sdhci_show_adma_error(struct sdhci_host *host) { }
2121 2166
2122static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) 2167static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
2123{ 2168{
2169 u32 command;
2124 BUG_ON(intmask == 0); 2170 BUG_ON(intmask == 0);
2125 2171
2126 /* CMD19 generates _only_ Buffer Read Ready interrupt */ 2172 /* CMD19 generates _only_ Buffer Read Ready interrupt */
2127 if (intmask & SDHCI_INT_DATA_AVAIL) { 2173 if (intmask & SDHCI_INT_DATA_AVAIL) {
2128 if (SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND)) == 2174 command = SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND));
2129 MMC_SEND_TUNING_BLOCK) { 2175 if (command == MMC_SEND_TUNING_BLOCK ||
2176 command == MMC_SEND_TUNING_BLOCK_HS200) {
2130 host->tuning_done = 1; 2177 host->tuning_done = 1;
2131 wake_up(&host->buf_ready_int); 2178 wake_up(&host->buf_ready_int);
2132 return; 2179 return;
@@ -2330,26 +2377,33 @@ out:
2330int sdhci_suspend_host(struct sdhci_host *host) 2377int sdhci_suspend_host(struct sdhci_host *host)
2331{ 2378{
2332 int ret; 2379 int ret;
2380 bool has_tuning_timer;
2333 2381
2334 sdhci_disable_card_detection(host); 2382 sdhci_disable_card_detection(host);
2335 2383
2336 /* Disable tuning since we are suspending */ 2384 /* Disable tuning since we are suspending */
2337 if (host->version >= SDHCI_SPEC_300 && host->tuning_count && 2385 has_tuning_timer = host->version >= SDHCI_SPEC_300 &&
2338 host->tuning_mode == SDHCI_TUNING_MODE_1) { 2386 host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1;
2387 if (has_tuning_timer) {
2388 del_timer_sync(&host->tuning_timer);
2339 host->flags &= ~SDHCI_NEEDS_RETUNING; 2389 host->flags &= ~SDHCI_NEEDS_RETUNING;
2340 mod_timer(&host->tuning_timer, jiffies +
2341 host->tuning_count * HZ);
2342 } 2390 }
2343 2391
2344 ret = mmc_suspend_host(host->mmc); 2392 ret = mmc_suspend_host(host->mmc);
2345 if (ret) 2393 if (ret) {
2394 if (has_tuning_timer) {
2395 host->flags |= SDHCI_NEEDS_RETUNING;
2396 mod_timer(&host->tuning_timer, jiffies +
2397 host->tuning_count * HZ);
2398 }
2399
2400 sdhci_enable_card_detection(host);
2401
2346 return ret; 2402 return ret;
2403 }
2347 2404
2348 free_irq(host->irq, host); 2405 free_irq(host->irq, host);
2349 2406
2350 if (host->vmmc)
2351 ret = regulator_disable(host->vmmc);
2352
2353 return ret; 2407 return ret;
2354} 2408}
2355 2409
@@ -2359,12 +2413,6 @@ int sdhci_resume_host(struct sdhci_host *host)
2359{ 2413{
2360 int ret; 2414 int ret;
2361 2415
2362 if (host->vmmc) {
2363 int ret = regulator_enable(host->vmmc);
2364 if (ret)
2365 return ret;
2366 }
2367
2368 if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { 2416 if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) {
2369 if (host->ops->enable_dma) 2417 if (host->ops->enable_dma)
2370 host->ops->enable_dma(host); 2418 host->ops->enable_dma(host);
@@ -2727,10 +2775,14 @@ int sdhci_add_host(struct sdhci_host *host)
2727 if (caps[1] & SDHCI_SUPPORT_DDR50) 2775 if (caps[1] & SDHCI_SUPPORT_DDR50)
2728 mmc->caps |= MMC_CAP_UHS_DDR50; 2776 mmc->caps |= MMC_CAP_UHS_DDR50;
2729 2777
2730 /* Does the host needs tuning for SDR50? */ 2778 /* Does the host need tuning for SDR50? */
2731 if (caps[1] & SDHCI_USE_SDR50_TUNING) 2779 if (caps[1] & SDHCI_USE_SDR50_TUNING)
2732 host->flags |= SDHCI_SDR50_NEEDS_TUNING; 2780 host->flags |= SDHCI_SDR50_NEEDS_TUNING;
2733 2781
2782 /* Does the host need tuning for HS200? */
2783 if (mmc->caps2 & MMC_CAP2_HS200)
2784 host->flags |= SDHCI_HS200_NEEDS_TUNING;
2785
2734 /* Driver Type(s) (A, C, D) supported by the host */ 2786 /* Driver Type(s) (A, C, D) supported by the host */
2735 if (caps[1] & SDHCI_DRIVER_TYPE_A) 2787 if (caps[1] & SDHCI_DRIVER_TYPE_A)
2736 mmc->caps |= MMC_CAP_DRIVER_TYPE_A; 2788 mmc->caps |= MMC_CAP_DRIVER_TYPE_A;
@@ -2926,8 +2978,6 @@ int sdhci_add_host(struct sdhci_host *host)
2926 if (IS_ERR(host->vmmc)) { 2978 if (IS_ERR(host->vmmc)) {
2927 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); 2979 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc));
2928 host->vmmc = NULL; 2980 host->vmmc = NULL;
2929 } else {
2930 regulator_enable(host->vmmc);
2931 } 2981 }
2932 2982
2933 sdhci_init(host, 0); 2983 sdhci_init(host, 0);
@@ -3016,10 +3066,8 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
3016 tasklet_kill(&host->card_tasklet); 3066 tasklet_kill(&host->card_tasklet);
3017 tasklet_kill(&host->finish_tasklet); 3067 tasklet_kill(&host->finish_tasklet);
3018 3068
3019 if (host->vmmc) { 3069 if (host->vmmc)
3020 regulator_disable(host->vmmc);
3021 regulator_put(host->vmmc); 3070 regulator_put(host->vmmc);
3022 }
3023 3071
3024 kfree(host->adma_desc); 3072 kfree(host->adma_desc);
3025 kfree(host->align_buffer); 3073 kfree(host->align_buffer);