diff options
author | 2013-09-20 13:13:02 +0530 | |
---|---|---|
committer | 2013-09-20 10:50:29 +0100 | |
commit | f8c1700dd7d2ce9b2238b20d364317b2968ac76b (patch) | |
tree | 6d42ffb2f3e7e9bee181e70745b7ee5e034874d2 /drivers/regulator/core.c | |
parent | regulator: core: add support for configuring turn-on time through constraints (diff) | |
download | linux-f8c1700dd7d2ce9b2238b20d364317b2968ac76b.tar.gz linux-f8c1700dd7d2ce9b2238b20d364317b2968ac76b.tar.bz2 linux-f8c1700dd7d2ce9b2238b20d364317b2968ac76b.zip |
regulator: core: set current constraints while setting machine constraints
Machine constraints is configured during regulator register. If current
constraints are provided through machine constraints then it is observed
that sometime the current configured on rail is out of range what machine
constraint has.
Set the current constraints when setting machine constraints to make
sure that rail's current is within the range of given machine constraints.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5217c1964c32..66ae12d12c10 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -923,6 +923,36 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, return 0; } +static int machine_constraints_current(struct regulator_dev *rdev, + struct regulation_constraints *constraints) +{ + struct regulator_ops *ops = rdev->desc->ops; + int ret; + + if (!constraints->min_uA && !constraints->max_uA) + return 0; + + if (constraints->min_uA > constraints->max_uA) { + rdev_err(rdev, "Invalid current constraints\n"); + return -EINVAL; + } + + if (!ops->set_current_limit || !ops->get_current_limit) { + rdev_warn(rdev, "Operation of current configuration missing\n"); + return 0; + } + + /* Set regulator current in constraints range */ + ret = ops->set_current_limit(rdev, constraints->min_uA, + constraints->max_uA); + if (ret < 0) { + rdev_err(rdev, "Failed to set current constraint, %d\n", ret); + return ret; + } + + return 0; +} + /** * set_machine_constraints - sets regulator constraints * @rdev: regulator source @@ -953,6 +983,10 @@ static int set_machine_constraints(struct regulator_dev *rdev, if (ret != 0) goto out; + ret = machine_constraints_current(rdev, rdev->constraints); + if (ret != 0) + goto out; + /* do we need to setup our suspend state */ if (rdev->constraints->initial_state) { ret = suspend_prepare(rdev, rdev->constraints->initial_state); |