aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2013-10-16 10:08:31 -0400
committerAnton Vorontsov <anton@enomsg.org>2013-10-25 19:24:22 -0400
commit3ed5cd79b82e9a055e0df3275eeb471ea0f1e2d7 (patch)
tree6cb58a324dc8c0123171da4d1647a8e5422b360d /drivers/power
parente47bcba4a189ab1ba23072ee2f457b1d72cd22fe (diff)
bq2415x_charger: Fix max battery regulation voltage
As per the datasheets, maximum battery regulation voltage is 4440mV. The formula is (voltage - offset) / step, so the maximum value is: (4440 - 3500) / 20 = 47 Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Thanks-to: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq2415x_charger.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index 0727f9256138..df893dd1447d 100644
--- a/drivers/power/bq2415x_charger.c
+++ b/drivers/power/bq2415x_charger.c
@@ -605,9 +605,13 @@ static int bq2415x_set_battery_regulation_voltage(struct bq2415x_device *bq,
605{ 605{
606 int val = (mV/10 - 350) / 2; 606 int val = (mV/10 - 350) / 2;
607 607
608 /*
609 * According to datasheet, maximum battery regulation voltage is
610 * 4440mV which is b101111 = 47.
611 */
608 if (val < 0) 612 if (val < 0)
609 val = 0; 613 val = 0;
610 else if (val > 94) /* FIXME: Max is 94 or 122 ? Set max value ? */ 614 else if (val > 47)
611 return -EINVAL; 615 return -EINVAL;
612 616
613 return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE, val, 617 return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE, val,