Commit 567c89032cfdda8047562abe450947ac01f2d3c7
Committed by
Chris Ball
1 parent
d887874e0e
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 5 changed files with 31 additions and 21 deletions Side-by-side Diff
drivers/mmc/core/core.c
... | ... | @@ -1317,8 +1317,27 @@ |
1317 | 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 | 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) | |
1340 | +{ | |
1322 | 1341 | struct mmc_command cmd = {0}; |
1323 | 1342 | int err = 0; |
1324 | 1343 | |
... | ... | @@ -1328,7 +1347,7 @@ |
1328 | 1347 | * Send CMD11 only if the request is to switch the card to |
1329 | 1348 | * 1.8V signalling. |
1330 | 1349 | */ |
1331 | - if ((signal_voltage != MMC_SIGNAL_VOLTAGE_330) && cmd11) { | |
1350 | + if (signal_voltage != MMC_SIGNAL_VOLTAGE_330) { | |
1332 | 1351 | cmd.opcode = SD_SWITCH_VOLTAGE; |
1333 | 1352 | cmd.arg = 0; |
1334 | 1353 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
... | ... | @@ -1341,15 +1360,7 @@ |
1341 | 1360 | return -EIO; |
1342 | 1361 | } |
1343 | 1362 | |
1344 | - host->ios.signal_voltage = 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; | |
1363 | + return __mmc_set_signal_voltage(host, signal_voltage); | |
1353 | 1364 | } |
1354 | 1365 | |
1355 | 1366 | /* |
... | ... | @@ -1412,7 +1423,7 @@ |
1412 | 1423 | mmc_set_ios(host); |
1413 | 1424 | |
1414 | 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 | 1429 | * This delay should be sufficient to allow the power supply |
drivers/mmc/core/core.h
... | ... | @@ -40,8 +40,8 @@ |
40 | 40 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); |
41 | 41 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width); |
42 | 42 | u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); |
43 | -int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, | |
44 | - bool cmd11); | |
43 | +int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); | |
44 | +int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); | |
45 | 45 | void mmc_set_timing(struct mmc_host *host, unsigned int timing); |
46 | 46 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); |
47 | 47 | void mmc_power_off(struct mmc_host *host); |
drivers/mmc/core/mmc.c
... | ... | @@ -769,11 +769,11 @@ |
769 | 769 | |
770 | 770 | if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V && |
771 | 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 | 774 | if (err && card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_8V && |
775 | 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 | 778 | /* If fails try again during next card power cycle */ |
779 | 779 | if (err) |
... | ... | @@ -1221,8 +1221,8 @@ |
1221 | 1221 | * WARNING: eMMC rules are NOT the same as SD DDR |
1222 | 1222 | */ |
1223 | 1223 | if (ddr == MMC_1_2V_DDR_MODE) { |
1224 | - err = mmc_set_signal_voltage(host, | |
1225 | - MMC_SIGNAL_VOLTAGE_120, 0); | |
1224 | + err = __mmc_set_signal_voltage(host, | |
1225 | + MMC_SIGNAL_VOLTAGE_120); | |
1226 | 1226 | if (err) |
1227 | 1227 | goto err; |
1228 | 1228 | } |
drivers/mmc/core/sd.c
... | ... | @@ -757,7 +757,7 @@ |
757 | 757 | */ |
758 | 758 | if (!mmc_host_is_spi(host) && rocr && |
759 | 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 | 761 | if (err) { |
762 | 762 | ocr &= ~SD_OCR_S18R; |
763 | 763 | goto try_again; |
drivers/mmc/core/sdio.c
... | ... | @@ -647,8 +647,7 @@ |
647 | 647 | * it. |
648 | 648 | */ |
649 | 649 | if ((ocr & R4_18V_PRESENT) && mmc_host_uhs(host)) { |
650 | - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, | |
651 | - true); | |
650 | + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); | |
652 | 651 | if (err) { |
653 | 652 | ocr &= ~R4_18V_PRESENT; |
654 | 653 | host->ocr &= ~R4_18V_PRESENT; |