Skip to content

Commit 39a72db

Browse files
Yann-lmsstorulf
authored andcommitted
mmc: core: properly select voltage range without power cycle
In mmc_select_voltage(), if there is no full power cycle, the voltage range selected at the end of the function will be on a single range (e.g. 3.3V/3.4V). To keep a range around the selected voltage (3.2V/3.4V), the mask shift should be reduced by 1. This issue was triggered by using a specific SD-card (Verbatim Premium 16GB UHS-1) on an STM32MP157C-DK2 board. This board cannot do UHS modes and there is no power cycle. And the card was failing to switch to high-speed mode. When adding the range 3.2V/3.3V for this card with the proposed shift change, the card can switch to high-speed mode. Fixes: ce69d37 ("mmc: core: Prevent violation of specs while initializing cards") Signed-off-by: Yann Gautier <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 094226a commit 39a72db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/mmc/core/core.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,13 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr)
11341134
mmc_power_cycle(host, ocr);
11351135
} else {
11361136
bit = fls(ocr) - 1;
1137-
ocr &= 3 << bit;
1137+
/*
1138+
* The bit variable represents the highest voltage bit set in
1139+
* the OCR register.
1140+
* To keep a range of 2 values (e.g. 3.2V/3.3V and 3.3V/3.4V),
1141+
* we must shift the mask '3' with (bit - 1).
1142+
*/
1143+
ocr &= 3 << (bit - 1);
11381144
if (bit != host->ios.vdd)
11391145
dev_warn(mmc_dev(host), "exceeding card's volts\n");
11401146
}

0 commit comments

Comments
 (0)