summaryrefslogtreecommitdiff
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-05-20 02:30:21 (GMT)
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-03 12:19:45 (GMT)
commitcffc9592fde309deafce12362e0a285108cfa3c8 (patch)
treebdd8ae2815fc8ac4aff7935eda79ee31bcb07cf8 /drivers/regulator/core.c
parentf8f5701bdaf9134b1f90e5044a82c66324d2073f (diff)
downloadlinux-fsl-qoriq-cffc9592fde309deafce12362e0a285108cfa3c8.tar.xz
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.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7584a74..333b7eb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1883,6 +1883,31 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
/**
+ * regulator_list_voltage_table - List voltages with table based mapping
+ *
+ * @rdev: Regulator device
+ * @selector: Selector to convert into a voltage
+ *
+ * Regulators with table based mapping between voltages and
+ * selectors can set volt_table in the regulator descriptor
+ * and then use this function as their list_voltage() operation.
+ */
+int regulator_list_voltage_table(struct regulator_dev *rdev,
+ unsigned int selector)
+{
+ if (!rdev->desc->volt_table) {
+ BUG_ON(!rdev->desc->volt_table);
+ return -EINVAL;
+ }
+
+ if (selector >= rdev->desc->n_voltages)
+ return -EINVAL;
+
+ return rdev->desc->volt_table[selector];
+}
+EXPORT_SYMBOL_GPL(regulator_list_voltage_table);
+
+/**
* regulator_list_voltage - enumerate supported voltages
* @regulator: regulator source
* @selector: identify voltage to list