linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bq2415x_charger: fix max battery regulation voltage
@ 2013-10-02 10:24 Alexandre Belloni
  2013-10-15 13:56 ` Pali Rohár
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2013-10-02 10:24 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: linux-kernel, Pali Rohár, David Woodhouse, Alexandre Belloni

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>
---
 drivers/power/bq2415x_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index 0727f92..0aa643e 100644
--- a/drivers/power/bq2415x_charger.c
+++ b/drivers/power/bq2415x_charger.c
@@ -607,7 +607,7 @@ static int bq2415x_set_battery_regulation_voltage(struct bq2415x_device *bq,
 
 	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,
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] bq2415x_charger: fix max battery regulation voltage
@ 2013-10-16 14:08 Alexandre Belloni
  2013-10-16 14:09 ` Alexandre Belloni
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2013-10-16 14:08 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: linux-kernel, Pali Rohár, David Woodhouse, Alexandre Belloni

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>
---
 drivers/power/bq2415x_charger.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index 0727f92..df893dd 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,
 {
 	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,
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-25 23:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-02 10:24 [PATCH] bq2415x_charger: fix max battery regulation voltage Alexandre Belloni
2013-10-15 13:56 ` Pali Rohár
2013-10-15 14:54   ` Alexandre Belloni
  -- strict thread matches above, loose matches on Subject: below --
2013-10-16 14:08 Alexandre Belloni
2013-10-16 14:09 ` Alexandre Belloni
2013-10-25 23:25   ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).