bq27541: report battery present state

The battery driver is not reporting battery present state, and as a
result, is_present flag always remain NOT_SURE. Fix it.

BRANCH=Ryu
BUG=None
TEST=On Ryu, 'chgstate' and see 'is_present = YES'.

Change-Id: I84bedc390158797bf1e67e612d0bb3f526292dfa
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/242970
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
This commit is contained in:
Vic Yang
2015-01-23 13:52:58 -08:00
committed by ChromeOS Commit Bot
parent 6f4af26809
commit 48eed0bebc

View File

@@ -219,14 +219,16 @@ enum battery_present battery_is_present(void)
void battery_get_params(struct batt_params *batt)
{
int v;
const uint32_t flags_to_check = BATT_FLAG_BAD_TEMPERATURE |
BATT_FLAG_BAD_STATE_OF_CHARGE |
BATT_FLAG_BAD_VOLTAGE |
BATT_FLAG_BAD_CURRENT;
/* Reset flags */
batt->flags = 0;
if (bq27541_read(REG_TEMPERATURE, &batt->temperature))
batt->flags |= BATT_FLAG_BAD_TEMPERATURE;
else
batt->flags |= BATT_FLAG_RESPONSIVE; /* Battery is responding */
if (bq27541_read8(REG_STATE_OF_CHARGE, &batt->state_of_charge))
batt->flags |= BATT_FLAG_BAD_STATE_OF_CHARGE;
@@ -242,6 +244,14 @@ void battery_get_params(struct batt_params *batt)
/* Default to not desiring voltage and current */
batt->desired_voltage = batt->desired_current = 0;
/* If any of those reads worked, the battery is responsive */
if ((batt->flags & flags_to_check) != flags_to_check) {
batt->flags |= BATT_FLAG_RESPONSIVE;
batt->is_present = BP_YES;
} else {
batt->is_present = BP_NOT_SURE;
}
v = 0;
if (battery_charging_allowed(&v)) {
batt->flags |= BATT_FLAG_BAD_ANY;