diff options
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e7e4460dcb92..3ffc6979d164 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1765,6 +1765,51 @@ out: | |||
1765 | EXPORT_SYMBOL_GPL(regulator_set_voltage); | 1765 | EXPORT_SYMBOL_GPL(regulator_set_voltage); |
1766 | 1766 | ||
1767 | /** | 1767 | /** |
1768 | * regulator_set_voltage_time - get raise/fall time | ||
1769 | * @regulator: regulator source | ||
1770 | * @old_uV: starting voltage in microvolts | ||
1771 | * @new_uV: target voltage in microvolts | ||
1772 | * | ||
1773 | * Provided with the starting and ending voltage, this function attempts to | ||
1774 | * calculate the time in microseconds required to rise or fall to this new | ||
1775 | * voltage. | ||
1776 | */ | ||
1777 | int regulator_set_voltage_time(struct regulator *regulator, | ||
1778 | int old_uV, int new_uV) | ||
1779 | { | ||
1780 | struct regulator_dev *rdev = regulator->rdev; | ||
1781 | struct regulator_ops *ops = rdev->desc->ops; | ||
1782 | int old_sel = -1; | ||
1783 | int new_sel = -1; | ||
1784 | int voltage; | ||
1785 | int i; | ||
1786 | |||
1787 | /* Currently requires operations to do this */ | ||
1788 | if (!ops->list_voltage || !ops->set_voltage_time_sel | ||
1789 | || !rdev->desc->n_voltages) | ||
1790 | return -EINVAL; | ||
1791 | |||
1792 | for (i = 0; i < rdev->desc->n_voltages; i++) { | ||
1793 | /* We only look for exact voltage matches here */ | ||
1794 | voltage = regulator_list_voltage(regulator, i); | ||
1795 | if (voltage < 0) | ||
1796 | return -EINVAL; | ||
1797 | if (voltage == 0) | ||
1798 | continue; | ||
1799 | if (voltage == old_uV) | ||
1800 | old_sel = i; | ||
1801 | if (voltage == new_uV) | ||
1802 | new_sel = i; | ||
1803 | } | ||
1804 | |||
1805 | if (old_sel < 0 || new_sel < 0) | ||
1806 | return -EINVAL; | ||
1807 | |||
1808 | return ops->set_voltage_time_sel(rdev, old_sel, new_sel); | ||
1809 | } | ||
1810 | EXPORT_SYMBOL_GPL(regulator_set_voltage_time); | ||
1811 | |||
1812 | /** | ||
1768 | * regulator_sync_voltage - re-apply last regulator output voltage | 1813 | * regulator_sync_voltage - re-apply last regulator output voltage |
1769 | * @regulator: regulator source | 1814 | * @regulator: regulator source |
1770 | * | 1815 | * |