Commit 17a0751e authored by Marek Vasut's avatar Marek Vasut Committed by Ulf Hansson

mmc: core: Return 1 from mmc_regulator_set_vqmmc() if switch skipped

Adjust mmc_regulator_set_vqmmc() to return 1 if the voltage switch was
skipped because the regulator voltage was already correct. This allows
drivers to detect such condition and possibly skip various voltage
switching extras.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20200416163649.336967-2-marex@denx.deSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 9cbe0fc8
...@@ -136,6 +136,8 @@ static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator, ...@@ -136,6 +136,8 @@ static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator,
int min_uV, int target_uV, int min_uV, int target_uV,
int max_uV) int max_uV)
{ {
int current_uV;
/* /*
* Check if supported first to avoid errors since we may try several * Check if supported first to avoid errors since we may try several
* signal levels during power up and don't want to show errors. * signal levels during power up and don't want to show errors.
...@@ -143,6 +145,14 @@ static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator, ...@@ -143,6 +145,14 @@ static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator,
if (!regulator_is_supported_voltage(regulator, min_uV, max_uV)) if (!regulator_is_supported_voltage(regulator, min_uV, max_uV))
return -EINVAL; return -EINVAL;
/*
* The voltage is already set, no need to switch.
* Return 1 to indicate that no switch happened.
*/
current_uV = regulator_get_voltage(regulator);
if (current_uV == target_uV)
return 1;
return regulator_set_voltage_triplet(regulator, min_uV, target_uV, return regulator_set_voltage_triplet(regulator, min_uV, target_uV,
max_uV); max_uV);
} }
...@@ -198,9 +208,10 @@ int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios) ...@@ -198,9 +208,10 @@ int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios)
* voltage in two steps and try to stay close to vmmc * voltage in two steps and try to stay close to vmmc
* with a 0.3V tolerance at first. * with a 0.3V tolerance at first.
*/ */
if (!mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc, ret = mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,
min_uV, volt, max_uV)) min_uV, volt, max_uV);
return 0; if (ret >= 0)
return ret;
return mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc, return mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,
2700000, volt, 3600000); 2700000, volt, 3600000);
......
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