summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-04-02 20:51:52 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-05 01:42:05 +0000
commit3e1db94ea03e43c37a165a5dd2f1693a54dbfefd (patch)
tree39a4abb67d8bf566adc4e924ab5c1cf128af0856
parentfe84900c6faa281067212ba6c2c4f564f5d0fe34 (diff)
downloadchrome-ec-3e1db94ea03e43c37a165a5dd2f1693a54dbfefd.tar.gz
Samus: Workaround for flaky battery temp reading
Sometimes the battery happily reports that it's current temperature is 6280C, which is just a little bit high. This just treats unreasonably high temperatures as an error. BUG=chrome-os-partner:27527 BRANCH=ToT TEST=manual Make the change, watch the EC console while the AP is running and the battery charges and discharges. The problem is intermittent, but when it occurs it shuts the AP down immediately. With this change, it just prints a warning instead. I've also added a check for this to test/sbs_charging_v2.c Change-Id: Ibfa53cf0244499ec52d4887bcd06fb9126c07a6c Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193277 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/charge_state_v2.c13
-rw-r--r--test/sbs_charging_v2.c12
2 files changed, 25 insertions, 0 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 4a8d13f4c0..f357187de8 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -442,6 +442,19 @@ void charger_task(void)
battery_get_params(&curr.batt);
/*
+ * TODO(crosbug.com/p/27527). Sometimes the battery thinks its
+ * temperature is 6280C, which seems a bit high. Let's ignore
+ * 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.
+ */
+ if (curr.batt.temperature > CELSIUS_TO_DECI_KELVIN(5660)) {
+ ccprintf("[%T ignoring ridiculous batt.temp of %dC]\n",
+ DECI_KELVIN_TO_CELSIUS(curr.batt.temperature));
+ curr.batt.flags |= BATT_FLAG_BAD_TEMPERATURE;
+ }
+
+ /*
* Now decide what we want to do about it. We'll normally just
* pass along whatever the battery wants to the charger. Note
* that if battery_get_params() can't get valid values from the
diff --git a/test/sbs_charging_v2.c b/test/sbs_charging_v2.c
index feedcb117b..69777042a3 100644
--- a/test/sbs_charging_v2.c
+++ b/test/sbs_charging_v2.c
@@ -116,6 +116,18 @@ static int test_charge_state(void)
state = wait_charging_state();
TEST_ASSERT(state == PWR_STATE_DISCHARGE);
+ /* Discharging waaaay overtemp is ignored */
+ ccprintf("[CHARGING TEST] AC off, batt temp = 0xffff\n");
+ gpio_set_level(GPIO_AC_PRESENT, 0);
+ sb_write(SB_CURRENT, -1000);
+ state = wait_charging_state();
+ TEST_ASSERT(state == PWR_STATE_DISCHARGE);
+ sb_write(SB_TEMPERATURE, 0xffff);
+ state = wait_charging_state();
+ TEST_ASSERT(!is_shutdown);
+ TEST_ASSERT(state == PWR_STATE_DISCHARGE);
+ sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(40));
+
/* Discharging overtemp */
ccprintf("[CHARGING TEST] AC off, batt temp = 90 C\n");
gpio_set_level(GPIO_AC_PRESENT, 0);