Commit 064d5cd1 authored by Alban Bedel's avatar Alban Bedel Committed by Mark Brown

regulator: core: Fix the init of DT defined fixed regulators

When a regulator is defined using DT and it has a single voltage the
regulator init always tries to apply this voltage. However it fails if
the regulator isn't settable because it is using an internal low level
function. To overcome this we now first query the regulator and only
set it if needed.
Signed-off-by: default avatarAlban Bedel <alban.bedel@avionic-design.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent fd482a3e
......@@ -844,13 +844,22 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
/* do we need to apply the constraint voltage */
if (rdev->constraints->apply_uV &&
rdev->constraints->min_uV == rdev->constraints->max_uV) {
ret = _regulator_do_set_voltage(rdev,
rdev->constraints->min_uV,
rdev->constraints->max_uV);
if (ret < 0) {
rdev_err(rdev, "failed to apply %duV constraint\n",
rdev->constraints->min_uV);
return ret;
int current_uV = _regulator_get_voltage(rdev);
if (current_uV < 0) {
rdev_err(rdev, "failed to get the current voltage\n");
return current_uV;
}
if (current_uV < rdev->constraints->min_uV ||
current_uV > rdev->constraints->max_uV) {
ret = _regulator_do_set_voltage(
rdev, rdev->constraints->min_uV,
rdev->constraints->max_uV);
if (ret < 0) {
rdev_err(rdev,
"failed to apply %duV constraint\n",
rdev->constraints->min_uV);
return ret;
}
}
}
......
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