Skip to content

Commit

Permalink
bq2415x_charger: Fix max battery regulation voltage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexandre Belloni authored and Anton Vorontsov committed Oct 25, 2013
1 parent e47bcba commit 3ed5cd7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/power/bq2415x_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,13 @@ static int bq2415x_set_battery_regulation_voltage(struct bq2415x_device *bq,
{
int val = (mV/10 - 350) / 2;

/*
* According to datasheet, maximum battery regulation voltage is
* 4440mV which is b101111 = 47.
*/
if (val < 0)
val = 0;
else if (val > 94) /* FIXME: Max is 94 or 122 ? Set max value ? */
else if (val > 47)
return -EINVAL;

return bq2415x_i2c_write_mask(bq, BQ2415X_REG_VOLTAGE, val,
Expand Down

0 comments on commit 3ed5cd7

Please sign in to comment.