aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/pfuze100-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-07-29 22:46:28 -0400
committerMark Brown <broonie@linaro.org>2013-07-30 06:20:00 -0400
commitd9493234e20e8153495fa118b60bdff22fdfc6c8 (patch)
treec4e93d3ee4d3eb110b7ef0b81046cf2026acc301 /drivers/regulator/pfuze100-regulator.c
parent2e04cc41a6d7a561568f3802b61d0987f1ec7e9a (diff)
regulator: pfuze100: Fix n_voltages setting for SW2~SW4 with high bit set
Current code adjust min_uV and uV_step but missed adjusting the n_voltages setting. When BIT6 is clear: n_voltages = (1975000 - 400000) / 25000 + 1 = 64 When BIT6 is set: n_voltages = (3300000 - 800000) / 50000 + 1 = 51 The n_voltages needs update because when BIT6 is set 0x73 ~ 0x7f are reserved. When using regulator_list_voltage_linear, the n_voltages does matter here because wrong n_voltages setting make the equation return wrong result. e.g. if selector is 63, regulator_list_voltage_linear returns 800000 + (50000 * 63) = 4000000 It should return -EINVAL if the selector is in the range of 51 ~ 63. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/pfuze100-regulator.c')
-rw-r--r--drivers/regulator/pfuze100-regulator.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index 7b24acb66a18..e02d9b921ed3 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -388,8 +388,11 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
388 388
389 for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) { 389 for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) {
390 struct regulator_init_data *init_data; 390 struct regulator_init_data *init_data;
391 struct regulator_desc *desc;
391 int val; 392 int val;
392 393
394 desc = &pfuze_chip->regulator_descs[i].desc;
395
393 if (pdata) 396 if (pdata)
394 init_data = pdata->init_data[i]; 397 init_data = pdata->init_data[i];
395 else 398 else
@@ -397,13 +400,11 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
397 400
398 /* SW2~SW4 high bit check and modify the voltage value table */ 401 /* SW2~SW4 high bit check and modify the voltage value table */
399 if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) { 402 if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) {
400 regmap_read(pfuze_chip->regmap, PFUZE100_SW2VOL + 403 regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val);
401 (i - PFUZE100_SW2) * 7, &val);
402 if (val & 0x40) { 404 if (val & 0x40) {
403 pfuze_chip->regulator_descs[i].desc.min_uV 405 desc->min_uV = 800000;
404 = 800000; 406 desc->uV_step = 50000;
405 pfuze_chip->regulator_descs[i].desc.uV_step 407 desc->n_voltages = 51;
406 = 50000;
407 } 408 }
408 } 409 }
409 410
@@ -412,8 +413,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
412 config.driver_data = pfuze_chip; 413 config.driver_data = pfuze_chip;
413 config.of_node = match_of_node(i); 414 config.of_node = match_of_node(i);
414 415
415 pfuze_chip->regulators[i] = regulator_register(&pfuze_chip 416 pfuze_chip->regulators[i] = regulator_register(desc, &config);
416 ->regulator_descs[i].desc, &config);
417 if (IS_ERR(pfuze_chip->regulators[i])) { 417 if (IS_ERR(pfuze_chip->regulators[i])) {
418 dev_err(&client->dev, "register regulator%s failed\n", 418 dev_err(&client->dev, "register regulator%s failed\n",
419 pfuze100_regulators[i].desc.name); 419 pfuze100_regulators[i].desc.name);