Commit | Line | Data |
---|---|---|
be0e2d3e HZ |
1 | /* |
2 | * Regulators driver for Marvell 88PM8607 | |
3 | * | |
4 | * Copyright (C) 2009 Marvell International Ltd. | |
5 | * Haojian Zhuang <haojian.zhuang@marvell.com> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | */ | |
11 | #include <linux/kernel.h> | |
12 | #include <linux/init.h> | |
13 | #include <linux/err.h> | |
53dbab7a | 14 | #include <linux/i2c.h> |
be0e2d3e HZ |
15 | #include <linux/platform_device.h> |
16 | #include <linux/regulator/driver.h> | |
17 | #include <linux/regulator/machine.h> | |
53dbab7a | 18 | #include <linux/mfd/88pm860x.h> |
65602c32 | 19 | #include <linux/module.h> |
be0e2d3e HZ |
20 | |
21 | struct pm8607_regulator_info { | |
22 | struct regulator_desc desc; | |
53dbab7a | 23 | struct pm860x_chip *chip; |
be0e2d3e | 24 | struct regulator_dev *regulator; |
53dbab7a | 25 | struct i2c_client *i2c; |
be0e2d3e | 26 | |
9f79e9db HZ |
27 | unsigned int *vol_table; |
28 | unsigned int *vol_suspend; | |
29 | ||
be0e2d3e HZ |
30 | int vol_reg; |
31 | int vol_shift; | |
32 | int vol_nbits; | |
33 | int update_reg; | |
34 | int update_bit; | |
35 | int enable_reg; | |
36 | int enable_bit; | |
37 | int slope_double; | |
38 | }; | |
39 | ||
9f79e9db HZ |
40 | static const unsigned int BUCK1_table[] = { |
41 | 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000, | |
42 | 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, | |
43 | 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000, | |
44 | 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000, | |
45 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | |
46 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | |
47 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | |
48 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | |
49 | }; | |
be0e2d3e | 50 | |
9f79e9db HZ |
51 | static const unsigned int BUCK1_suspend_table[] = { |
52 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | |
53 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | |
54 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | |
55 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | |
56 | 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000, | |
57 | 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, | |
58 | 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, | |
59 | 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000, | |
60 | }; | |
61 | ||
62 | static const unsigned int BUCK2_table[] = { | |
63 | 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000, | |
64 | 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000, | |
65 | 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000, | |
66 | 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000, | |
67 | 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000, | |
68 | 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000, | |
69 | 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000, | |
70 | 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000, | |
71 | }; | |
72 | ||
73 | static const unsigned int BUCK2_suspend_table[] = { | |
74 | 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000, | |
75 | 400000, 450000, 500000, 550000, 600000, 650000, 700000, 750000, | |
76 | 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000, 1150000, | |
77 | 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000, 1550000, | |
78 | 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000, 1950000, | |
79 | 2000000, 2050000, 2100000, 2150000, 2200000, 2250000, 2300000, 2350000, | |
80 | 2400000, 2450000, 2500000, 2550000, 2600000, 2650000, 2700000, 2750000, | |
81 | 2800000, 2850000, 2900000, 2950000, 3000000, 3000000, 3000000, 3000000, | |
82 | }; | |
83 | ||
84 | static const unsigned int BUCK3_table[] = { | |
85 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | |
86 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | |
87 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | |
88 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | |
89 | 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000, | |
90 | 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, | |
91 | 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, | |
92 | 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000, | |
93 | }; | |
94 | ||
95 | static const unsigned int BUCK3_suspend_table[] = { | |
96 | 0, 25000, 50000, 75000, 100000, 125000, 150000, 175000, | |
97 | 200000, 225000, 250000, 275000, 300000, 325000, 350000, 375000, | |
98 | 400000, 425000, 450000, 475000, 500000, 525000, 550000, 575000, | |
99 | 600000, 625000, 650000, 675000, 700000, 725000, 750000, 775000, | |
100 | 800000, 825000, 850000, 875000, 900000, 925000, 950000, 975000, | |
101 | 1000000, 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, | |
102 | 1200000, 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, | |
103 | 1400000, 1425000, 1450000, 1475000, 1500000, 1500000, 1500000, 1500000, | |
104 | }; | |
105 | ||
106 | static const unsigned int LDO1_table[] = { | |
107 | 1800000, 1200000, 2800000, 0, | |
108 | }; | |
109 | ||
110 | static const unsigned int LDO1_suspend_table[] = { | |
111 | 1800000, 1200000, 0, 0, | |
112 | }; | |
113 | ||
114 | static const unsigned int LDO2_table[] = { | |
115 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | |
116 | }; | |
117 | ||
118 | static const unsigned int LDO2_suspend_table[] = { | |
119 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
120 | }; | |
121 | ||
122 | static const unsigned int LDO3_table[] = { | |
123 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | |
124 | }; | |
125 | ||
126 | static const unsigned int LDO3_suspend_table[] = { | |
127 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
128 | }; | |
129 | ||
130 | static const unsigned int LDO4_table[] = { | |
131 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 3300000, | |
132 | }; | |
133 | ||
134 | static const unsigned int LDO4_suspend_table[] = { | |
135 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2900000, 2900000, | |
136 | }; | |
137 | ||
138 | static const unsigned int LDO5_table[] = { | |
139 | 2900000, 3000000, 3100000, 3300000, | |
140 | }; | |
141 | ||
142 | static const unsigned int LDO5_suspend_table[] = { | |
143 | 2900000, 0, 0, 0, | |
144 | }; | |
145 | ||
146 | static const unsigned int LDO6_table[] = { | |
147 | 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 3300000, | |
148 | }; | |
149 | ||
150 | static const unsigned int LDO6_suspend_table[] = { | |
151 | 1800000, 1850000, 2600000, 2650000, 2700000, 2750000, 2800000, 2900000, | |
152 | }; | |
153 | ||
154 | static const unsigned int LDO7_table[] = { | |
155 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
156 | }; | |
157 | ||
158 | static const unsigned int LDO7_suspend_table[] = { | |
159 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
160 | }; | |
161 | ||
162 | static const unsigned int LDO8_table[] = { | |
163 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
164 | }; | |
165 | ||
166 | static const unsigned int LDO8_suspend_table[] = { | |
167 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
168 | }; | |
169 | ||
170 | static const unsigned int LDO9_table[] = { | |
171 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | |
172 | }; | |
173 | ||
174 | static const unsigned int LDO9_suspend_table[] = { | |
175 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
176 | }; | |
177 | ||
178 | static const unsigned int LDO10_table[] = { | |
179 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 3300000, | |
180 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | |
181 | }; | |
182 | ||
183 | static const unsigned int LDO10_suspend_table[] = { | |
184 | 1800000, 1850000, 1900000, 2700000, 2750000, 2800000, 2850000, 2900000, | |
185 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | |
186 | }; | |
187 | ||
188 | static const unsigned int LDO12_table[] = { | |
189 | 1800000, 1900000, 2700000, 2800000, 2900000, 3000000, 3100000, 3300000, | |
190 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | |
191 | }; | |
192 | ||
193 | static const unsigned int LDO12_suspend_table[] = { | |
194 | 1800000, 1900000, 2700000, 2800000, 2900000, 2900000, 2900000, 2900000, | |
195 | 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, 1200000, | |
196 | }; | |
197 | ||
198 | static const unsigned int LDO13_table[] = { | |
3380643b | 199 | 1200000, 1300000, 1800000, 2000000, 2500000, 2800000, 3000000, 0, |
9f79e9db HZ |
200 | }; |
201 | ||
202 | static const unsigned int LDO13_suspend_table[] = { | |
203 | 0, | |
204 | }; | |
205 | ||
206 | static const unsigned int LDO14_table[] = { | |
207 | 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 3300000, | |
208 | }; | |
209 | ||
210 | static const unsigned int LDO14_suspend_table[] = { | |
211 | 1800000, 1850000, 2700000, 2750000, 2800000, 2850000, 2900000, 2900000, | |
212 | }; | |
be0e2d3e HZ |
213 | |
214 | static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index) | |
215 | { | |
216 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
be0e2d3e HZ |
217 | int ret = -EINVAL; |
218 | ||
d06563cb | 219 | if (info->vol_table && (index < (1 << info->vol_nbits))) { |
9f79e9db | 220 | ret = info->vol_table[index]; |
be0e2d3e HZ |
221 | if (info->slope_double) |
222 | ret <<= 1; | |
be0e2d3e HZ |
223 | } |
224 | return ret; | |
225 | } | |
226 | ||
227 | static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV) | |
228 | { | |
229 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
9f79e9db | 230 | int i, ret = -ENOENT; |
be0e2d3e | 231 | |
9f79e9db HZ |
232 | if (info->slope_double) { |
233 | min_uV = min_uV >> 1; | |
234 | max_uV = max_uV >> 1; | |
be0e2d3e | 235 | } |
9f79e9db | 236 | if (info->vol_table) { |
d06563cb | 237 | for (i = 0; i < (1 << info->vol_nbits); i++) { |
9f79e9db HZ |
238 | if (!info->vol_table[i]) |
239 | break; | |
240 | if ((min_uV <= info->vol_table[i]) | |
241 | && (max_uV >= info->vol_table[i])) { | |
242 | ret = i; | |
243 | break; | |
244 | } | |
be0e2d3e | 245 | } |
9f79e9db HZ |
246 | } |
247 | if (ret < 0) | |
248 | pr_err("invalid voltage range (%d %d) uV\n", min_uV, max_uV); | |
249 | return ret; | |
be0e2d3e HZ |
250 | } |
251 | ||
252 | static int pm8607_set_voltage(struct regulator_dev *rdev, | |
3a93f2a9 | 253 | int min_uV, int max_uV, unsigned *selector) |
be0e2d3e HZ |
254 | { |
255 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
be0e2d3e HZ |
256 | uint8_t val, mask; |
257 | int ret; | |
258 | ||
9f79e9db | 259 | if (min_uV > max_uV) { |
be0e2d3e HZ |
260 | pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV); |
261 | return -EINVAL; | |
262 | } | |
263 | ||
264 | ret = choose_voltage(rdev, min_uV, max_uV); | |
265 | if (ret < 0) | |
266 | return -EINVAL; | |
3a93f2a9 | 267 | *selector = ret; |
be0e2d3e HZ |
268 | val = (uint8_t)(ret << info->vol_shift); |
269 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | |
270 | ||
53dbab7a | 271 | ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val); |
be0e2d3e HZ |
272 | if (ret) |
273 | return ret; | |
274 | switch (info->desc.id) { | |
275 | case PM8607_ID_BUCK1: | |
276 | case PM8607_ID_BUCK3: | |
53dbab7a | 277 | ret = pm860x_set_bits(info->i2c, info->update_reg, |
be0e2d3e HZ |
278 | 1 << info->update_bit, |
279 | 1 << info->update_bit); | |
280 | break; | |
281 | } | |
282 | return ret; | |
283 | } | |
284 | ||
285 | static int pm8607_get_voltage(struct regulator_dev *rdev) | |
286 | { | |
287 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
be0e2d3e HZ |
288 | uint8_t val, mask; |
289 | int ret; | |
290 | ||
53dbab7a | 291 | ret = pm860x_reg_read(info->i2c, info->vol_reg); |
be0e2d3e HZ |
292 | if (ret < 0) |
293 | return ret; | |
294 | ||
295 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | |
296 | val = ((unsigned char)ret & mask) >> info->vol_shift; | |
297 | ||
298 | return pm8607_list_voltage(rdev, val); | |
299 | } | |
300 | ||
301 | static int pm8607_enable(struct regulator_dev *rdev) | |
302 | { | |
303 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
be0e2d3e | 304 | |
53dbab7a | 305 | return pm860x_set_bits(info->i2c, info->enable_reg, |
be0e2d3e HZ |
306 | 1 << info->enable_bit, |
307 | 1 << info->enable_bit); | |
308 | } | |
309 | ||
310 | static int pm8607_disable(struct regulator_dev *rdev) | |
311 | { | |
312 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
be0e2d3e | 313 | |
53dbab7a | 314 | return pm860x_set_bits(info->i2c, info->enable_reg, |
be0e2d3e HZ |
315 | 1 << info->enable_bit, 0); |
316 | } | |
317 | ||
318 | static int pm8607_is_enabled(struct regulator_dev *rdev) | |
319 | { | |
320 | struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); | |
be0e2d3e HZ |
321 | int ret; |
322 | ||
53dbab7a | 323 | ret = pm860x_reg_read(info->i2c, info->enable_reg); |
be0e2d3e HZ |
324 | if (ret < 0) |
325 | return ret; | |
326 | ||
327 | return !!((unsigned char)ret & (1 << info->enable_bit)); | |
328 | } | |
329 | ||
330 | static struct regulator_ops pm8607_regulator_ops = { | |
d3d7bccc | 331 | .list_voltage = pm8607_list_voltage, |
be0e2d3e HZ |
332 | .set_voltage = pm8607_set_voltage, |
333 | .get_voltage = pm8607_get_voltage, | |
334 | .enable = pm8607_enable, | |
335 | .disable = pm8607_disable, | |
336 | .is_enabled = pm8607_is_enabled, | |
337 | }; | |
338 | ||
9f79e9db | 339 | #define PM8607_DVC(vreg, nbits, ureg, ubit, ereg, ebit) \ |
be0e2d3e HZ |
340 | { \ |
341 | .desc = { \ | |
9f79e9db | 342 | .name = #vreg, \ |
be0e2d3e HZ |
343 | .ops = &pm8607_regulator_ops, \ |
344 | .type = REGULATOR_VOLTAGE, \ | |
9f79e9db | 345 | .id = PM8607_ID_##vreg, \ |
be0e2d3e HZ |
346 | .owner = THIS_MODULE, \ |
347 | }, \ | |
be0e2d3e HZ |
348 | .vol_reg = PM8607_##vreg, \ |
349 | .vol_shift = (0), \ | |
350 | .vol_nbits = (nbits), \ | |
351 | .update_reg = PM8607_##ureg, \ | |
352 | .update_bit = (ubit), \ | |
353 | .enable_reg = PM8607_##ereg, \ | |
354 | .enable_bit = (ebit), \ | |
355 | .slope_double = (0), \ | |
9f79e9db HZ |
356 | .vol_table = (unsigned int *)&vreg##_table, \ |
357 | .vol_suspend = (unsigned int *)&vreg##_suspend_table, \ | |
be0e2d3e HZ |
358 | } |
359 | ||
9f79e9db | 360 | #define PM8607_LDO(_id, vreg, shift, nbits, ereg, ebit) \ |
be0e2d3e HZ |
361 | { \ |
362 | .desc = { \ | |
363 | .name = "LDO" #_id, \ | |
364 | .ops = &pm8607_regulator_ops, \ | |
365 | .type = REGULATOR_VOLTAGE, \ | |
366 | .id = PM8607_ID_LDO##_id, \ | |
367 | .owner = THIS_MODULE, \ | |
368 | }, \ | |
be0e2d3e HZ |
369 | .vol_reg = PM8607_##vreg, \ |
370 | .vol_shift = (shift), \ | |
371 | .vol_nbits = (nbits), \ | |
372 | .enable_reg = PM8607_##ereg, \ | |
373 | .enable_bit = (ebit), \ | |
374 | .slope_double = (0), \ | |
9f79e9db HZ |
375 | .vol_table = (unsigned int *)&LDO##_id##_table, \ |
376 | .vol_suspend = (unsigned int *)&LDO##_id##_suspend_table, \ | |
be0e2d3e HZ |
377 | } |
378 | ||
379 | static struct pm8607_regulator_info pm8607_regulator_info[] = { | |
9f79e9db HZ |
380 | PM8607_DVC(BUCK1, 6, GO, 0, SUPPLIES_EN11, 0), |
381 | PM8607_DVC(BUCK2, 6, GO, 1, SUPPLIES_EN11, 1), | |
382 | PM8607_DVC(BUCK3, 6, GO, 2, SUPPLIES_EN11, 2), | |
383 | ||
384 | PM8607_LDO( 1, LDO1, 0, 2, SUPPLIES_EN11, 3), | |
385 | PM8607_LDO( 2, LDO2, 0, 3, SUPPLIES_EN11, 4), | |
386 | PM8607_LDO( 3, LDO3, 0, 3, SUPPLIES_EN11, 5), | |
387 | PM8607_LDO( 4, LDO4, 0, 3, SUPPLIES_EN11, 6), | |
388 | PM8607_LDO( 5, LDO5, 0, 2, SUPPLIES_EN11, 7), | |
389 | PM8607_LDO( 6, LDO6, 0, 3, SUPPLIES_EN12, 0), | |
390 | PM8607_LDO( 7, LDO7, 0, 3, SUPPLIES_EN12, 1), | |
391 | PM8607_LDO( 8, LDO8, 0, 3, SUPPLIES_EN12, 2), | |
392 | PM8607_LDO( 9, LDO9, 0, 3, SUPPLIES_EN12, 3), | |
3380643b | 393 | PM8607_LDO(10, LDO10, 0, 4, SUPPLIES_EN12, 4), |
9f79e9db HZ |
394 | PM8607_LDO(12, LDO12, 0, 4, SUPPLIES_EN12, 5), |
395 | PM8607_LDO(13, VIBRATOR_SET, 1, 3, VIBRATOR_SET, 0), | |
3380643b | 396 | PM8607_LDO(14, LDO14, 0, 3, SUPPLIES_EN12, 6), |
be0e2d3e HZ |
397 | }; |
398 | ||
22aad001 | 399 | static int __devinit pm8607_regulator_probe(struct platform_device *pdev) |
be0e2d3e | 400 | { |
22aad001 HZ |
401 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); |
402 | struct pm8607_regulator_info *info = NULL; | |
586e1a17 HZ |
403 | struct regulator_init_data *pdata = pdev->dev.platform_data; |
404 | struct resource *res; | |
be0e2d3e HZ |
405 | int i; |
406 | ||
586e1a17 HZ |
407 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
408 | if (res == NULL) { | |
409 | dev_err(&pdev->dev, "No I/O resource!\n"); | |
22aad001 | 410 | return -EINVAL; |
586e1a17 | 411 | } |
be0e2d3e HZ |
412 | for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { |
413 | info = &pm8607_regulator_info[i]; | |
586e1a17 | 414 | if (info->desc.id == res->start) |
22aad001 | 415 | break; |
be0e2d3e | 416 | } |
99cd25ce | 417 | if (i == ARRAY_SIZE(pm8607_regulator_info)) { |
09969108 RD |
418 | dev_err(&pdev->dev, "Failed to find regulator %llu\n", |
419 | (unsigned long long)res->start); | |
be0e2d3e HZ |
420 | return -EINVAL; |
421 | } | |
53dbab7a | 422 | info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; |
be0e2d3e HZ |
423 | info->chip = chip; |
424 | ||
22aad001 | 425 | /* check DVC ramp slope double */ |
586e1a17 HZ |
426 | if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double) |
427 | info->slope_double = 1; | |
22aad001 | 428 | |
586e1a17 | 429 | /* replace driver_data with info */ |
be0e2d3e | 430 | info->regulator = regulator_register(&info->desc, &pdev->dev, |
2c043bcb | 431 | pdata, info, NULL); |
be0e2d3e HZ |
432 | if (IS_ERR(info->regulator)) { |
433 | dev_err(&pdev->dev, "failed to register regulator %s\n", | |
434 | info->desc.name); | |
435 | return PTR_ERR(info->regulator); | |
436 | } | |
437 | ||
be0e2d3e HZ |
438 | platform_set_drvdata(pdev, info); |
439 | return 0; | |
440 | } | |
441 | ||
442 | static int __devexit pm8607_regulator_remove(struct platform_device *pdev) | |
443 | { | |
444 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); | |
445 | ||
192bbb95 | 446 | platform_set_drvdata(pdev, NULL); |
be0e2d3e HZ |
447 | regulator_unregister(info->regulator); |
448 | return 0; | |
449 | } | |
450 | ||
192bbb95 HZ |
451 | static struct platform_driver pm8607_regulator_driver = { |
452 | .driver = { | |
453 | .name = "88pm860x-regulator", | |
454 | .owner = THIS_MODULE, | |
455 | }, | |
456 | .probe = pm8607_regulator_probe, | |
457 | .remove = __devexit_p(pm8607_regulator_remove), | |
be0e2d3e HZ |
458 | }; |
459 | ||
460 | static int __init pm8607_regulator_init(void) | |
461 | { | |
192bbb95 | 462 | return platform_driver_register(&pm8607_regulator_driver); |
be0e2d3e HZ |
463 | } |
464 | subsys_initcall(pm8607_regulator_init); | |
465 | ||
466 | static void __exit pm8607_regulator_exit(void) | |
467 | { | |
192bbb95 | 468 | platform_driver_unregister(&pm8607_regulator_driver); |
be0e2d3e HZ |
469 | } |
470 | module_exit(pm8607_regulator_exit); | |
471 | ||
472 | MODULE_LICENSE("GPL"); | |
473 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); | |
474 | MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM8607 PMIC"); | |
475 | MODULE_ALIAS("platform:88pm8607-regulator"); |