aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/88pm8607.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-28 02:59:23 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-01 06:59:39 -0400
commit53b6949ef3291778aa9f921985206fbfd95449d7 (patch)
treea5e315b0092c8e9bef49acb3a44736aa8a792962 /drivers/regulator/88pm8607.c
parentd3d7bccc07a06a33fb9ba97ab764df8d46fb87d0 (diff)
regulator: Add missing n_voltages setting for 88pm8607
Then we can remove the vol_nbits field from struct pm8607_regulator_info. Signed-off-by: Axel Lin <axel.lin@gmail.com> Tested-by: Jett Zhou <jtzhou@marvell.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/88pm8607.c')
-rw-r--r--drivers/regulator/88pm8607.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 981b47ae7d3c..81b665909171 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -29,7 +29,6 @@ struct pm8607_regulator_info {
29 29
30 int vol_reg; 30 int vol_reg;
31 int vol_shift; 31 int vol_shift;
32 int vol_nbits;
33 int update_reg; 32 int update_reg;
34 int update_bit; 33 int update_bit;
35 int enable_reg; 34 int enable_reg;
@@ -216,7 +215,7 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
216 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); 215 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
217 int ret = -EINVAL; 216 int ret = -EINVAL;
218 217
219 if (info->vol_table && (index < (1 << info->vol_nbits))) { 218 if (info->vol_table && (index < rdev->desc->n_voltages)) {
220 ret = info->vol_table[index]; 219 ret = info->vol_table[index];
221 if (info->slope_double) 220 if (info->slope_double)
222 ret <<= 1; 221 ret <<= 1;
@@ -234,7 +233,7 @@ static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
234 max_uV = max_uV >> 1; 233 max_uV = max_uV >> 1;
235 } 234 }
236 if (info->vol_table) { 235 if (info->vol_table) {
237 for (i = 0; i < (1 << info->vol_nbits); i++) { 236 for (i = 0; i < rdev->desc->n_voltages; i++) {
238 if (!info->vol_table[i]) 237 if (!info->vol_table[i])
239 break; 238 break;
240 if ((min_uV <= info->vol_table[i]) 239 if ((min_uV <= info->vol_table[i])
@@ -266,7 +265,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
266 return -EINVAL; 265 return -EINVAL;
267 *selector = ret; 266 *selector = ret;
268 val = (uint8_t)(ret << info->vol_shift); 267 val = (uint8_t)(ret << info->vol_shift);
269 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; 268 mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
270 269
271 ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val); 270 ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
272 if (ret) 271 if (ret)
@@ -292,7 +291,7 @@ static int pm8607_get_voltage(struct regulator_dev *rdev)
292 if (ret < 0) 291 if (ret < 0)
293 return ret; 292 return ret;
294 293
295 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; 294 mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
296 val = ((unsigned char)ret & mask) >> info->vol_shift; 295 val = ((unsigned char)ret & mask) >> info->vol_shift;
297 296
298 return pm8607_list_voltage(rdev, val); 297 return pm8607_list_voltage(rdev, val);
@@ -336,7 +335,7 @@ static struct regulator_ops pm8607_regulator_ops = {
336 .is_enabled = pm8607_is_enabled, 335 .is_enabled = pm8607_is_enabled,
337}; 336};
338 337
339#define PM8607_DVC(vreg, nbits, ureg, ubit, ereg, ebit) \ 338#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
340{ \ 339{ \
341 .desc = { \ 340 .desc = { \
342 .name = #vreg, \ 341 .name = #vreg, \
@@ -344,10 +343,10 @@ static struct regulator_ops pm8607_regulator_ops = {
344 .type = REGULATOR_VOLTAGE, \ 343 .type = REGULATOR_VOLTAGE, \
345 .id = PM8607_ID_##vreg, \ 344 .id = PM8607_ID_##vreg, \
346 .owner = THIS_MODULE, \ 345 .owner = THIS_MODULE, \
346 .n_voltages = ARRAY_SIZE(vreg##_table), \
347 }, \ 347 }, \
348 .vol_reg = PM8607_##vreg, \ 348 .vol_reg = PM8607_##vreg, \
349 .vol_shift = (0), \ 349 .vol_shift = (0), \
350 .vol_nbits = (nbits), \
351 .update_reg = PM8607_##ureg, \ 350 .update_reg = PM8607_##ureg, \
352 .update_bit = (ubit), \ 351 .update_bit = (ubit), \
353 .enable_reg = PM8607_##ereg, \ 352 .enable_reg = PM8607_##ereg, \
@@ -357,7 +356,7 @@ static struct regulator_ops pm8607_regulator_ops = {
357 .vol_suspend = (unsigned int *)&vreg##_suspend_table, \ 356 .vol_suspend = (unsigned int *)&vreg##_suspend_table, \
358} 357}
359 358
360#define PM8607_LDO(_id, vreg, shift, nbits, ereg, ebit) \ 359#define PM8607_LDO(_id, vreg, shift, ereg, ebit) \
361{ \ 360{ \
362 .desc = { \ 361 .desc = { \
363 .name = "LDO" #_id, \ 362 .name = "LDO" #_id, \
@@ -365,10 +364,10 @@ static struct regulator_ops pm8607_regulator_ops = {
365 .type = REGULATOR_VOLTAGE, \ 364 .type = REGULATOR_VOLTAGE, \
366 .id = PM8607_ID_LDO##_id, \ 365 .id = PM8607_ID_LDO##_id, \
367 .owner = THIS_MODULE, \ 366 .owner = THIS_MODULE, \
367 .n_voltages = ARRAY_SIZE(LDO##_id##_table), \
368 }, \ 368 }, \
369 .vol_reg = PM8607_##vreg, \ 369 .vol_reg = PM8607_##vreg, \
370 .vol_shift = (shift), \ 370 .vol_shift = (shift), \
371 .vol_nbits = (nbits), \
372 .enable_reg = PM8607_##ereg, \ 371 .enable_reg = PM8607_##ereg, \
373 .enable_bit = (ebit), \ 372 .enable_bit = (ebit), \
374 .slope_double = (0), \ 373 .slope_double = (0), \
@@ -377,23 +376,23 @@ static struct regulator_ops pm8607_regulator_ops = {
377} 376}
378 377
379static struct pm8607_regulator_info pm8607_regulator_info[] = { 378static struct pm8607_regulator_info pm8607_regulator_info[] = {
380 PM8607_DVC(BUCK1, 6, GO, 0, SUPPLIES_EN11, 0), 379 PM8607_DVC(BUCK1, GO, 0, SUPPLIES_EN11, 0),
381 PM8607_DVC(BUCK2, 6, GO, 1, SUPPLIES_EN11, 1), 380 PM8607_DVC(BUCK2, GO, 1, SUPPLIES_EN11, 1),
382 PM8607_DVC(BUCK3, 6, GO, 2, SUPPLIES_EN11, 2), 381 PM8607_DVC(BUCK3, GO, 2, SUPPLIES_EN11, 2),
383 382
384 PM8607_LDO( 1, LDO1, 0, 2, SUPPLIES_EN11, 3), 383 PM8607_LDO(1, LDO1, 0, SUPPLIES_EN11, 3),
385 PM8607_LDO( 2, LDO2, 0, 3, SUPPLIES_EN11, 4), 384 PM8607_LDO(2, LDO2, 0, SUPPLIES_EN11, 4),
386 PM8607_LDO( 3, LDO3, 0, 3, SUPPLIES_EN11, 5), 385 PM8607_LDO(3, LDO3, 0, SUPPLIES_EN11, 5),
387 PM8607_LDO( 4, LDO4, 0, 3, SUPPLIES_EN11, 6), 386 PM8607_LDO(4, LDO4, 0, SUPPLIES_EN11, 6),
388 PM8607_LDO( 5, LDO5, 0, 2, SUPPLIES_EN11, 7), 387 PM8607_LDO(5, LDO5, 0, SUPPLIES_EN11, 7),
389 PM8607_LDO( 6, LDO6, 0, 3, SUPPLIES_EN12, 0), 388 PM8607_LDO(6, LDO6, 0, SUPPLIES_EN12, 0),
390 PM8607_LDO( 7, LDO7, 0, 3, SUPPLIES_EN12, 1), 389 PM8607_LDO(7, LDO7, 0, SUPPLIES_EN12, 1),
391 PM8607_LDO( 8, LDO8, 0, 3, SUPPLIES_EN12, 2), 390 PM8607_LDO(8, LDO8, 0, SUPPLIES_EN12, 2),
392 PM8607_LDO( 9, LDO9, 0, 3, SUPPLIES_EN12, 3), 391 PM8607_LDO(9, LDO9, 0, SUPPLIES_EN12, 3),
393 PM8607_LDO(10, LDO10, 0, 4, SUPPLIES_EN12, 4), 392 PM8607_LDO(10, LDO10, 0, SUPPLIES_EN12, 4),
394 PM8607_LDO(12, LDO12, 0, 4, SUPPLIES_EN12, 5), 393 PM8607_LDO(12, LDO12, 0, SUPPLIES_EN12, 5),
395 PM8607_LDO(13, VIBRATOR_SET, 1, 3, VIBRATOR_SET, 0), 394 PM8607_LDO(13, VIBRATOR_SET, 1, VIBRATOR_SET, 0),
396 PM8607_LDO(14, LDO14, 0, 3, SUPPLIES_EN12, 6), 395 PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
397}; 396};
398 397
399static int __devinit pm8607_regulator_probe(struct platform_device *pdev) 398static int __devinit pm8607_regulator_probe(struct platform_device *pdev)