aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2011-03-17 08:24:36 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-03-26 10:15:06 -0400
commit77af1b2641faf45788a0d480db94082ebee931dc (patch)
tree66f06c3244e6c961f15b22e66156f388e0420994
parent79568b941277b5986a8a7f0fb8578b2ccfc3e87e (diff)
regulator: add set_voltage_time_sel infrastructure
This makes it possible to set the stabilization time for voltage regulators in the same manner as enable_time(). The interface only supports regulators that implements fixed selectors. Cc: Bengt Jonsson <bengt.g.jonsson@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r--drivers/regulator/core.c25
-rw-r--r--include/linux/regulator/driver.h11
2 files changed, 34 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e611f6797e6a..e7e4460dcb92 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1629,6 +1629,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
1629 int min_uV, int max_uV) 1629 int min_uV, int max_uV)
1630{ 1630{
1631 int ret; 1631 int ret;
1632 int delay = 0;
1632 unsigned int selector; 1633 unsigned int selector;
1633 1634
1634 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); 1635 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV);
@@ -1662,6 +1663,22 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
1662 } 1663 }
1663 } 1664 }
1664 1665
1666 /*
1667 * If we can't obtain the old selector there is not enough
1668 * info to call set_voltage_time_sel().
1669 */
1670 if (rdev->desc->ops->set_voltage_time_sel &&
1671 rdev->desc->ops->get_voltage_sel) {
1672 unsigned int old_selector = 0;
1673
1674 ret = rdev->desc->ops->get_voltage_sel(rdev);
1675 if (ret < 0)
1676 return ret;
1677 old_selector = ret;
1678 delay = rdev->desc->ops->set_voltage_time_sel(rdev,
1679 old_selector, selector);
1680 }
1681
1665 if (best_val != INT_MAX) { 1682 if (best_val != INT_MAX) {
1666 ret = rdev->desc->ops->set_voltage_sel(rdev, selector); 1683 ret = rdev->desc->ops->set_voltage_sel(rdev, selector);
1667 selector = best_val; 1684 selector = best_val;
@@ -1672,6 +1689,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
1672 ret = -EINVAL; 1689 ret = -EINVAL;
1673 } 1690 }
1674 1691
1692 /* Insert any necessary delays */
1693 if (delay >= 1000) {
1694 mdelay(delay / 1000);
1695 udelay(delay % 1000);
1696 } else if (delay) {
1697 udelay(delay);
1698 }
1699
1675 if (ret == 0) 1700 if (ret == 0)
1676 _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, 1701 _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,
1677 NULL); 1702 NULL);
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index b8ed16a33c47..6c433b89c80d 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -63,7 +63,11 @@ enum regulator_status {
63 * when running with the specified parameters. 63 * when running with the specified parameters.
64 * 64 *
65 * @enable_time: Time taken for the regulator voltage output voltage to 65 * @enable_time: Time taken for the regulator voltage output voltage to
66 * stabalise after being enabled, in microseconds. 66 * stabilise after being enabled, in microseconds.
67 * @set_voltage_time_sel: Time taken for the regulator voltage output voltage
68 * to stabilise after being set to a new value, in microseconds.
69 * The function provides the from and to voltage selector, the
70 * function should return the worst case.
67 * 71 *
68 * @set_suspend_voltage: Set the voltage for the regulator when the system 72 * @set_suspend_voltage: Set the voltage for the regulator when the system
69 * is suspended. 73 * is suspended.
@@ -103,8 +107,11 @@ struct regulator_ops {
103 int (*set_mode) (struct regulator_dev *, unsigned int mode); 107 int (*set_mode) (struct regulator_dev *, unsigned int mode);
104 unsigned int (*get_mode) (struct regulator_dev *); 108 unsigned int (*get_mode) (struct regulator_dev *);
105 109
106 /* Time taken to enable the regulator */ 110 /* Time taken to enable or set voltage on the regulator */
107 int (*enable_time) (struct regulator_dev *); 111 int (*enable_time) (struct regulator_dev *);
112 int (*set_voltage_time_sel) (struct regulator_dev *,
113 unsigned int old_selector,
114 unsigned int new_selector);
108 115
109 /* report regulator status ... most other accessors report 116 /* report regulator status ... most other accessors report
110 * control inputs, this reports results of combining inputs 117 * control inputs, this reports results of combining inputs