aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-09-10 06:15:05 -0400
committerMark Brown <broonie@linaro.org>2013-09-10 13:19:52 -0400
commit5a523605afa7d3b54b2e7041f8c9e6bc39872a7e (patch)
treebb8b579e660754e37ae11b68f11085d12dff7c71
parenta584862221426f461f56674d30fe0d712ee63d00 (diff)
regulator: core: provide fixed voltage in desc for single voltage rail
If given rail has the single voltage (n_voltages = 1) then provide the rail voltage through regulator descriptor so that core can use this value for finding voltage. This will avoid the implementation of the callback for get_voltage() or list_voltage() callback on regulator driver. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/core.c5
-rw-r--r--include/linux/regulator/driver.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a01b8b3b70ca..abc899ed1ebf 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2489,6 +2489,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
2489 ret = rdev->desc->ops->get_voltage(rdev); 2489 ret = rdev->desc->ops->get_voltage(rdev);
2490 } else if (rdev->desc->ops->list_voltage) { 2490 } else if (rdev->desc->ops->list_voltage) {
2491 ret = rdev->desc->ops->list_voltage(rdev, 0); 2491 ret = rdev->desc->ops->list_voltage(rdev, 0);
2492 } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) {
2493 ret = rdev->desc->fixed_uV;
2492 } else { 2494 } else {
2493 return -EINVAL; 2495 return -EINVAL;
2494 } 2496 }
@@ -3170,7 +3172,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
3170 /* some attributes need specific methods to be displayed */ 3172 /* some attributes need specific methods to be displayed */
3171 if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || 3173 if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) ||
3172 (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || 3174 (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) ||
3173 (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0)) { 3175 (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0) ||
3176 (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1))) {
3174 status = device_create_file(dev, &dev_attr_microvolts); 3177 status = device_create_file(dev, &dev_attr_microvolts);
3175 if (status < 0) 3178 if (status < 0)
3176 return status; 3179 return status;
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 67e13aa5a478..9e8241a9f28f 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -207,6 +207,7 @@ enum regulator_type {
207 * @min_uV: Voltage given by the lowest selector (if linear mapping) 207 * @min_uV: Voltage given by the lowest selector (if linear mapping)
208 * @uV_step: Voltage increase with each selector (if linear mapping) 208 * @uV_step: Voltage increase with each selector (if linear mapping)
209 * @linear_min_sel: Minimal selector for starting linear mapping 209 * @linear_min_sel: Minimal selector for starting linear mapping
210 * @fixed_uV: Fixed voltage of rails.
210 * @ramp_delay: Time to settle down after voltage change (unit: uV/us) 211 * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
211 * @volt_table: Voltage mapping table (if table based mapping) 212 * @volt_table: Voltage mapping table (if table based mapping)
212 * 213 *
@@ -239,6 +240,7 @@ struct regulator_desc {
239 unsigned int min_uV; 240 unsigned int min_uV;
240 unsigned int uV_step; 241 unsigned int uV_step;
241 unsigned int linear_min_sel; 242 unsigned int linear_min_sel;
243 int fixed_uV;
242 unsigned int ramp_delay; 244 unsigned int ramp_delay;
243 245
244 const struct regulator_linear_range *linear_ranges; 246 const struct regulator_linear_range *linear_ranges;