From 2bfda581d537ef9a5065e08b672357e280f927db Mon Sep 17 00:00:00 2001 From: Robert Zieba Date: Thu, 30 Mar 2023 02:40:43 +0000 Subject: common/battery: Add workaround for erroneous battery temperatures Certain batteries appear to transiently return temperatures of 591.1K and 2151K. These values are clearly incorrect. Add a temporary workaround while the root cause is investigated. BRANCH=skyrim BUG=b:274812415 TEST=Ran suspend_stress_test with no battery temperature wakeups. Change-Id: I0c774a58770fa25907caf50aaf8d672a787addd3 Signed-off-by: Robert Zieba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4382556 Tested-by: Isaac Lee Reviewed-by: Diana Z Reviewed-by: Elthan Huang Tested-by: Elthan Huang Commit-Queue: Isaac Lee --- common/battery.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/battery.c b/common/battery.c index 9e46cd8bbf..4a47991738 100644 --- a/common/battery.c +++ b/common/battery.c @@ -695,8 +695,12 @@ void battery_validate_params(struct batt_params *batt) * anything above the boiling point of tungsten until this bug * is fixed. If the battery is really that warm, we probably * have more urgent problems. + * TODO(b/276000336). Some batteries occasionally give obviously + * incorrect results of 591.1K and 2151K, which are 318C and 1878C. + * Ignore these for now. */ - if (batt->temperature > CELSIUS_TO_DECI_KELVIN(5660)) { + if (batt->temperature > CELSIUS_TO_DECI_KELVIN(5660) || + batt->temperature == 5911 || batt->temperature == 21510) { CPRINTS("ignoring ridiculous batt.temp of %dC", DECI_KELVIN_TO_CELSIUS(batt->temperature)); batt->flags |= BATT_FLAG_BAD_TEMPERATURE; -- cgit v1.2.1