Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Linus Walleij and committed by
Liam Girdwood
77af1b26 79568b94

+34 -2
+25
drivers/regulator/core.c
··· 1629 1629 int min_uV, int max_uV) 1630 1630 { 1631 1631 int ret; 1632 + int delay = 0; 1632 1633 unsigned int selector; 1633 1634 1634 1635 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); ··· 1663 1662 } 1664 1663 } 1665 1664 1665 + /* 1666 + * If we can't obtain the old selector there is not enough 1667 + * info to call set_voltage_time_sel(). 1668 + */ 1669 + if (rdev->desc->ops->set_voltage_time_sel && 1670 + rdev->desc->ops->get_voltage_sel) { 1671 + unsigned int old_selector = 0; 1672 + 1673 + ret = rdev->desc->ops->get_voltage_sel(rdev); 1674 + if (ret < 0) 1675 + return ret; 1676 + old_selector = ret; 1677 + delay = rdev->desc->ops->set_voltage_time_sel(rdev, 1678 + old_selector, selector); 1679 + } 1680 + 1666 1681 if (best_val != INT_MAX) { 1667 1682 ret = rdev->desc->ops->set_voltage_sel(rdev, selector); 1668 1683 selector = best_val; ··· 1687 1670 } 1688 1671 } else { 1689 1672 ret = -EINVAL; 1673 + } 1674 + 1675 + /* Insert any necessary delays */ 1676 + if (delay >= 1000) { 1677 + mdelay(delay / 1000); 1678 + udelay(delay % 1000); 1679 + } else if (delay) { 1680 + udelay(delay); 1690 1681 } 1691 1682 1692 1683 if (ret == 0)
+9 -2
include/linux/regulator/driver.h
··· 63 63 * when running with the specified parameters. 64 64 * 65 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 72 * @set_suspend_voltage: Set the voltage for the regulator when the system 69 73 * is suspended. ··· 107 103 int (*set_mode) (struct regulator_dev *, unsigned int mode); 108 104 unsigned int (*get_mode) (struct regulator_dev *); 109 105 110 - /* Time taken to enable the regulator */ 106 + /* Time taken to enable or set voltage on the regulator */ 111 107 int (*enable_time) (struct regulator_dev *); 108 + int (*set_voltage_time_sel) (struct regulator_dev *, 109 + unsigned int old_selector, 110 + unsigned int new_selector); 112 111 113 112 /* report regulator status ... most other accessors report 114 113 * control inputs, this reports results of combining inputs