diff options
author | Diana Z <dzigterman@chromium.org> | 2019-12-09 14:58:34 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-11 21:30:33 +0000 |
commit | 92e1c8698ab44582e329ccdea0e50dd9012116fa (patch) | |
tree | e8f84cd3ebc5922b352504bea3c030cc23100cef /common | |
parent | 536eb90d4e354e2efb4c21ca8502eda12ddaa389 (diff) | |
download | chrome-ec-92e1c8698ab44582e329ccdea0e50dd9012116fa.tar.gz |
Charge state v2: Only shutdown on cold discharge
Currently, the discharge minimum temperature is always checked when
determining if the system should shut down, even if the system is not
discharging. This change allows the system to run below the discharging
minimum temperature as long as AC is present.
BRANCH=octopus
BUG=b:145494158
TEST=loaded onto octopus unit, faked low battery temperature and
verified the system did shut down when discharging and did not with AC
Change-Id: I4f6549b04dc1e7b55e410d3ae4f67dc6126f9c7c
Signed-off-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1958853
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/charge_state_v2.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 170680487d..cb225c7a3b 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1295,12 +1295,16 @@ static int set_chg_ctrl_mode(enum ec_charge_control_mode mode) return EC_SUCCESS; } -/* True if we know the battery temp is too high or too low */ static inline int battery_too_hot(int batt_temp_c) { return (!(curr.batt.flags & BATT_FLAG_BAD_TEMPERATURE) && - (batt_temp_c > batt_info->discharging_max_c || - batt_temp_c < batt_info->discharging_min_c)); + (batt_temp_c > batt_info->discharging_max_c)); +} + +static inline int battery_too_cold_for_discharge(int batt_temp_c) +{ + return (!(curr.batt.flags & BATT_FLAG_BAD_TEMPERATURE) && + (batt_temp_c < batt_info->discharging_min_c)); } __attribute__((weak)) uint8_t board_set_battery_level_shutdown(void) @@ -1339,7 +1343,13 @@ static int is_battery_critical(void) * temp, so it can turn fans on. */ if (battery_too_hot(batt_temp_c)) { - CPRINTS("Batt temp out of range: %dC", batt_temp_c); + CPRINTS("Batt too hot: %dC", batt_temp_c); + return 1; + } + + /* Note: the battery may run on AC without discharging when too cold */ + if (!curr.ac && battery_too_cold_for_discharge(batt_temp_c)) { + CPRINTS("Batt too cold: %dC", batt_temp_c); return 1; } |