aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-12-16 10:49:36 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-01-12 09:33:05 -0500
commit606a25628187ce863b48d43ca42bc0cbe8342de9 (patch)
tree98057c2d49e5fccb8d9e72d2b961a4f28585afeb /drivers/regulator
parent27315cf61fb813b3916cecfbfa6932dc9447f3f4 (diff)
regulator: Add API to re-apply voltage to hardware
When cooperating with an external control source the regulator setup may be changed underneath the API. Currently consumers can just redo the regulator_set_voltage() to restore a previously set configuration but provide an explicit API for doing this as optimsations in the regulator_set_voltage() implementation will shortly prevent that. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 3d72cc8e2f3e..a12cba32460e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1727,6 +1727,53 @@ out:
1727} 1727}
1728EXPORT_SYMBOL_GPL(regulator_set_voltage); 1728EXPORT_SYMBOL_GPL(regulator_set_voltage);
1729 1729
1730/**
1731 * regulator_sync_voltage - re-apply last regulator output voltage
1732 * @regulator: regulator source
1733 *
1734 * Re-apply the last configured voltage. This is intended to be used
1735 * where some external control source the consumer is cooperating with
1736 * has caused the configured voltage to change.
1737 */
1738int regulator_sync_voltage(struct regulator *regulator)
1739{
1740 struct regulator_dev *rdev = regulator->rdev;
1741 int ret, min_uV, max_uV;
1742
1743 mutex_lock(&rdev->mutex);
1744
1745 if (!rdev->desc->ops->set_voltage &&
1746 !rdev->desc->ops->set_voltage_sel) {
1747 ret = -EINVAL;
1748 goto out;
1749 }
1750
1751 /* This is only going to work if we've had a voltage configured. */
1752 if (!regulator->min_uV && !regulator->max_uV) {
1753 ret = -EINVAL;
1754 goto out;
1755 }
1756
1757 min_uV = regulator->min_uV;
1758 max_uV = regulator->max_uV;
1759
1760 /* This should be a paranoia check... */
1761 ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
1762 if (ret < 0)
1763 goto out;
1764
1765 ret = regulator_check_consumers(rdev, &min_uV, &max_uV);
1766 if (ret < 0)
1767 goto out;
1768
1769 ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
1770
1771out:
1772 mutex_unlock(&rdev->mutex);
1773 return ret;
1774}
1775EXPORT_SYMBOL_GPL(regulator_sync_voltage);
1776
1730static int _regulator_get_voltage(struct regulator_dev *rdev) 1777static int _regulator_get_voltage(struct regulator_dev *rdev)
1731{ 1778{
1732 int sel; 1779 int sel;