aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c15
-rw-r--r--include/linux/regulator/machine.h4
2 files changed, 16 insertions, 3 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 432faa5cb8af..58452ac0f165 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -724,6 +724,10 @@ static void print_constraints(struct regulator_dev *rdev)
724 count += sprintf(buf + count, "at %d mV ", ret / 1000); 724 count += sprintf(buf + count, "at %d mV ", ret / 1000);
725 } 725 }
726 726
727 if (constraints->uV_offset)
728 count += sprintf(buf, "%dmV offset ",
729 constraints->uV_offset / 1000);
730
727 if (constraints->min_uA && constraints->max_uA) { 731 if (constraints->min_uA && constraints->max_uA) {
728 if (constraints->min_uA == constraints->max_uA) 732 if (constraints->min_uA == constraints->max_uA)
729 count += sprintf(buf + count, "%d mA ", 733 count += sprintf(buf + count, "%d mA ",
@@ -1641,6 +1645,9 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
1641 1645
1642 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); 1646 trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV);
1643 1647
1648 min_uV += rdev->constraints->uV_offset;
1649 max_uV += rdev->constraints->uV_offset;
1650
1644 if (rdev->desc->ops->set_voltage) { 1651 if (rdev->desc->ops->set_voltage) {
1645 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, 1652 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
1646 &selector); 1653 &selector);
@@ -1865,18 +1872,20 @@ EXPORT_SYMBOL_GPL(regulator_sync_voltage);
1865 1872
1866static int _regulator_get_voltage(struct regulator_dev *rdev) 1873static int _regulator_get_voltage(struct regulator_dev *rdev)
1867{ 1874{
1868 int sel; 1875 int sel, ret;
1869 1876
1870 if (rdev->desc->ops->get_voltage_sel) { 1877 if (rdev->desc->ops->get_voltage_sel) {
1871 sel = rdev->desc->ops->get_voltage_sel(rdev); 1878 sel = rdev->desc->ops->get_voltage_sel(rdev);
1872 if (sel < 0) 1879 if (sel < 0)
1873 return sel; 1880 return sel;
1874 return rdev->desc->ops->list_voltage(rdev, sel); 1881 ret = rdev->desc->ops->list_voltage(rdev, sel);
1875 } 1882 }
1876 if (rdev->desc->ops->get_voltage) 1883 if (rdev->desc->ops->get_voltage)
1877 return rdev->desc->ops->get_voltage(rdev); 1884 ret = rdev->desc->ops->get_voltage(rdev);
1878 else 1885 else
1879 return -EINVAL; 1886 return -EINVAL;
1887
1888 return ret - rdev->constraints->uV_offset;
1880} 1889}
1881 1890
1882/** 1891/**
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 8f1a55d99494..ce3127a75c88 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -68,6 +68,8 @@ struct regulator_state {
68 * 68 *
69 * @min_uV: Smallest voltage consumers may set. 69 * @min_uV: Smallest voltage consumers may set.
70 * @max_uV: Largest voltage consumers may set. 70 * @max_uV: Largest voltage consumers may set.
71 * @uV_offset: Offset applied to voltages from consumer to compensate for
72 * voltage drops.
71 * 73 *
72 * @min_uA: Smallest consumers consumers may set. 74 * @min_uA: Smallest consumers consumers may set.
73 * @max_uA: Largest current consumers may set. 75 * @max_uA: Largest current consumers may set.
@@ -99,6 +101,8 @@ struct regulation_constraints {
99 int min_uV; 101 int min_uV;
100 int max_uV; 102 int max_uV;
101 103
104 int uV_offset;
105
102 /* current output range (inclusive) - for current control */ 106 /* current output range (inclusive) - for current control */
103 int min_uA; 107 int min_uA;
104 int max_uA; 108 int max_uA;