aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r--drivers/mmc/core/core.c52
-rw-r--r--drivers/mmc/core/host.c4
-rw-r--r--drivers/mmc/core/host.h21
-rw-r--r--drivers/mmc/core/mmc.c29
-rw-r--r--drivers/mmc/core/sd.c30
-rw-r--r--drivers/mmc/core/sdio.c15
-rw-r--r--drivers/mmc/core/sdio_irq.c10
7 files changed, 105 insertions, 56 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index f545a3e6eb80..132378b89d76 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -290,8 +290,11 @@ static void mmc_wait_for_req_done(struct mmc_host *host,
290static void mmc_pre_req(struct mmc_host *host, struct mmc_request *mrq, 290static void mmc_pre_req(struct mmc_host *host, struct mmc_request *mrq,
291 bool is_first_req) 291 bool is_first_req)
292{ 292{
293 if (host->ops->pre_req) 293 if (host->ops->pre_req) {
294 mmc_host_clk_hold(host);
294 host->ops->pre_req(host, mrq, is_first_req); 295 host->ops->pre_req(host, mrq, is_first_req);
296 mmc_host_clk_release(host);
297 }
295} 298}
296 299
297/** 300/**
@@ -306,8 +309,11 @@ static void mmc_pre_req(struct mmc_host *host, struct mmc_request *mrq,
306static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, 309static void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq,
307 int err) 310 int err)
308{ 311{
309 if (host->ops->post_req) 312 if (host->ops->post_req) {
313 mmc_host_clk_hold(host);
310 host->ops->post_req(host, mrq, err); 314 host->ops->post_req(host, mrq, err);
315 mmc_host_clk_release(host);
316 }
311} 317}
312 318
313/** 319/**
@@ -620,7 +626,9 @@ int mmc_host_enable(struct mmc_host *host)
620 int err; 626 int err;
621 627
622 host->en_dis_recurs = 1; 628 host->en_dis_recurs = 1;
629 mmc_host_clk_hold(host);
623 err = host->ops->enable(host); 630 err = host->ops->enable(host);
631 mmc_host_clk_release(host);
624 host->en_dis_recurs = 0; 632 host->en_dis_recurs = 0;
625 633
626 if (err) { 634 if (err) {
@@ -640,7 +648,9 @@ static int mmc_host_do_disable(struct mmc_host *host, int lazy)
640 int err; 648 int err;
641 649
642 host->en_dis_recurs = 1; 650 host->en_dis_recurs = 1;
651 mmc_host_clk_hold(host);
643 err = host->ops->disable(host, lazy); 652 err = host->ops->disable(host, lazy);
653 mmc_host_clk_release(host);
644 host->en_dis_recurs = 0; 654 host->en_dis_recurs = 0;
645 655
646 if (err < 0) { 656 if (err < 0) {
@@ -1121,6 +1131,10 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
1121 * might not allow this operation 1131 * might not allow this operation
1122 */ 1132 */
1123 voltage = regulator_get_voltage(supply); 1133 voltage = regulator_get_voltage(supply);
1134
1135 if (mmc->caps2 & MMC_CAP2_BROKEN_VOLTAGE)
1136 min_uV = max_uV = voltage;
1137
1124 if (voltage < 0) 1138 if (voltage < 0)
1125 result = voltage; 1139 result = voltage;
1126 else if (voltage < min_uV || voltage > max_uV) 1140 else if (voltage < min_uV || voltage > max_uV)
@@ -1203,8 +1217,11 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11
1203 1217
1204 host->ios.signal_voltage = signal_voltage; 1218 host->ios.signal_voltage = signal_voltage;
1205 1219
1206 if (host->ops->start_signal_voltage_switch) 1220 if (host->ops->start_signal_voltage_switch) {
1221 mmc_host_clk_hold(host);
1207 err = host->ops->start_signal_voltage_switch(host, &host->ios); 1222 err = host->ops->start_signal_voltage_switch(host, &host->ios);
1223 mmc_host_clk_release(host);
1224 }
1208 1225
1209 return err; 1226 return err;
1210} 1227}
@@ -1239,6 +1256,7 @@ static void mmc_poweroff_notify(struct mmc_host *host)
1239 int err = 0; 1256 int err = 0;
1240 1257
1241 card = host->card; 1258 card = host->card;
1259 mmc_claim_host(host);
1242 1260
1243 /* 1261 /*
1244 * Send power notify command only if card 1262 * Send power notify command only if card
@@ -1269,6 +1287,7 @@ static void mmc_poweroff_notify(struct mmc_host *host)
1269 /* Set the card state to no notification after the poweroff */ 1287 /* Set the card state to no notification after the poweroff */
1270 card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION; 1288 card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION;
1271 } 1289 }
1290 mmc_release_host(host);
1272} 1291}
1273 1292
1274/* 1293/*
@@ -1327,12 +1346,28 @@ static void mmc_power_up(struct mmc_host *host)
1327 1346
1328void mmc_power_off(struct mmc_host *host) 1347void mmc_power_off(struct mmc_host *host)
1329{ 1348{
1349 int err = 0;
1330 mmc_host_clk_hold(host); 1350 mmc_host_clk_hold(host);
1331 1351
1332 host->ios.clock = 0; 1352 host->ios.clock = 0;
1333 host->ios.vdd = 0; 1353 host->ios.vdd = 0;
1334 1354
1335 mmc_poweroff_notify(host); 1355 /*
1356 * For eMMC 4.5 device send AWAKE command before
1357 * POWER_OFF_NOTIFY command, because in sleep state
1358 * eMMC 4.5 devices respond to only RESET and AWAKE cmd
1359 */
1360 if (host->card && mmc_card_is_sleep(host->card) &&
1361 host->bus_ops->resume) {
1362 err = host->bus_ops->resume(host);
1363
1364 if (!err)
1365 mmc_poweroff_notify(host);
1366 else
1367 pr_warning("%s: error %d during resume "
1368 "(continue with poweroff sequence)\n",
1369 mmc_hostname(host), err);
1370 }
1336 1371
1337 /* 1372 /*
1338 * Reset ocr mask to be the highest possible voltage supported for 1373 * Reset ocr mask to be the highest possible voltage supported for
@@ -2033,6 +2068,9 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
2033 */ 2068 */
2034 mmc_hw_reset_for_init(host); 2069 mmc_hw_reset_for_init(host);
2035 2070
2071 /* Initialization should be done at 3.3 V I/O voltage. */
2072 mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);
2073
2036 /* 2074 /*
2037 * sdio_reset sends CMD52 to reset card. Since we do not know 2075 * sdio_reset sends CMD52 to reset card. Since we do not know
2038 * if the card is being re-initialized, just send it. CMD52 2076 * if the card is being re-initialized, just send it. CMD52
@@ -2386,12 +2424,6 @@ int mmc_suspend_host(struct mmc_host *host)
2386 */ 2424 */
2387 if (mmc_try_claim_host(host)) { 2425 if (mmc_try_claim_host(host)) {
2388 if (host->bus_ops->suspend) { 2426 if (host->bus_ops->suspend) {
2389 /*
2390 * For eMMC 4.5 device send notify command
2391 * before sleep, because in sleep state eMMC 4.5
2392 * devices respond to only RESET and AWAKE cmd
2393 */
2394 mmc_poweroff_notify(host);
2395 err = host->bus_ops->suspend(host); 2427 err = host->bus_ops->suspend(host);
2396 } 2428 }
2397 mmc_do_release_host(host); 2429 mmc_do_release_host(host);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 30055f2b0d44..c3704e293a7b 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -238,10 +238,10 @@ static inline void mmc_host_clk_init(struct mmc_host *host)
238 /* Hold MCI clock for 8 cycles by default */ 238 /* Hold MCI clock for 8 cycles by default */
239 host->clk_delay = 8; 239 host->clk_delay = 8;
240 /* 240 /*
241 * Default clock gating delay is 200ms. 241 * Default clock gating delay is 0ms to avoid wasting power.
242 * This value can be tuned by writing into sysfs entry. 242 * This value can be tuned by writing into sysfs entry.
243 */ 243 */
244 host->clkgate_delay = 200; 244 host->clkgate_delay = 0;
245 host->clk_gated = false; 245 host->clk_gated = false;
246 INIT_DELAYED_WORK(&host->clk_gate_work, mmc_host_clk_gate_work); 246 INIT_DELAYED_WORK(&host->clk_gate_work, mmc_host_clk_gate_work);
247 spin_lock_init(&host->clk_lock); 247 spin_lock_init(&host->clk_lock);
diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h
index fb8a5cd2e4a1..08a7852ade44 100644
--- a/drivers/mmc/core/host.h
+++ b/drivers/mmc/core/host.h
@@ -14,27 +14,6 @@
14 14
15int mmc_register_host_class(void); 15int mmc_register_host_class(void);
16void mmc_unregister_host_class(void); 16void mmc_unregister_host_class(void);
17
18#ifdef CONFIG_MMC_CLKGATE
19void mmc_host_clk_hold(struct mmc_host *host);
20void mmc_host_clk_release(struct mmc_host *host);
21unsigned int mmc_host_clk_rate(struct mmc_host *host);
22
23#else
24static inline void mmc_host_clk_hold(struct mmc_host *host)
25{
26}
27
28static inline void mmc_host_clk_release(struct mmc_host *host)
29{
30}
31
32static inline unsigned int mmc_host_clk_rate(struct mmc_host *host)
33{
34 return host->ios.clock;
35}
36#endif
37
38void mmc_host_deeper_disable(struct work_struct *work); 17void mmc_host_deeper_disable(struct work_struct *work);
39 18
40#endif 19#endif
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 59b9ba52e66a..2b9ed1401dc4 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -376,7 +376,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
376 } 376 }
377 377
378 card->ext_csd.raw_hc_erase_gap_size = 378 card->ext_csd.raw_hc_erase_gap_size =
379 ext_csd[EXT_CSD_PARTITION_ATTRIBUTE]; 379 ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
380 card->ext_csd.raw_sec_trim_mult = 380 card->ext_csd.raw_sec_trim_mult =
381 ext_csd[EXT_CSD_SEC_TRIM_MULT]; 381 ext_csd[EXT_CSD_SEC_TRIM_MULT];
382 card->ext_csd.raw_sec_erase_mult = 382 card->ext_csd.raw_sec_erase_mult =
@@ -551,7 +551,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)
551 goto out; 551 goto out;
552 552
553 /* only compare read only fields */ 553 /* only compare read only fields */
554 err = (!(card->ext_csd.raw_partition_support == 554 err = !((card->ext_csd.raw_partition_support ==
555 bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) && 555 bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) &&
556 (card->ext_csd.raw_erased_mem_count == 556 (card->ext_csd.raw_erased_mem_count ==
557 bw_ext_csd[EXT_CSD_ERASED_MEM_CONT]) && 557 bw_ext_csd[EXT_CSD_ERASED_MEM_CONT]) &&
@@ -816,6 +816,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
816 if (!mmc_host_is_spi(host)) 816 if (!mmc_host_is_spi(host))
817 mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN); 817 mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN);
818 818
819 /* Initialization should be done at 3.3 V I/O voltage. */
820 mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);
821
819 /* 822 /*
820 * Since we're changing the OCR value, we seem to 823 * Since we're changing the OCR value, we seem to
821 * need to tell some cards to go back to the idle 824 * need to tell some cards to go back to the idle
@@ -1006,7 +1009,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1006 err = mmc_select_hs200(card); 1009 err = mmc_select_hs200(card);
1007 else if (host->caps & MMC_CAP_MMC_HIGHSPEED) 1010 else if (host->caps & MMC_CAP_MMC_HIGHSPEED)
1008 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1011 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1009 EXT_CSD_HS_TIMING, 1, 0); 1012 EXT_CSD_HS_TIMING, 1,
1013 card->ext_csd.generic_cmd6_time);
1010 1014
1011 if (err && err != -EBADMSG) 1015 if (err && err != -EBADMSG)
1012 goto free_card; 1016 goto free_card;
@@ -1116,7 +1120,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1116 * Activate wide bus and DDR (if supported). 1120 * Activate wide bus and DDR (if supported).
1117 */ 1121 */
1118 if (!mmc_card_hs200(card) && 1122 if (!mmc_card_hs200(card) &&
1119 (card->csd.mmca_vsn >= CSD_SPEC_VER_3) && 1123 (card->csd.mmca_vsn >= CSD_SPEC_VER_4) &&
1120 (host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) { 1124 (host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) {
1121 static unsigned ext_csd_bits[][2] = { 1125 static unsigned ext_csd_bits[][2] = {
1122 { EXT_CSD_BUS_WIDTH_8, EXT_CSD_DDR_BUS_WIDTH_8 }, 1126 { EXT_CSD_BUS_WIDTH_8, EXT_CSD_DDR_BUS_WIDTH_8 },
@@ -1315,11 +1319,13 @@ static int mmc_suspend(struct mmc_host *host)
1315 BUG_ON(!host->card); 1319 BUG_ON(!host->card);
1316 1320
1317 mmc_claim_host(host); 1321 mmc_claim_host(host);
1318 if (mmc_card_can_sleep(host)) 1322 if (mmc_card_can_sleep(host)) {
1319 err = mmc_card_sleep(host); 1323 err = mmc_card_sleep(host);
1320 else if (!mmc_host_is_spi(host)) 1324 if (!err)
1325 mmc_card_set_sleep(host->card);
1326 } else if (!mmc_host_is_spi(host))
1321 mmc_deselect_cards(host); 1327 mmc_deselect_cards(host);
1322 host->card->state &= ~MMC_STATE_HIGHSPEED; 1328 host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
1323 mmc_release_host(host); 1329 mmc_release_host(host);
1324 1330
1325 return err; 1331 return err;
@@ -1339,7 +1345,11 @@ static int mmc_resume(struct mmc_host *host)
1339 BUG_ON(!host->card); 1345 BUG_ON(!host->card);
1340 1346
1341 mmc_claim_host(host); 1347 mmc_claim_host(host);
1342 err = mmc_init_card(host, host->ocr, host->card); 1348 if (mmc_card_is_sleep(host->card)) {
1349 err = mmc_card_awake(host);
1350 mmc_card_clr_sleep(host->card);
1351 } else
1352 err = mmc_init_card(host, host->ocr, host->card);
1343 mmc_release_host(host); 1353 mmc_release_host(host);
1344 1354
1345 return err; 1355 return err;
@@ -1349,7 +1359,8 @@ static int mmc_power_restore(struct mmc_host *host)
1349{ 1359{
1350 int ret; 1360 int ret;
1351 1361
1352 host->card->state &= ~MMC_STATE_HIGHSPEED; 1362 host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
1363 mmc_card_clr_sleep(host->card);
1353 mmc_claim_host(host); 1364 mmc_claim_host(host);
1354 ret = mmc_init_card(host, host->ocr, host->card); 1365 ret = mmc_init_card(host, host->ocr, host->card);
1355 mmc_release_host(host); 1366 mmc_release_host(host);
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index c63ad03c29c7..c272c6868ecf 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 "
@@ -903,6 +911,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
903 BUG_ON(!host); 911 BUG_ON(!host);
904 WARN_ON(!host->claimed); 912 WARN_ON(!host->claimed);
905 913
914 /* The initialization should be done at 3.3 V I/O voltage. */
915 mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);
916
906 err = mmc_sd_get_cid(host, ocr, cid, &rocr); 917 err = mmc_sd_get_cid(host, ocr, cid, &rocr);
907 if (err) 918 if (err)
908 return err; 919 return err;
@@ -967,8 +978,11 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
967 * Since initialization is now complete, enable preset 978 * Since initialization is now complete, enable preset
968 * value registers for UHS-I cards. 979 * value registers for UHS-I cards.
969 */ 980 */
970 if (host->ops->enable_preset_value) 981 if (host->ops->enable_preset_value) {
982 mmc_host_clk_hold(card->host);
971 host->ops->enable_preset_value(host, true); 983 host->ops->enable_preset_value(host, true);
984 mmc_host_clk_release(card->host);
985 }
972 } else { 986 } else {
973 /* 987 /*
974 * Attempt to change to high-speed (if supported) 988 * Attempt to change to high-speed (if supported)
@@ -1145,14 +1159,12 @@ int mmc_attach_sd(struct mmc_host *host)
1145 BUG_ON(!host); 1159 BUG_ON(!host);
1146 WARN_ON(!host->claimed); 1160 WARN_ON(!host->claimed);
1147 1161
1148 /* Make sure we are at 3.3V signalling voltage */
1149 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, false);
1150 if (err)
1151 return err;
1152
1153 /* Disable preset value enable if already set since last time */ 1162 /* Disable preset value enable if already set since last time */
1154 if (host->ops->enable_preset_value) 1163 if (host->ops->enable_preset_value) {
1164 mmc_host_clk_hold(host);
1155 host->ops->enable_preset_value(host, false); 1165 host->ops->enable_preset_value(host, false);
1166 mmc_host_clk_release(host);
1167 }
1156 1168
1157 err = mmc_send_app_op_cond(host, 0, &ocr); 1169 err = mmc_send_app_op_cond(host, 0, &ocr);
1158 if (err) 1170 if (err)
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index bd7bacc950dc..2c7c83f832d2 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -98,10 +98,11 @@ fail:
98 return ret; 98 return ret;
99} 99}
100 100
101static int sdio_read_cccr(struct mmc_card *card) 101static int sdio_read_cccr(struct mmc_card *card, u32 ocr)
102{ 102{
103 int ret; 103 int ret;
104 int cccr_vsn; 104 int cccr_vsn;
105 int uhs = ocr & R4_18V_PRESENT;
105 unsigned char data; 106 unsigned char data;
106 unsigned char speed; 107 unsigned char speed;
107 108
@@ -149,7 +150,7 @@ static int sdio_read_cccr(struct mmc_card *card)
149 card->scr.sda_spec3 = 0; 150 card->scr.sda_spec3 = 0;
150 card->sw_caps.sd3_bus_mode = 0; 151 card->sw_caps.sd3_bus_mode = 0;
151 card->sw_caps.sd3_drv_type = 0; 152 card->sw_caps.sd3_drv_type = 0;
152 if (cccr_vsn >= SDIO_CCCR_REV_3_00) { 153 if (cccr_vsn >= SDIO_CCCR_REV_3_00 && uhs) {
153 card->scr.sda_spec3 = 1; 154 card->scr.sda_spec3 = 1;
154 ret = mmc_io_rw_direct(card, 0, 0, 155 ret = mmc_io_rw_direct(card, 0, 0,
155 SDIO_CCCR_UHS, 0, &data); 156 SDIO_CCCR_UHS, 0, &data);
@@ -584,6 +585,9 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
584 * Inform the card of the voltage 585 * Inform the card of the voltage
585 */ 586 */
586 if (!powered_resume) { 587 if (!powered_resume) {
588 /* The initialization should be done at 3.3 V I/O voltage. */
589 mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);
590
587 err = mmc_send_io_op_cond(host, host->ocr, &ocr); 591 err = mmc_send_io_op_cond(host, host->ocr, &ocr);
588 if (err) 592 if (err)
589 goto err; 593 goto err;
@@ -712,7 +716,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
712 /* 716 /*
713 * Read the common registers. 717 * Read the common registers.
714 */ 718 */
715 err = sdio_read_cccr(card); 719 err = sdio_read_cccr(card, ocr);
716 if (err) 720 if (err)
717 goto remove; 721 goto remove;
718 722
@@ -995,6 +999,11 @@ static int mmc_sdio_power_restore(struct mmc_host *host)
995 * With these steps taken, mmc_select_voltage() is also required to 999 * With these steps taken, mmc_select_voltage() is also required to
996 * restore the correct voltage setting of the card. 1000 * restore the correct voltage setting of the card.
997 */ 1001 */
1002
1003 /* The initialization should be done at 3.3 V I/O voltage. */
1004 if (!mmc_card_keep_power(host))
1005 mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);
1006
998 sdio_reset(host); 1007 sdio_reset(host);
999 mmc_go_idle(host); 1008 mmc_go_idle(host);
1000 mmc_send_if_cond(host, host->ocr_avail); 1009 mmc_send_if_cond(host, host->ocr_avail);
diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
index 68f81b9ee0fb..f573e7f9f740 100644
--- a/drivers/mmc/core/sdio_irq.c
+++ b/drivers/mmc/core/sdio_irq.c
@@ -146,15 +146,21 @@ static int sdio_irq_thread(void *_host)
146 } 146 }
147 147
148 set_current_state(TASK_INTERRUPTIBLE); 148 set_current_state(TASK_INTERRUPTIBLE);
149 if (host->caps & MMC_CAP_SDIO_IRQ) 149 if (host->caps & MMC_CAP_SDIO_IRQ) {
150 mmc_host_clk_hold(host);
150 host->ops->enable_sdio_irq(host, 1); 151 host->ops->enable_sdio_irq(host, 1);
152 mmc_host_clk_release(host);
153 }
151 if (!kthread_should_stop()) 154 if (!kthread_should_stop())
152 schedule_timeout(period); 155 schedule_timeout(period);
153 set_current_state(TASK_RUNNING); 156 set_current_state(TASK_RUNNING);
154 } while (!kthread_should_stop()); 157 } while (!kthread_should_stop());
155 158
156 if (host->caps & MMC_CAP_SDIO_IRQ) 159 if (host->caps & MMC_CAP_SDIO_IRQ) {
160 mmc_host_clk_hold(host);
157 host->ops->enable_sdio_irq(host, 0); 161 host->ops->enable_sdio_irq(host, 0);
162 mmc_host_clk_release(host);
163 }
158 164
159 pr_debug("%s: IRQ thread exiting with code %d\n", 165 pr_debug("%s: IRQ thread exiting with code %d\n",
160 mmc_hostname(host), ret); 166 mmc_hostname(host), ret);