aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2010-05-04 09:54:51 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-05-25 05:16:02 -0400
commit9f79e9db2e282857912bcfe7f741bcdd5c46e860 (patch)
tree690e0647b56032ef703112e6e03c0b65ddaea10c
parent192bbb95ca16f2b4d4383e76b3262672e6116daa (diff)
regulator: use voltage number array in 88pm860x
A lot of condition comparision statements are used in original driver. These statements are used to check the boundary of voltage numbers since voltage number isn't linear. Now use array of voltage numbers instead. Clean code with simpler way. Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r--drivers/mfd/88pm860x-core.c2
-rw-r--r--drivers/regulator/88pm8607.c482
-rw-r--r--include/linux/mfd/88pm860x.h3
3 files changed, 224 insertions, 263 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 21de38daf948..405d2d5183cf 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -173,6 +173,7 @@ static struct resource regulator_resources[] = {
173 PM8607_REG_RESOURCE(LDO9, LDO9), 173 PM8607_REG_RESOURCE(LDO9, LDO9),
174 PM8607_REG_RESOURCE(LDO10, LDO10), 174 PM8607_REG_RESOURCE(LDO10, LDO10),
175 PM8607_REG_RESOURCE(LDO12, LDO12), 175 PM8607_REG_RESOURCE(LDO12, LDO12),
176 PM8607_REG_RESOURCE(VIBRATOR_SET, VIBRATOR_SET),
176 PM8607_REG_RESOURCE(LDO14, LDO14), 177 PM8607_REG_RESOURCE(LDO14, LDO14),
177}; 178};
178 179
@@ -199,6 +200,7 @@ static struct mfd_cell regulator_devs[] = {
199 PM8607_REG_DEVS(LDO9), 200 PM8607_REG_DEVS(LDO9),
200 PM8607_REG_DEVS(LDO10), 201 PM8607_REG_DEVS(LDO10),
201 PM8607_REG_DEVS(LDO12), 202 PM8607_REG_DEVS(LDO12),
203 PM8607_REG_DEVS(LDO13),
202 PM8607_REG_DEVS(LDO14), 204 PM8607_REG_DEVS(LDO14),
203}; 205};
204 206
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 121bab4c0dc0..7d149a8d8d9b 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -23,9 +23,9 @@ struct pm8607_regulator_info {
23 struct regulator_dev *regulator; 23 struct regulator_dev *regulator;
24 struct i2c_client *i2c; 24 struct i2c_client *i2c;
25 25
26 int min_uV; 26 unsigned int *vol_table;
27 int max_uV; 27 unsigned int *vol_suspend;
28 int step_uV; 28
29 int vol_reg; 29 int vol_reg;
30 int vol_shift; 30 int vol_shift;
31 int vol_nbits; 31 int vol_nbits;
@@ -36,83 +36,189 @@ struct pm8607_regulator_info {
36 int slope_double; 36 int slope_double;
37}; 37};
38 38
39static inline int check_range(struct pm8607_regulator_info *info, 39static const unsigned int BUCK1_table[] = {
40 int min_uV, int max_uV) 40 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,
41{ 41 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
42 if (max_uV < info->min_uV || min_uV > info->max_uV || min_uV > max_uV) 42 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
43 return -EINVAL; 43 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,
44 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
45 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
46 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
47 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
48};
44 49
45 return 0; 50static const unsigned int BUCK1_suspend_table[] = {
46} 51 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
52 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
53 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
54 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
55 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000,
56 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000,
57 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000,
58 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000,
59};
60
61static const unsigned int BUCK2_table[] = {
62 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000,
63 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000,
64 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000,
65 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000,
66 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000,
67 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000,
68 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000,
69 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000,
70};
71
72static const unsigned int BUCK2_suspend_table[] = {
73 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000,
74 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000,
75 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000,
76 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000,
77 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000,
78 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000,
79 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000,
80 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000,
81};
82
83static const unsigned int BUCK3_table[] = {
84 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
85 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
86 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
87 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
88 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000,
89 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000,
90 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000,
91 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000,
92};
93
94static const unsigned int BUCK3_suspend_table[] = {
95 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000,
96 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000,
97 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000,
98 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000,
99 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000,
100 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000,
101 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000,
102 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000,
103};
104
105static const unsigned int LDO1_table[] = {
106 1800000, 1200000, 2800000, 0,
107};
108
109static const unsigned int LDO1_suspend_table[] = {
110 1800000, 1200000, 0, 0,
111};
112
113static const unsigned int LDO2_table[] = {
114 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
115};
116
117static const unsigned int LDO2_suspend_table[] = {
118 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
119};
120
121static const unsigned int LDO3_table[] = {
122 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
123};
124
125static const unsigned int LDO3_suspend_table[] = {
126 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
127};
128
129static const unsigned int LDO4_table[] = {
130 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 3300000,
131};
132
133static const unsigned int LDO4_suspend_table[] = {
134 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 2900000,
135};
136
137static const unsigned int LDO5_table[] = {
138 2900000, 3000000, 3100000, 3300000,
139};
140
141static const unsigned int LDO5_suspend_table[] = {
142 2900000, 0, 0, 0,
143};
144
145static const unsigned int LDO6_table[] = {
146 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 3300000,
147};
148
149static const unsigned int LDO6_suspend_table[] = {
150 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 2900000,
151};
152
153static const unsigned int LDO7_table[] = {
154 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
155};
156
157static const unsigned int LDO7_suspend_table[] = {
158 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
159};
160
161static const unsigned int LDO8_table[] = {
162 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
163};
164
165static const unsigned int LDO8_suspend_table[] = {
166 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
167};
168
169static const unsigned int LDO9_table[] = {
170 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
171};
172
173static const unsigned int LDO9_suspend_table[] = {
174 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
175};
176
177static const unsigned int LDO10_table[] = {
178 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000,
179 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
180};
181
182static const unsigned int LDO10_suspend_table[] = {
183 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000,
184 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
185};
186
187static const unsigned int LDO12_table[] = {
188 1800000, 1900000, 2700000, 2800000, 2900000, 3000000, 3100000, 3300000,
189 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
190};
191
192static const unsigned int LDO12_suspend_table[] = {
193 1800000, 1900000, 2700000, 2800000, 2900000, 2900000, 2900000, 2900000,
194 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000,
195};
196
197static const unsigned int LDO13_table[] = {
198 1300000, 1800000, 2000000, 2500000, 2800000, 3000000, 0, 0,
199};
200
201static const unsigned int LDO13_suspend_table[] = {
202 0,
203};
204
205static const unsigned int LDO14_table[] = {
206 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 3300000,
207};
208
209static const unsigned int LDO14_suspend_table[] = {
210 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 2900000,
211};
47 212
48static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) 213static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
49{ 214{
50 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 215 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
51 int ret = -EINVAL; 216 int ret = -EINVAL;
52 217
53 switch (info->desc.id) { 218 if (info->vol_table && (index < (2 << info->vol_nbits))) {
54 case PM8607_ID_BUCK1: 219 ret = info->vol_table[index];
55 ret = (index < 0x1d) ? (index * 25000 + 800000) :
56 ((index < 0x20) ? 1500000 :
57 ((index < 0x40) ? ((index - 0x20) * 25000) :
58 -EINVAL));
59 break;
60 case PM8607_ID_BUCK3:
61 ret = (index < 0x3d) ? (index * 25000) :
62 ((index < 0x40) ? 1500000 : -EINVAL);
63 if (ret < 0)
64 break;
65 if (info->slope_double) 220 if (info->slope_double)
66 ret <<= 1; 221 ret <<= 1;
67 break;
68 case PM8607_ID_LDO1:
69 ret = (index == 0) ? 1800000 :
70 ((index == 1) ? 1200000 :
71 ((index == 2) ? 2800000 : -EINVAL));
72 break;
73 case PM8607_ID_LDO5:
74 ret = (index == 0) ? 2900000 :
75 ((index == 1) ? 3000000 :
76 ((index == 2) ? 3100000 : 3300000));
77 break;
78 case PM8607_ID_LDO7:
79 case PM8607_ID_LDO8:
80 ret = (index < 3) ? (index * 50000 + 1800000) :
81 ((index < 8) ? (index * 50000 + 2550000) :
82 -EINVAL);
83 break;
84 case PM8607_ID_LDO12:
85 ret = (index < 2) ? (index * 100000 + 1800000) :
86 ((index < 7) ? (index * 100000 + 2500000) :
87 ((index == 7) ? 3300000 : 1200000));
88 break;
89 case PM8607_ID_LDO2:
90 case PM8607_ID_LDO3:
91 case PM8607_ID_LDO9:
92 ret = (index < 3) ? (index * 50000 + 1800000) :
93 ((index < 7) ? (index * 50000 + 2550000) :
94 3300000);
95 break;
96 case PM8607_ID_LDO4:
97 ret = (index < 3) ? (index * 50000 + 1800000) :
98 ((index < 6) ? (index * 50000 + 2550000) :
99 ((index == 6) ? 2900000 : 3300000));
100 break;
101 case PM8607_ID_LDO6:
102 ret = (index < 2) ? (index * 50000 + 1800000) :
103 ((index < 7) ? (index * 50000 + 2500000) :
104 3300000);
105 break;
106 case PM8607_ID_LDO10:
107 ret = (index < 3) ? (index * 50000 + 1800000) :
108 ((index < 7) ? (index * 50000 + 2550000) :
109 ((index == 7) ? 3300000 : 1200000));
110 break;
111 case PM8607_ID_LDO14:
112 ret = (index < 2) ? (index * 50000 + 1800000) :
113 ((index < 7) ? (index * 50000 + 2600000) :
114 3300000);
115 break;
116 } 222 }
117 return ret; 223 return ret;
118} 224}
@@ -120,174 +226,26 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
120static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) 226static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
121{ 227{
122 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 228 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
123 int val = -ENOENT; 229 int i, ret = -ENOENT;
124 int ret;
125 230
126 switch (info->desc.id) { 231 if (info->slope_double) {
127 case PM8607_ID_BUCK1: 232 min_uV = min_uV >> 1;
128 if (min_uV >= 800000) /* 800mV ~ 1500mV / 25mV */ 233 max_uV = max_uV >> 1;
129 val = (min_uV - 775001) / 25000;
130 else { /* 25mV ~ 775mV / 25mV */
131 val = (min_uV + 249999) / 25000;
132 val += 32;
133 }
134 break;
135 case PM8607_ID_BUCK3:
136 if (info->slope_double)
137 min_uV = min_uV >> 1;
138 val = (min_uV + 249999) / 25000; /* 0mV ~ 1500mV / 25mV */
139
140 break;
141 case PM8607_ID_LDO1:
142 if (min_uV > 1800000)
143 val = 2;
144 else if (min_uV > 1200000)
145 val = 0;
146 else
147 val = 1;
148 break;
149 case PM8607_ID_LDO5:
150 if (min_uV > 3100000)
151 val = 3;
152 else /* 2900mV ~ 3100mV / 100mV */
153 val = (min_uV - 2800001) / 100000;
154 break;
155 case PM8607_ID_LDO7:
156 case PM8607_ID_LDO8:
157 if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
158 if (min_uV <= 1800000)
159 val = 0; /* 1800mv */
160 else if (min_uV <= 1900000)
161 val = (min_uV - 1750001) / 50000;
162 else
163 val = 3; /* 2700mV */
164 } else { /* 2700mV ~ 2900mV / 50mV */
165 if (min_uV <= 2900000) {
166 val = (min_uV - 2650001) / 50000;
167 val += 3;
168 } else
169 val = -EINVAL;
170 }
171 break;
172 case PM8607_ID_LDO10:
173 if (min_uV > 2850000)
174 val = 7;
175 else if (min_uV <= 1200000)
176 val = 8;
177 else if (min_uV < 2700000) /* 1800mV ~ 1900mV / 50mV */
178 val = (min_uV - 1750001) / 50000;
179 else { /* 2700mV ~ 2850mV / 50mV */
180 val = (min_uV - 2650001) / 50000;
181 val += 3;
182 }
183 break;
184 case PM8607_ID_LDO12:
185 if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 100mV */
186 if (min_uV <= 1200000)
187 val = 8; /* 1200mV */
188 else if (min_uV <= 1800000)
189 val = 0; /* 1800mV */
190 else if (min_uV <= 1900000)
191 val = (min_uV - 1700001) / 100000;
192 else
193 val = 2; /* 2700mV */
194 } else { /* 2700mV ~ 3100mV / 100mV */
195 if (min_uV <= 3100000) {
196 val = (min_uV - 2600001) / 100000;
197 val += 2;
198 } else if (min_uV <= 3300000)
199 val = 7;
200 else
201 val = -EINVAL;
202 }
203 break;
204 case PM8607_ID_LDO2:
205 case PM8607_ID_LDO3:
206 case PM8607_ID_LDO9:
207 if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
208 if (min_uV <= 1800000)
209 val = 0;
210 else if (min_uV <= 1900000)
211 val = (min_uV - 1750001) / 50000;
212 else
213 val = 3; /* 2700mV */
214 } else { /* 2700mV ~ 2850mV / 50mV */
215 if (min_uV <= 2850000) {
216 val = (min_uV - 2650001) / 50000;
217 val += 3;
218 } else if (min_uV <= 3300000)
219 val = 7;
220 else
221 val = -EINVAL;
222 }
223 break;
224 case PM8607_ID_LDO4:
225 if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
226 if (min_uV <= 1800000)
227 val = 0;
228 else if (min_uV <= 1900000)
229 val = (min_uV - 1750001) / 50000;
230 else
231 val = 3; /* 2700mV */
232 } else { /* 2700mV ~ 2800mV / 50mV */
233 if (min_uV <= 2850000) {
234 val = (min_uV - 2650001) / 50000;
235 val += 3;
236 } else if (min_uV <= 2900000)
237 val = 6;
238 else if (min_uV <= 3300000)
239 val = 7;
240 else
241 val = -EINVAL;
242 }
243 break;
244 case PM8607_ID_LDO6:
245 if (min_uV < 2600000) { /* 1800mV ~ 1850mV / 50mV */
246 if (min_uV <= 1800000)
247 val = 0;
248 else if (min_uV <= 1850000)
249 val = (min_uV - 1750001) / 50000;
250 else
251 val = 2; /* 2600mV */
252 } else { /* 2600mV ~ 2800mV / 50mV */
253 if (min_uV <= 2800000) {
254 val = (min_uV - 2550001) / 50000;
255 val += 2;
256 } else if (min_uV <= 3300000)
257 val = 7;
258 else
259 val = -EINVAL;
260 }
261 break;
262 case PM8607_ID_LDO14:
263 if (min_uV < 2700000) { /* 1800mV ~ 1850mV / 50mV */
264 if (min_uV <= 1800000)
265 val = 0;
266 else if (min_uV <= 1850000)
267 val = (min_uV - 1750001) / 50000;
268 else
269 val = 2; /* 2700mV */
270 } else { /* 2700mV ~ 2900mV / 50mV */
271 if (min_uV <= 2900000) {
272 val = (min_uV - 2650001) / 50000;
273 val += 2;
274 } else if (min_uV <= 3300000)
275 val = 7;
276 else
277 val = -EINVAL;
278 }
279 break;
280 } 234 }
281 if (val >= 0) { 235 if (info->vol_table) {
282 ret = pm8607_list_voltage(rdev, val); 236 for (i = 0; i < (2 << info->vol_nbits); i++) {
283 if (ret > max_uV) { 237 if (!info->vol_table[i])
284 pr_err("exceed voltage range (%d %d) uV", 238 break;
285 min_uV, max_uV); 239 if ((min_uV <= info->vol_table[i])
286 return -EINVAL; 240 && (max_uV >= info->vol_table[i])) {
241 ret = i;
242 break;
243 }
287 } 244 }
288 } else 245 }
289 pr_err("invalid voltage range (%d %d) uV", min_uV, max_uV); 246 if (ret < 0)
290 return val; 247 pr_err("invalid voltage range (%d %d) uV\n", min_uV, max_uV);
248 return ret;
291} 249}
292 250
293static int pm8607_set_voltage(struct regulator_dev *rdev, 251static int pm8607_set_voltage(struct regulator_dev *rdev,
@@ -297,7 +255,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
297 uint8_t val, mask; 255 uint8_t val, mask;
298 int ret; 256 int ret;
299 257
300 if (check_range(info, min_uV, max_uV)) { 258 if (min_uV > max_uV) {
301 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV); 259 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
302 return -EINVAL; 260 return -EINVAL;
303 } 261 }
@@ -375,18 +333,15 @@ static struct regulator_ops pm8607_regulator_ops = {
375 .is_enabled = pm8607_is_enabled, 333 .is_enabled = pm8607_is_enabled,
376}; 334};
377 335
378#define PM8607_DVC(_id, min, max, step, vreg, nbits, ureg, ubit, ereg, ebit) \ 336#define PM8607_DVC(vreg, nbits, ureg, ubit, ereg, ebit) \
379{ \ 337{ \
380 .desc = { \ 338 .desc = { \
381 .name = "BUCK" #_id, \ 339 .name = #vreg, \
382 .ops = &pm8607_regulator_ops, \ 340 .ops = &pm8607_regulator_ops, \
383 .type = REGULATOR_VOLTAGE, \ 341 .type = REGULATOR_VOLTAGE, \
384 .id = PM8607_ID_BUCK##_id, \ 342 .id = PM8607_ID_##vreg, \
385 .owner = THIS_MODULE, \ 343 .owner = THIS_MODULE, \
386 }, \ 344 }, \
387 .min_uV = (min) * 1000, \
388 .max_uV = (max) * 1000, \
389 .step_uV = (step) * 1000, \
390 .vol_reg = PM8607_##vreg, \ 345 .vol_reg = PM8607_##vreg, \
391 .vol_shift = (0), \ 346 .vol_shift = (0), \
392 .vol_nbits = (nbits), \ 347 .vol_nbits = (nbits), \
@@ -395,9 +350,11 @@ static struct regulator_ops pm8607_regulator_ops = {
395 .enable_reg = PM8607_##ereg, \ 350 .enable_reg = PM8607_##ereg, \
396 .enable_bit = (ebit), \ 351 .enable_bit = (ebit), \
397 .slope_double = (0), \ 352 .slope_double = (0), \
353 .vol_table = (unsigned int *)&vreg##_table, \
354 .vol_suspend = (unsigned int *)&vreg##_suspend_table, \
398} 355}
399 356
400#define PM8607_LDO(_id, min, max, step, vreg, shift, nbits, ereg, ebit) \ 357#define PM8607_LDO(_id, vreg, shift, nbits, ereg, ebit) \
401{ \ 358{ \
402 .desc = { \ 359 .desc = { \
403 .name = "LDO" #_id, \ 360 .name = "LDO" #_id, \
@@ -406,33 +363,34 @@ static struct regulator_ops pm8607_regulator_ops = {
406 .id = PM8607_ID_LDO##_id, \ 363 .id = PM8607_ID_LDO##_id, \
407 .owner = THIS_MODULE, \ 364 .owner = THIS_MODULE, \
408 }, \ 365 }, \
409 .min_uV = (min) * 1000, \
410 .max_uV = (max) * 1000, \
411 .step_uV = (step) * 1000, \
412 .vol_reg = PM8607_##vreg, \ 366 .vol_reg = PM8607_##vreg, \
413 .vol_shift = (shift), \ 367 .vol_shift = (shift), \
414 .vol_nbits = (nbits), \ 368 .vol_nbits = (nbits), \
415 .enable_reg = PM8607_##ereg, \ 369 .enable_reg = PM8607_##ereg, \
416 .enable_bit = (ebit), \ 370 .enable_bit = (ebit), \
417 .slope_double = (0), \ 371 .slope_double = (0), \
372 .vol_table = (unsigned int *)&LDO##_id##_table, \
373 .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \
418} 374}
419 375
420static struct pm8607_regulator_info pm8607_regulator_info[] = { 376static struct pm8607_regulator_info pm8607_regulator_info[] = {
421 PM8607_DVC(1, 0, 1500, 25, BUCK1, 6, GO, 0, SUPPLIES_EN11, 0), 377 PM8607_DVC(BUCK1, 6, GO, 0, SUPPLIES_EN11, 0),
422 PM8607_DVC(3, 0, 1500, 25, BUCK3, 6, GO, 2, SUPPLIES_EN11, 2), 378 PM8607_DVC(BUCK2, 6, GO, 1, SUPPLIES_EN11, 1),
423 379 PM8607_DVC(BUCK3, 6, GO, 2, SUPPLIES_EN11, 2),
424 PM8607_LDO(1 , 1200, 2800, 0, LDO1 , 0, 2, SUPPLIES_EN11, 3), 380
425 PM8607_LDO(2 , 1800, 3300, 0, LDO2 , 0, 3, SUPPLIES_EN11, 4), 381 PM8607_LDO( 1, LDO1, 0, 2, SUPPLIES_EN11, 3),
426 PM8607_LDO(3 , 1800, 3300, 0, LDO3 , 0, 3, SUPPLIES_EN11, 5), 382 PM8607_LDO( 2, LDO2, 0, 3, SUPPLIES_EN11, 4),
427 PM8607_LDO(4 , 1800, 3300, 0, LDO4 , 0, 3, SUPPLIES_EN11, 6), 383 PM8607_LDO( 3, LDO3, 0, 3, SUPPLIES_EN11, 5),
428 PM8607_LDO(5 , 2900, 3300, 0, LDO5 , 0, 2, SUPPLIES_EN11, 7), 384 PM8607_LDO( 4, LDO4, 0, 3, SUPPLIES_EN11, 6),
429 PM8607_LDO(6 , 1800, 3300, 0, LDO6 , 0, 3, SUPPLIES_EN12, 0), 385 PM8607_LDO( 5, LDO5, 0, 2, SUPPLIES_EN11, 7),
430 PM8607_LDO(7 , 1800, 2900, 0, LDO7 , 0, 3, SUPPLIES_EN12, 1), 386 PM8607_LDO( 6, LDO6, 0, 3, SUPPLIES_EN12, 0),
431 PM8607_LDO(8 , 1800, 2900, 0, LDO8 , 0, 3, SUPPLIES_EN12, 2), 387 PM8607_LDO( 7, LDO7, 0, 3, SUPPLIES_EN12, 1),
432 PM8607_LDO(9 , 1800, 3300, 0, LDO9 , 0, 3, SUPPLIES_EN12, 3), 388 PM8607_LDO( 8, LDO8, 0, 3, SUPPLIES_EN12, 2),
433 PM8607_LDO(10, 1200, 3300, 0, LDO10, 0, 4, SUPPLIES_EN11, 4), 389 PM8607_LDO( 9, LDO9, 0, 3, SUPPLIES_EN12, 3),
434 PM8607_LDO(12, 1200, 3300, 0, LDO12, 0, 4, SUPPLIES_EN11, 5), 390 PM8607_LDO(10, LDO10, 0, 3, SUPPLIES_EN12, 4),
435 PM8607_LDO(14, 1800, 3300, 0, LDO14, 0, 3, SUPPLIES_EN11, 6), 391 PM8607_LDO(12, LDO12, 0, 4, SUPPLIES_EN12, 5),
392 PM8607_LDO(13, VIBRATOR_SET, 1, 3, VIBRATOR_SET, 0),
393 PM8607_LDO(14, LDO14, 0, 4, SUPPLIES_EN12, 6),
436}; 394};
437 395
438static inline struct pm8607_regulator_info *find_regulator_info(int id) 396static inline struct pm8607_regulator_info *find_regulator_info(int id)
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h
index 73f92c5feea2..e3c4ff8c3e38 100644
--- a/include/linux/mfd/88pm860x.h
+++ b/include/linux/mfd/88pm860x.h
@@ -132,6 +132,7 @@ enum {
132 PM8607_ID_LDO9, 132 PM8607_ID_LDO9,
133 PM8607_ID_LDO10, 133 PM8607_ID_LDO10,
134 PM8607_ID_LDO12, 134 PM8607_ID_LDO12,
135 PM8607_ID_LDO13,
135 PM8607_ID_LDO14, 136 PM8607_ID_LDO14,
136 137
137 PM8607_ID_RG_MAX, 138 PM8607_ID_RG_MAX,
@@ -309,7 +310,7 @@ struct pm860x_chip {
309 310
310}; 311};
311 312
312#define PM8607_MAX_REGULATOR 15 /* 3 Bucks, 12 LDOs */ 313#define PM8607_MAX_REGULATOR PM8607_ID_RG_MAX /* 3 Bucks, 13 LDOs */
313 314
314enum { 315enum {
315 GI2C_PORT = 0, 316 GI2C_PORT = 0,