diff options
author | Johan Rudholm <johan.rudholm@stericsson.com> | 2013-01-28 09:08:27 -0500 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-02-24 14:37:07 -0500 |
commit | 567c89032cfdda8047562abe450947ac01f2d3c7 (patch) | |
tree | 09bdcb03c610055c9c1b69220948619d62934142 | |
parent | d887874e0ead6a0b86b6046b872730c81c121352 (diff) |
mmc: core: Break out start_signal_voltage_switch
Allow callers to access the start_signal_voltage_switch host_ops
member without going through any cmd11 logic. This is mostly a
preparation for the following signal voltage switch patch.
Also, reset ios.signal_voltage to its original value if
start_signal_voltage_switch fails.
Signed-off-by: Johan Rudholm <johan.rudholm@stericsson.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Wei WANG <wei_wang@realsil.com.cn>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/core/core.c | 35 | ||||
-rw-r--r-- | drivers/mmc/core/core.h | 4 | ||||
-rw-r--r-- | drivers/mmc/core/mmc.c | 8 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 2 | ||||
-rw-r--r-- | drivers/mmc/core/sdio.c | 3 |
5 files changed, 31 insertions, 21 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 789056fbfc93..bb794c784597 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1317,7 +1317,26 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) | |||
1317 | return ocr; | 1317 | return ocr; |
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11) | 1320 | int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) |
1321 | { | ||
1322 | int err = 0; | ||
1323 | int old_signal_voltage = host->ios.signal_voltage; | ||
1324 | |||
1325 | host->ios.signal_voltage = signal_voltage; | ||
1326 | if (host->ops->start_signal_voltage_switch) { | ||
1327 | mmc_host_clk_hold(host); | ||
1328 | err = host->ops->start_signal_voltage_switch(host, &host->ios); | ||
1329 | mmc_host_clk_release(host); | ||
1330 | } | ||
1331 | |||
1332 | if (err) | ||
1333 | host->ios.signal_voltage = old_signal_voltage; | ||
1334 | |||
1335 | return err; | ||
1336 | |||
1337 | } | ||
1338 | |||
1339 | int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) | ||
1321 | { | 1340 | { |
1322 | struct mmc_command cmd = {0}; | 1341 | struct mmc_command cmd = {0}; |
1323 | int err = 0; | 1342 | int err = 0; |
@@ -1328,7 +1347,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 | |||
1328 | * Send CMD11 only if the request is to switch the card to | 1347 | * Send CMD11 only if the request is to switch the card to |
1329 | * 1.8V signalling. | 1348 | * 1.8V signalling. |
1330 | */ | 1349 | */ |
1331 | if ((signal_voltage != MMC_SIGNAL_VOLTAGE_330) && cmd11) { | 1350 | if (signal_voltage != MMC_SIGNAL_VOLTAGE_330) { |
1332 | cmd.opcode = SD_SWITCH_VOLTAGE; | 1351 | cmd.opcode = SD_SWITCH_VOLTAGE; |
1333 | cmd.arg = 0; | 1352 | cmd.arg = 0; |
1334 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; | 1353 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
@@ -1341,15 +1360,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 | |||
1341 | return -EIO; | 1360 | return -EIO; |
1342 | } | 1361 | } |
1343 | 1362 | ||
1344 | host->ios.signal_voltage = signal_voltage; | 1363 | return __mmc_set_signal_voltage(host, signal_voltage); |
1345 | |||
1346 | if (host->ops->start_signal_voltage_switch) { | ||
1347 | mmc_host_clk_hold(host); | ||
1348 | err = host->ops->start_signal_voltage_switch(host, &host->ios); | ||
1349 | mmc_host_clk_release(host); | ||
1350 | } | ||
1351 | |||
1352 | return err; | ||
1353 | } | 1364 | } |
1354 | 1365 | ||
1355 | /* | 1366 | /* |
@@ -1412,7 +1423,7 @@ static void mmc_power_up(struct mmc_host *host) | |||
1412 | mmc_set_ios(host); | 1423 | mmc_set_ios(host); |
1413 | 1424 | ||
1414 | /* Set signal voltage to 3.3V */ | 1425 | /* Set signal voltage to 3.3V */ |
1415 | mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, false); | 1426 | __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330); |
1416 | 1427 | ||
1417 | /* | 1428 | /* |
1418 | * This delay should be sufficient to allow the power supply | 1429 | * This delay should be sufficient to allow the power supply |
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 9007de74d8a9..b9f18a2a8874 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h | |||
@@ -40,8 +40,8 @@ void mmc_set_ungated(struct mmc_host *host); | |||
40 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); | 40 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); |
41 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width); | 41 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width); |
42 | u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); | 42 | u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); |
43 | int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, | 43 | int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); |
44 | bool cmd11); | 44 | int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); |
45 | void mmc_set_timing(struct mmc_host *host, unsigned int timing); | 45 | void mmc_set_timing(struct mmc_host *host, unsigned int timing); |
46 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); | 46 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); |
47 | void mmc_power_off(struct mmc_host *host); | 47 | void mmc_power_off(struct mmc_host *host); |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 0d7a9795a6da..8a3ad602a877 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -769,11 +769,11 @@ static int mmc_select_hs200(struct mmc_card *card) | |||
769 | 769 | ||
770 | if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V && | 770 | if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V && |
771 | host->caps2 & MMC_CAP2_HS200_1_2V_SDR) | 771 | host->caps2 & MMC_CAP2_HS200_1_2V_SDR) |
772 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120, 0); | 772 | err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); |
773 | 773 | ||
774 | if (err && card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_8V && | 774 | if (err && card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_8V && |
775 | host->caps2 & MMC_CAP2_HS200_1_8V_SDR) | 775 | host->caps2 & MMC_CAP2_HS200_1_8V_SDR) |
776 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, 0); | 776 | err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); |
777 | 777 | ||
778 | /* If fails try again during next card power cycle */ | 778 | /* If fails try again during next card power cycle */ |
779 | if (err) | 779 | if (err) |
@@ -1221,8 +1221,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1221 | * WARNING: eMMC rules are NOT the same as SD DDR | 1221 | * WARNING: eMMC rules are NOT the same as SD DDR |
1222 | */ | 1222 | */ |
1223 | if (ddr == MMC_1_2V_DDR_MODE) { | 1223 | if (ddr == MMC_1_2V_DDR_MODE) { |
1224 | err = mmc_set_signal_voltage(host, | 1224 | err = __mmc_set_signal_voltage(host, |
1225 | MMC_SIGNAL_VOLTAGE_120, 0); | 1225 | MMC_SIGNAL_VOLTAGE_120); |
1226 | if (err) | 1226 | if (err) |
1227 | goto err; | 1227 | goto err; |
1228 | } | 1228 | } |
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 937363948079..9a59fcd55a75 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -757,7 +757,7 @@ try_again: | |||
757 | */ | 757 | */ |
758 | if (!mmc_host_is_spi(host) && rocr && | 758 | if (!mmc_host_is_spi(host) && rocr && |
759 | ((*rocr & 0x41000000) == 0x41000000)) { | 759 | ((*rocr & 0x41000000) == 0x41000000)) { |
760 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, true); | 760 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); |
761 | if (err) { | 761 | if (err) { |
762 | ocr &= ~SD_OCR_S18R; | 762 | ocr &= ~SD_OCR_S18R; |
763 | goto try_again; | 763 | goto try_again; |
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 3a64933466b8..1a726aef211d 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c | |||
@@ -647,8 +647,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
647 | * it. | 647 | * it. |
648 | */ | 648 | */ |
649 | if ((ocr & R4_18V_PRESENT) && mmc_host_uhs(host)) { | 649 | if ((ocr & R4_18V_PRESENT) && mmc_host_uhs(host)) { |
650 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, | 650 | err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); |
651 | true); | ||
652 | if (err) { | 651 | if (err) { |
653 | ocr &= ~R4_18V_PRESENT; | 652 | ocr &= ~R4_18V_PRESENT; |
654 | host->ocr &= ~R4_18V_PRESENT; | 653 | host->ocr &= ~R4_18V_PRESENT; |