summaryrefslogtreecommitdiff
path: root/driver/battery/max17055.c
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2017-11-01 03:14:04 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-11-03 01:53:39 -0700
commit10dc1b8aad55939f14277b16d0d3cc7199615a36 (patch)
treec5246853455387326970dcf0891cc5d598672af2 /driver/battery/max17055.c
parent7d76175df7e00f9fa0a20fcea4c12b9033573042 (diff)
downloadchrome-ec-10dc1b8aad55939f14277b16d0d3cc7199615a36.tar.gz
battery/max17055: Allow charging
We didn't set BATT_FLAG_WANT_CHARGE in battery_get_params(), so battery command always shows 'charging not allowed'. Let's set the flag in the same condition as it is set in battery/smart.c. BUG=b:68027469 BRANCH=none TEST='battery' on EC console shows 'Charging: Allowed' Change-Id: Ifbdb6aee2572c8fc5f67103ca940738fb221ce5d Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/749025 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/battery/max17055.c')
-rw-r--r--driver/battery/max17055.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/driver/battery/max17055.c b/driver/battery/max17055.c
index 405ebdf975..516cd1f429 100644
--- a/driver/battery/max17055.c
+++ b/driver/battery/max17055.c
@@ -294,6 +294,16 @@ void battery_get_params(struct batt_params *batt)
batt->is_present = BP_YES;
} else
batt->is_present = BP_NOT_SURE;
+
+ /*
+ * Charging allowed if both desired voltage and current are nonzero
+ * and battery isn't full (and we read them all correctly).
+ */
+ if (!(batt->flags & BATT_FLAG_BAD_STATE_OF_CHARGE) &&
+ batt->desired_voltage &&
+ batt->desired_current &&
+ batt->state_of_charge < BATTERY_LEVEL_FULL)
+ batt->flags |= BATT_FLAG_WANT_CHARGE;
}
/* Wait until battery is totally stable. */