diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-19 22:30:21 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-03 08:19:45 -0400 |
commit | cffc9592fde309deafce12362e0a285108cfa3c8 (patch) | |
tree | bdd8ae2815fc8ac4aff7935eda79ee31bcb07cf8 /drivers/regulator/core.c | |
parent | f8f5701bdaf9134b1f90e5044a82c66324d2073f (diff) |
regulator: core: Allow drivers to set voltage mapping table in regulator_desc
Some regulator hardware use table based mapping can set volt_table in
regulator_desc and use regulator_list_voltage_table() for their list_voltage
callback.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7584a74eec8a..333b7ebe7cae 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1883,6 +1883,31 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev, | |||
1883 | EXPORT_SYMBOL_GPL(regulator_list_voltage_linear); | 1883 | EXPORT_SYMBOL_GPL(regulator_list_voltage_linear); |
1884 | 1884 | ||
1885 | /** | 1885 | /** |
1886 | * regulator_list_voltage_table - List voltages with table based mapping | ||
1887 | * | ||
1888 | * @rdev: Regulator device | ||
1889 | * @selector: Selector to convert into a voltage | ||
1890 | * | ||
1891 | * Regulators with table based mapping between voltages and | ||
1892 | * selectors can set volt_table in the regulator descriptor | ||
1893 | * and then use this function as their list_voltage() operation. | ||
1894 | */ | ||
1895 | int regulator_list_voltage_table(struct regulator_dev *rdev, | ||
1896 | unsigned int selector) | ||
1897 | { | ||
1898 | if (!rdev->desc->volt_table) { | ||
1899 | BUG_ON(!rdev->desc->volt_table); | ||
1900 | return -EINVAL; | ||
1901 | } | ||
1902 | |||
1903 | if (selector >= rdev->desc->n_voltages) | ||
1904 | return -EINVAL; | ||
1905 | |||
1906 | return rdev->desc->volt_table[selector]; | ||
1907 | } | ||
1908 | EXPORT_SYMBOL_GPL(regulator_list_voltage_table); | ||
1909 | |||
1910 | /** | ||
1886 | * regulator_list_voltage - enumerate supported voltages | 1911 | * regulator_list_voltage - enumerate supported voltages |
1887 | * @regulator: regulator source | 1912 | * @regulator: regulator source |
1888 | * @selector: identify voltage to list | 1913 | * @selector: identify voltage to list |