aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/lp3972.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2010-09-18 01:13:28 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-10-28 17:40:31 -0400
commit993af7c048f414121bc81e0d6e69456e3862a06b (patch)
tree26b8990dddfbd056d95b2ac0458af0103ed080c4 /drivers/regulator/lp3972.c
parent5976f0959d5251ae5b4db848eaa2f42a19e98652 (diff)
Regulator: lp3972 cleanup
This patch includes below fixes based on Mark's comment. - Return actual error if i2c_smbus_read_byte_data() fail - Add spaces around bitwise AND operator(&) to improve readability - Add comment to explain why we need to update voltage change control register for LDO1 and LDO5 - Logging the value for diagnostics if chip reported incorrect voltage value - Add __devinit annotation for setup_regulators() - Show system control register1 value if the value is mismatched - Logging the value for diagnostics if failed to detect device Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/lp3972.c')
-rw-r--r--drivers/regulator/lp3972.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 0d9b47569c1b..e07062fd0b42 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -192,7 +192,7 @@ static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count,
192 return -EIO; 192 return -EIO;
193 ret = i2c_smbus_read_byte_data(i2c, reg); 193 ret = i2c_smbus_read_byte_data(i2c, reg);
194 if (ret < 0) 194 if (ret < 0)
195 return -EIO; 195 return ret;
196 196
197 *dest = ret; 197 *dest = ret;
198 return 0; 198 return 0;
@@ -215,7 +215,7 @@ static u8 lp3972_reg_read(struct lp3972 *lp3972, u8 reg)
215 lp3972_i2c_read(lp3972->i2c, reg, 1, &val); 215 lp3972_i2c_read(lp3972->i2c, reg, 1, &val);
216 216
217 dev_dbg(lp3972->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg, 217 dev_dbg(lp3972->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg,
218 (unsigned)val&0xff); 218 (unsigned)val & 0xff);
219 219
220 mutex_unlock(&lp3972->io_lock); 220 mutex_unlock(&lp3972->io_lock);
221 221
@@ -234,7 +234,7 @@ static int lp3972_set_bits(struct lp3972 *lp3972, u8 reg, u16 mask, u16 val)
234 if (ret == 0) { 234 if (ret == 0) {
235 ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp); 235 ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp);
236 dev_dbg(lp3972->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg, 236 dev_dbg(lp3972->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg,
237 (unsigned)val&0xff); 237 (unsigned)val & 0xff);
238 } 238 }
239 mutex_unlock(&lp3972->io_lock); 239 mutex_unlock(&lp3972->io_lock);
240 240
@@ -320,6 +320,13 @@ static int lp3972_ldo_set_voltage(struct regulator_dev *dev,
320 if (ret) 320 if (ret)
321 return ret; 321 return ret;
322 322
323 /*
324 * LDO1 and LDO5 support voltage control by either target voltage1
325 * or target voltage2 register.
326 * We use target voltage1 register for LDO1 and LDO5 in this driver.
327 * We need to update voltage change control register(0x20) to enable
328 * LDO1 and LDO5 to change to their programmed target values.
329 */
323 switch (ldo) { 330 switch (ldo) {
324 case LP3972_LDO1: 331 case LP3972_LDO1:
325 case LP3972_LDO5: 332 case LP3972_LDO5:
@@ -401,7 +408,8 @@ static int lp3972_dcdc_get_voltage(struct regulator_dev *dev)
401 val = 1000 * buck_voltage_map[buck][reg]; 408 val = 1000 * buck_voltage_map[buck][reg];
402 else { 409 else {
403 val = 0; 410 val = 0;
404 dev_warn(&dev->dev, "chip reported incorrect voltage value.\n"); 411 dev_warn(&dev->dev, "chip reported incorrect voltage value."
412 " reg = %d\n", reg);
405 } 413 }
406 414
407 return val; 415 return val;
@@ -523,7 +531,7 @@ static struct regulator_desc regulators[] = {
523 }, 531 },
524}; 532};
525 533
526static int setup_regulators(struct lp3972 *lp3972, 534static int __devinit setup_regulators(struct lp3972 *lp3972,
527 struct lp3972_platform_data *pdata) 535 struct lp3972_platform_data *pdata)
528{ 536{
529 int i, err; 537 int i, err;
@@ -584,10 +592,13 @@ static int __devinit lp3972_i2c_probe(struct i2c_client *i2c,
584 592
585 /* Detect LP3972 */ 593 /* Detect LP3972 */
586 ret = lp3972_i2c_read(i2c, LP3972_SYS_CONTROL1_REG, 1, &val); 594 ret = lp3972_i2c_read(i2c, LP3972_SYS_CONTROL1_REG, 1, &val);
587 if (ret == 0 && (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL) 595 if (ret == 0 &&
596 (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL) {
588 ret = -ENODEV; 597 ret = -ENODEV;
598 dev_err(&i2c->dev, "chip reported: val = 0x%x\n", val);
599 }
589 if (ret < 0) { 600 if (ret < 0) {
590 dev_err(&i2c->dev, "failed to detect device\n"); 601 dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret);
591 goto err_detect; 602 goto err_detect;
592 } 603 }
593 604