aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorPuthikorn Voravootivat <puthik@chromium.org>2014-09-30 14:18:56 -0400
committerSebastian Reichel <sre@kernel.org>2014-09-30 22:10:50 -0400
commita3c0c3e79066c78b890c078998c8c6bd577f1d21 (patch)
tree85ae7a455ff35c62df0ac44eaade8572705f7a65 /drivers/power
parent18a702e0de9879d5c0225a09f494443f0b91a0cc (diff)
bq27x00_battery: Fix flag reading for bq27742
This patch fix the following issues. - Flag for bq27742 is 2 bytes contracy to 1 byte for older hardware - Don't read FLAG_CI as bq27742 does not have it - Use Battery full capacity register as last measure discharge Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq27x00_battery.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 5b9f0eacb20a..e3bacfe3bcd0 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -254,9 +254,11 @@ static inline int bq27x00_battery_read_nac(struct bq27x00_device_info *di)
254{ 254{
255 int flags; 255 int flags;
256 bool is_bq27500 = di->chip == BQ27500; 256 bool is_bq27500 = di->chip == BQ27500;
257 bool is_bq27742 = di->chip == BQ27742;
257 bool is_higher = bq27xxx_is_chip_version_higher(di); 258 bool is_higher = bq27xxx_is_chip_version_higher(di);
259 bool flags_1b = !(is_bq27500 || is_bq27742);
258 260
259 flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500); 261 flags = bq27x00_read(di, BQ27x00_REG_FLAGS, flags_1b);
260 if (flags >= 0 && !is_higher && (flags & BQ27000_FLAG_CI)) 262 if (flags >= 0 && !is_higher && (flags & BQ27000_FLAG_CI))
261 return -ENODATA; 263 return -ENODATA;
262 264
@@ -436,13 +438,14 @@ static void bq27x00_update(struct bq27x00_device_info *di)
436 bool is_bq27500 = di->chip == BQ27500; 438 bool is_bq27500 = di->chip == BQ27500;
437 bool is_bq27425 = di->chip == BQ27425; 439 bool is_bq27425 = di->chip == BQ27425;
438 bool is_bq27742 = di->chip == BQ27742; 440 bool is_bq27742 = di->chip == BQ27742;
441 bool flags_1b = !(is_bq27500 || is_bq27742);
439 442
440 cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, !is_bq27500); 443 cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, flags_1b);
441 if ((cache.flags & 0xff) == 0xff) 444 if ((cache.flags & 0xff) == 0xff)
442 /* read error */ 445 /* read error */
443 cache.flags = -1; 446 cache.flags = -1;
444 if (cache.flags >= 0) { 447 if (cache.flags >= 0) {
445 if (!is_bq27500 && !is_bq27425 448 if (!is_bq27500 && !is_bq27425 && !is_bq27742
446 && (cache.flags & BQ27000_FLAG_CI)) { 449 && (cache.flags & BQ27000_FLAG_CI)) {
447 dev_info(di->dev, "battery is not calibrated! ignoring capacity values\n"); 450 dev_info(di->dev, "battery is not calibrated! ignoring capacity values\n");
448 cache.capacity = -ENODATA; 451 cache.capacity = -ENODATA;
@@ -470,9 +473,7 @@ static void bq27x00_update(struct bq27x00_device_info *di)
470 bq27x00_battery_read_time(di, 473 bq27x00_battery_read_time(di,
471 BQ27x00_REG_TTF); 474 BQ27x00_REG_TTF);
472 } 475 }
473 if (!is_bq27742) 476 cache.charge_full = bq27x00_battery_read_lmd(di);
474 cache.charge_full =
475 bq27x00_battery_read_lmd(di);
476 cache.health = bq27x00_battery_read_health(di); 477 cache.health = bq27x00_battery_read_health(di);
477 } 478 }
478 cache.temperature = bq27x00_battery_read_temperature(di); 479 cache.temperature = bq27x00_battery_read_temperature(di);