Commit 9ed7ca89 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Ulf Hansson

mmc: core: Use regulator_get_voltage() if OCR mask is empty.

The operation conditions register (OCR) stores the voltage
profile of the card, however the list of possible voltages
is restricted by the voltage range supported by the supply
used as VCC/VDD. So in mmc_vddrange_to_ocrmask() a OCR mask
is obtained to filter the not supported voltages, from the
value read in the host controller OCR register.

For fixed regulators, regulator_list_voltage() returns the
fixed output for the first selector but this doesn't happen
for switch (FET) regulators that obtain their voltage from
their parent supply. A call to regulator_get_voltage() is
needed in this case so the regulator core can return the
FET's parent supply voltage output.

This change is consistent with the fact that for other
fixed regulators (that are not FETs) the OCR mask is
returned even when mmc_regulator_set_ocr() checks if the
regulator is fixed before calling regulator_set_voltage().

Without this patch, the following warning is reported when
a FET is used as a vmmc-supply:

dwmmc_exynos 12220000.mmc: Failed getting OCR mask: -22
Signed-off-by: default avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 3d705d14
...@@ -1221,15 +1221,14 @@ int mmc_regulator_get_ocrmask(struct regulator *supply) ...@@ -1221,15 +1221,14 @@ int mmc_regulator_get_ocrmask(struct regulator *supply)
int result = 0; int result = 0;
int count; int count;
int i; int i;
int vdd_uV;
int vdd_mV;
count = regulator_count_voltages(supply); count = regulator_count_voltages(supply);
if (count < 0) if (count < 0)
return count; return count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
int vdd_uV;
int vdd_mV;
vdd_uV = regulator_list_voltage(supply, i); vdd_uV = regulator_list_voltage(supply, i);
if (vdd_uV <= 0) if (vdd_uV <= 0)
continue; continue;
...@@ -1238,6 +1237,15 @@ int mmc_regulator_get_ocrmask(struct regulator *supply) ...@@ -1238,6 +1237,15 @@ int mmc_regulator_get_ocrmask(struct regulator *supply)
result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV); result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
} }
if (!result) {
vdd_uV = regulator_get_voltage(supply);
if (vdd_uV <= 0)
return vdd_uV;
vdd_mV = vdd_uV / 1000;
result = mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
}
return result; return result;
} }
EXPORT_SYMBOL_GPL(mmc_regulator_get_ocrmask); EXPORT_SYMBOL_GPL(mmc_regulator_get_ocrmask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment