summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-03-27 11:10:46 -0700
committerBill Richardson <wfrichar@chromium.org>2014-03-28 15:23:01 +0000
commit91a5fa01940764832c1b974d2022bee4e744f09c (patch)
tree3a772b75245da7c02cc4ddfa01752168577eee82 /common
parentb2d87dc18ad0c6049a48959f4c2d7dfddaf301f1 (diff)
downloadchrome-ec-91a5fa01940764832c1b974d2022bee4e744f09c.tar.gz
Add more fields and error flags to struct batt_params
This adds two battery parameters that need to be monitored constantly: remaining_capacity and full_capacity (that one only changes occasionally, but we have to notify the AP when it does). It also adds the is_present field to indicate whether the battery is physically present or not (when we can tell), so we know whether to try to wake up a deep-discharged battery. Along with that, we clean up the error flags to provide indication of which fields were unable to be read, and replace the manual logical-or of all errors as they were set with a bitmask (BATT_FLAG_BAD_ANY). No functionality is changed, only new & better information is provided for use in the upcoming cleanup of the charge state machine. BUG=chrome-os-partner:20881 BRANCH=ToT TEST=make buildall -j All targets build; all tests pass. Change-Id: I4312c2fdd3cf2dd9570718e90571eff796b269db Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191917 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/charge_state_v1.c2
-rw-r--r--common/pmu_tps65090_charger.c6
2 files changed, 4 insertions, 4 deletions
diff --git a/common/charge_state_v1.c b/common/charge_state_v1.c
index 9f1040654f..bb2c681ef9 100644
--- a/common/charge_state_v1.c
+++ b/common/charge_state_v1.c
@@ -294,7 +294,7 @@ static int state_common(struct charge_state_context *ctx)
curr->error |= F_BATTERY_GET_PARAMS;
if (batt->flags & BATT_FLAG_BAD_VOLTAGE)
curr->error |= F_BATTERY_VOLTAGE;
- if (batt->flags & BATT_FLAG_BAD_CHARGE_PERCENT)
+ if (batt->flags & BATT_FLAG_BAD_STATE_OF_CHARGE)
curr->error |= F_BATTERY_STATE_OF_CHARGE;
*ctx->memmap_batt_volt = batt->voltage;
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index 8a07653a80..ff66a9c4d8 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -218,7 +218,7 @@ static int calc_next_state(int state)
return ST_IDLE;
/* Start charging only when battery charge lower than 100% */
- if (!(batt.flags & BATT_FLAG_BAD_CHARGE_PERCENT)) {
+ if (!(batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE)) {
if (batt.state_of_charge < 100)
return ST_CHARGING;
}
@@ -236,7 +236,7 @@ static int calc_next_state(int state)
if (batt.flags & BATT_FLAG_RESPONSIVE) {
if (!battery_start_charging_range(batt.temperature))
return ST_IDLE0;
- if (!(batt.flags & BATT_FLAG_BAD_CHARGE_PERCENT)) {
+ if (!(batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE)) {
if (batt.state_of_charge >= 100)
return ST_IDLE0;
}
@@ -355,7 +355,7 @@ static int calc_next_state(int state)
return system_off();
}
/* Check remaining charge % */
- if (!(batt.flags & BATT_FLAG_BAD_CHARGE_PERCENT)) {
+ if (!(batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE)) {
/*
* Shutdown AP when state of charge < 1.5%.
* Moving average is rounded to integer.