Commit e5fda26c authored by Mark Brown's avatar Mark Brown Committed by Liam Girdwood

regulator: Enable regulators marked as always_on

If the machine constraints mark a regulator as always_on but this was
not done by the bootloader then enable the regulator when applying
constraints.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent e06f5b4f
...@@ -670,6 +670,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -670,6 +670,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
{ {
int ret = 0; int ret = 0;
const char *name; const char *name;
struct regulator_ops *ops = rdev->desc->ops;
if (constraints->name) if (constraints->name)
name = constraints->name; name = constraints->name;
...@@ -683,8 +684,8 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -683,8 +684,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
/* do we need to apply the constraint voltage */ /* do we need to apply the constraint voltage */
if (rdev->constraints->apply_uV && if (rdev->constraints->apply_uV &&
rdev->constraints->min_uV == rdev->constraints->max_uV && rdev->constraints->min_uV == rdev->constraints->max_uV &&
rdev->desc->ops->set_voltage) { ops->set_voltage) {
ret = rdev->desc->ops->set_voltage(rdev, ret = ops->set_voltage(rdev,
rdev->constraints->min_uV, rdev->constraints->max_uV); rdev->constraints->min_uV, rdev->constraints->max_uV);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n", printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n",
...@@ -710,6 +711,20 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -710,6 +711,20 @@ static int set_machine_constraints(struct regulator_dev *rdev,
} }
} }
/* if always_on is set then turn the regulator on if it's not
* already on. */
if (constraints->always_on && ops->enable &&
((ops->is_enabled && !ops->is_enabled(rdev)) ||
(!ops->is_enabled && !constraints->boot_on))) {
ret = ops->enable(rdev);
if (ret < 0) {
printk(KERN_ERR "%s: failed to enable %s\n",
__func__, name);
rdev->constraints = NULL;
goto out;
}
}
print_constraints(rdev); print_constraints(rdev);
out: out:
return ret; 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