aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-10-10 21:30:24 -0400
committerMark Brown <broonie@linaro.org>2013-10-11 07:49:12 -0400
commite277e656804c85a0729d4fd8cdd3c8ab3e6b3b86 (patch)
treea92f29fb7c735cb4cf918059d1773d5110a38bf3
parent813de3c649d6c6ff14c930de9fcd161c0062fabd (diff)
regulator: Remove max_uV from struct regulator_linear_range
linear ranges means each range has linear voltage settings. So we can calculate max_uV for each linear range in regulator core rather than set the max_uV field in drivers. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/88pm800.c14
-rw-r--r--drivers/regulator/as3711-regulator.c25
-rw-r--r--drivers/regulator/as3722-regulator.c1
-rw-r--r--drivers/regulator/da903x.c6
-rw-r--r--drivers/regulator/helpers.c6
-rw-r--r--drivers/regulator/tps65217-regulator.c24
-rw-r--r--drivers/regulator/tps65912-regulator.c9
-rw-r--r--drivers/regulator/wm831x-ldo.c12
-rw-r--r--drivers/regulator/wm8350-regulator.c6
-rw-r--r--drivers/regulator/wm8400-regulator.c6
-rw-r--r--include/linux/regulator/driver.h2
11 files changed, 43 insertions, 68 deletions
diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index 3459f60dcfd1..22ba4c4280ee 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -141,18 +141,16 @@ struct pm800_regulators {
141 141
142/* Ranges are sorted in ascending order. */ 142/* Ranges are sorted in ascending order. */
143static const struct regulator_linear_range buck1_volt_range[] = { 143static const struct regulator_linear_range buck1_volt_range[] = {
144 { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, 144 { .min_uV = 600000, .min_sel = 0, .max_sel = 0x4f, .uV_step = 12500 },
145 .uV_step = 12500 }, 145 { .min_uV = 1600000, .min_sel = 0x50, .max_sel = 0x54,
146 { .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50, 146 .uV_step = 50000 },
147 .max_sel = 0x54, .uV_step = 50000 },
148}; 147};
149 148
150/* BUCK 2~5 have same ranges. */ 149/* BUCK 2~5 have same ranges. */
151static const struct regulator_linear_range buck2_5_volt_range[] = { 150static const struct regulator_linear_range buck2_5_volt_range[] = {
152 { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, 151 { .min_uV = 600000, .min_sel = 0, .max_sel = 0x4f, .uV_step = 12500 },
153 .uV_step = 12500 }, 152 { .min_uV = 1600000, .min_sel = 0x50, .max_sel = 0x72,
154 { .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50, 153 .uV_step = 50000 },
155 .max_sel = 0x72, .uV_step = 50000 },
156}; 154};
157 155
158static const unsigned int ldo1_volt_table[] = { 156static const unsigned int ldo1_volt_table[] = {
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c
index 8406cd745da2..d0a97e5ea431 100644
--- a/drivers/regulator/as3711-regulator.c
+++ b/drivers/regulator/as3711-regulator.c
@@ -117,26 +117,23 @@ static struct regulator_ops as3711_dldo_ops = {
117}; 117};
118 118
119static const struct regulator_linear_range as3711_sd_ranges[] = { 119static const struct regulator_linear_range as3711_sd_ranges[] = {
120 { .min_uV = 612500, .max_uV = 1400000, 120 { .min_uV = 612500, .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 },
121 .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, 121 { .min_uV = 1425000, .min_sel = 0x41, .max_sel = 0x70,
122 { .min_uV = 1425000, .max_uV = 2600000, 122 .uV_step = 25000 },
123 .min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 }, 123 { .min_uV = 2650000, .min_sel = 0x71, .max_sel = 0x7f,
124 { .min_uV = 2650000, .max_uV = 3350000, 124 .uV_step = 50000 },
125 .min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 },
126}; 125};
127 126
128static const struct regulator_linear_range as3711_aldo_ranges[] = { 127static const struct regulator_linear_range as3711_aldo_ranges[] = {
129 { .min_uV = 1200000, .max_uV = 1950000, 128 { .min_uV = 1200000, .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 },
130 .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, 129 { .min_uV = 1800000, .min_sel = 0x10, .max_sel = 0x1f,
131 { .min_uV = 1800000, .max_uV = 3300000, 130 .uV_step = 100000 },
132 .min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 },
133}; 131};
134 132
135static const struct regulator_linear_range as3711_dldo_ranges[] = { 133static const struct regulator_linear_range as3711_dldo_ranges[] = {
136 { .min_uV = 900000, .max_uV = 1700000, 134 { .min_uV = 900000, .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 },
137 .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, 135 { .min_uV = 1750000, .min_sel = 0x20, .max_sel = 0x3f,
138 { .min_uV = 1750000, .max_uV = 3300000, 136 .uV_step = 50000 },
139 .min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 },
140}; 137};
141 138
142#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ 139#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \
diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c
index d7b71a9c41f1..240ae6d2ee2a 100644
--- a/drivers/regulator/as3722-regulator.c
+++ b/drivers/regulator/as3722-regulator.c
@@ -441,7 +441,6 @@ static struct regulator_ops as3722_ldo3_extcntrl_ops = {
441 .max_sel = _max_sel, \ 441 .max_sel = _max_sel, \
442 .uV_step = _step_uV, \ 442 .uV_step = _step_uV, \
443 .min_uV = _min_uV, \ 443 .min_uV = _min_uV, \
444 .max_uV = _min_uV + (_max_sel - _min_sel) * _step_uV, \
445 } 444 }
446 445
447static const struct regulator_linear_range as3722_ldo_ranges[] = { 446static const struct regulator_linear_range as3722_ldo_ranges[] = {
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index f06854cf8cf5..90d55e066447 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -253,10 +253,8 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev,
253} 253}
254 254
255static const struct regulator_linear_range da9034_ldo12_ranges[] = { 255static const struct regulator_linear_range da9034_ldo12_ranges[] = {
256 { .min_uV = 1700000, .max_uV = 2050000, .min_sel = 0, .max_sel = 7, 256 { .min_uV = 1700000, .min_sel = 0, .max_sel = 7, .uV_step = 50000 },
257 .uV_step = 50000 }, 257 { .min_uV = 2700000, .min_sel = 8, .max_sel = 15, .uV_step = 50000 },
258 { .min_uV = 2700000, .max_uV = 3050000, .min_sel = 8, .max_sel = 15,
259 .uV_step = 50000 },
260}; 258};
261 259
262static struct regulator_ops da903x_regulator_ldo_ops = { 260static struct regulator_ops da903x_regulator_ldo_ops = {
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 6e30df14714b..e221a271ba56 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -284,9 +284,13 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
284 } 284 }
285 285
286 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { 286 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
287 int linear_max_uV;
288
287 range = &rdev->desc->linear_ranges[i]; 289 range = &rdev->desc->linear_ranges[i];
290 linear_max_uV = range->min_uV +
291 (range->max_sel - range->min_sel) * range->uV_step;
288 292
289 if (!(min_uV <= range->max_uV && max_uV >= range->min_uV)) 293 if (!(min_uV <= linear_max_uV && max_uV >= range->min_uV))
290 continue; 294 continue;
291 295
292 if (min_uV <= range->min_uV) 296 if (min_uV <= range->min_uV)
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index 90861d68a0b0..484866f43681 100644
--- a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -52,25 +52,17 @@ static const unsigned int LDO1_VSEL_table[] = {
52}; 52};
53 53
54static const struct regulator_linear_range tps65217_uv1_ranges[] = { 54static const struct regulator_linear_range tps65217_uv1_ranges[] = {
55 { .min_uV = 900000, .max_uV = 1500000, .min_sel = 0, .max_sel = 24, 55 { .min_uV = 900000, .min_sel = 0, .max_sel = 24, .uV_step = 25000 },
56 .uV_step = 25000 }, 56 { .min_uV = 1550000, .min_sel = 25, .max_sel = 30, .uV_step = 50000 },
57 { .min_uV = 1550000, .max_uV = 1800000, .min_sel = 25, .max_sel = 30, 57 { .min_uV = 1850000, .min_sel = 31, .max_sel = 52, .uV_step = 50000 },
58 .uV_step = 50000 }, 58 { .min_uV = 3000000, .min_sel = 53, .max_sel = 55, .uV_step = 100000 },
59 { .min_uV = 1850000, .max_uV = 2900000, .min_sel = 31, .max_sel = 52, 59 { .min_uV = 3300000, .min_sel = 56, .max_sel = 62, .uV_step = 0 },
60 .uV_step = 50000 },
61 { .min_uV = 3000000, .max_uV = 3200000, .min_sel = 53, .max_sel = 55,
62 .uV_step = 100000 },
63 { .min_uV = 3300000, .max_uV = 3300000, .min_sel = 56, .max_sel = 62,
64 .uV_step = 0 },
65}; 60};
66 61
67static const struct regulator_linear_range tps65217_uv2_ranges[] = { 62static const struct regulator_linear_range tps65217_uv2_ranges[] = {
68 { .min_uV = 1500000, .max_uV = 1900000, .min_sel = 0, .max_sel = 8, 63 { .min_uV = 1500000, .min_sel = 0, .max_sel = 8, .uV_step = 50000 },
69 .uV_step = 50000 }, 64 { .min_uV = 2000000, .min_sel = 9, .max_sel = 13, .uV_step = 100000 },
70 { .min_uV = 2000000, .max_uV = 2400000, .min_sel = 9, .max_sel = 13, 65 { .min_uV = 2450000, .min_sel = 14, .max_sel = 31, .uV_step = 50000 },
71 .uV_step = 100000 },
72 { .min_uV = 2450000, .max_uV = 3300000, .min_sel = 14, .max_sel = 31,
73 .uV_step = 50000 },
74}; 66};
75 67
76static int tps65217_pmic_enable(struct regulator_dev *dev) 68static int tps65217_pmic_enable(struct regulator_dev *dev)
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 281e52ac64ba..9fc87d8c9ce5 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -119,12 +119,9 @@ struct tps65912_reg {
119}; 119};
120 120
121static const struct regulator_linear_range tps65912_ldo_ranges[] = { 121static const struct regulator_linear_range tps65912_ldo_ranges[] = {
122 { .min_uV = 800000, .max_uV = 1600000, .min_sel = 0, .max_sel = 32, 122 { .min_uV = 800000, .min_sel = 0, .max_sel = 32, .uV_step = 25000 },
123 .uV_step = 25000 }, 123 { .min_uV = 1650000, .min_sel = 33, .max_sel = 60, .uV_step = 50000 },
124 { .min_uV = 1650000, .max_uV = 3000000, .min_sel = 33, .max_sel = 60, 124 { .min_uV = 3100000, .min_sel = 61, .max_sel = 63, .uV_step = 100000 },
125 .uV_step = 50000 },
126 { .min_uV = 3100000, .max_uV = 3300000, .min_sel = 61, .max_sel = 63,
127 .uV_step = 100000 },
128}; 125};
129 126
130static int tps65912_get_range(struct tps65912_reg *pmic, int id) 127static int tps65912_get_range(struct tps65912_reg *pmic, int id)
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index 2205fbc2c37b..a95814027b24 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -63,10 +63,8 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data)
63 */ 63 */
64 64
65static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { 65static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = {
66 { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, 66 { .min_uV = 900000, .min_sel = 0, .max_sel = 14, .uV_step = 50000 },
67 .uV_step = 50000 }, 67 { .min_uV = 1700000, .min_sel = 15, .max_sel = 31, .uV_step = 100000 },
68 { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
69 .uV_step = 100000 },
70}; 68};
71 69
72static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, 70static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev,
@@ -332,10 +330,8 @@ static struct platform_driver wm831x_gp_ldo_driver = {
332 */ 330 */
333 331
334static const struct regulator_linear_range wm831x_aldo_ranges[] = { 332static const struct regulator_linear_range wm831x_aldo_ranges[] = {
335 { .min_uV = 1000000, .max_uV = 1600000, .min_sel = 0, .max_sel = 12, 333 { .min_uV = 1000000, .min_sel = 0, .max_sel = 12, .uV_step = 50000 },
336 .uV_step = 50000 }, 334 { .min_uV = 1700000, .min_sel = 13, .max_sel = 31, .uV_step = 100000 },
337 { .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31,
338 .uV_step = 100000 },
339}; 335};
340 336
341static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, 337static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev,
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 61ca9292a429..de9de26d0bfc 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -543,10 +543,8 @@ static int wm8350_dcdc_set_suspend_mode(struct regulator_dev *rdev,
543} 543}
544 544
545static const struct regulator_linear_range wm8350_ldo_ranges[] = { 545static const struct regulator_linear_range wm8350_ldo_ranges[] = {
546 { .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 15, 546 { .min_uV = 900000, .min_sel = 0, .max_sel = 15, .uV_step = 50000 },
547 .uV_step = 50000 }, 547 { .min_uV = 1800000, .min_sel = 16, .max_sel = 31, .uV_step = 100000 },
548 { .min_uV = 1800000, .max_uV = 3300000, .min_sel = 16, .max_sel = 31,
549 .uV_step = 100000 },
550}; 548};
551 549
552static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) 550static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV)
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 58f51bec13f2..3352b2090ed5 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -20,10 +20,8 @@
20#include <linux/mfd/wm8400-private.h> 20#include <linux/mfd/wm8400-private.h>
21 21
22static const struct regulator_linear_range wm8400_ldo_ranges[] = { 22static const struct regulator_linear_range wm8400_ldo_ranges[] = {
23 { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, 23 { .min_uV = 900000, .min_sel = 0, .max_sel = 14, .uV_step = 50000 },
24 .uV_step = 50000 }, 24 { .min_uV = 1700000, .min_sel = 15, .max_sel = 31, .uV_step = 100000 },
25 { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31,
26 .uV_step = 100000 },
27}; 25};
28 26
29static struct regulator_ops wm8400_ldo_ops = { 27static struct regulator_ops wm8400_ldo_ops = {
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 9bdad43ad228..997ff5c4d880 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -46,14 +46,12 @@ enum regulator_status {
46 * regulator_list_linear_range(). 46 * regulator_list_linear_range().
47 * 47 *
48 * @min_uV: Lowest voltage in range 48 * @min_uV: Lowest voltage in range
49 * @max_uV: Highest voltage in range
50 * @min_sel: Lowest selector for range 49 * @min_sel: Lowest selector for range
51 * @max_sel: Highest selector for range 50 * @max_sel: Highest selector for range
52 * @uV_step: Step size 51 * @uV_step: Step size
53 */ 52 */
54struct regulator_linear_range { 53struct regulator_linear_range {
55 unsigned int min_uV; 54 unsigned int min_uV;
56 unsigned int max_uV;
57 unsigned int min_sel; 55 unsigned int min_sel;
58 unsigned int max_sel; 56 unsigned int max_sel;
59 unsigned int uV_step; 57 unsigned int uV_step;