mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 01:50:53 +00:00
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:
committed by
ChromeOS Commit Bot
parent
6f4af26809
commit
48eed0bebc
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user