diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/bq27x00_battery.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index a5311225b964..6c8dfdb169a1 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #define BQ27000_REG_ILMD 0x76 /* Initial last measured discharge */ | 56 | #define BQ27000_REG_ILMD 0x76 /* Initial last measured discharge */ |
57 | #define BQ27000_FLAG_EDVF BIT(0) /* Final End-of-Discharge-Voltage flag */ | 57 | #define BQ27000_FLAG_EDVF BIT(0) /* Final End-of-Discharge-Voltage flag */ |
58 | #define BQ27000_FLAG_EDV1 BIT(1) /* First End-of-Discharge-Voltage flag */ | 58 | #define BQ27000_FLAG_EDV1 BIT(1) /* First End-of-Discharge-Voltage flag */ |
59 | #define BQ27000_FLAG_CI BIT(4) /* Capacity Inaccurate flag */ | ||
59 | #define BQ27000_FLAG_FC BIT(5) | 60 | #define BQ27000_FLAG_FC BIT(5) |
60 | #define BQ27000_FLAG_CHGS BIT(7) /* Charge state flag */ | 61 | #define BQ27000_FLAG_CHGS BIT(7) /* Charge state flag */ |
61 | 62 | ||
@@ -265,12 +266,20 @@ static void bq27x00_update(struct bq27x00_device_info *di) | |||
265 | 266 | ||
266 | cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500); | 267 | cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500); |
267 | if (cache.flags >= 0) { | 268 | if (cache.flags >= 0) { |
268 | cache.capacity = bq27x00_battery_read_rsoc(di); | 269 | if (!is_bq27500 && (cache.flags & BQ27000_FLAG_CI)) { |
270 | cache.capacity = -ENODATA; | ||
271 | cache.time_to_empty = -ENODATA; | ||
272 | cache.time_to_empty_avg = -ENODATA; | ||
273 | cache.time_to_full = -ENODATA; | ||
274 | cache.charge_full = -ENODATA; | ||
275 | } else { | ||
276 | cache.capacity = bq27x00_battery_read_rsoc(di); | ||
277 | cache.time_to_empty = bq27x00_battery_read_time(di, BQ27x00_REG_TTE); | ||
278 | cache.time_to_empty_avg = bq27x00_battery_read_time(di, BQ27x00_REG_TTECP); | ||
279 | cache.time_to_full = bq27x00_battery_read_time(di, BQ27x00_REG_TTF); | ||
280 | cache.charge_full = bq27x00_battery_read_lmd(di); | ||
281 | } | ||
269 | cache.temperature = bq27x00_read(di, BQ27x00_REG_TEMP, false); | 282 | cache.temperature = bq27x00_read(di, BQ27x00_REG_TEMP, false); |
270 | cache.time_to_empty = bq27x00_battery_read_time(di, BQ27x00_REG_TTE); | ||
271 | cache.time_to_empty_avg = bq27x00_battery_read_time(di, BQ27x00_REG_TTECP); | ||
272 | cache.time_to_full = bq27x00_battery_read_time(di, BQ27x00_REG_TTF); | ||
273 | cache.charge_full = bq27x00_battery_read_lmd(di); | ||
274 | cache.cycle_count = bq27x00_battery_read_cyct(di); | 283 | cache.cycle_count = bq27x00_battery_read_cyct(di); |
275 | 284 | ||
276 | /* We only have to read charge design full once */ | 285 | /* We only have to read charge design full once */ |