summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-12-15 08:45:54 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-15 22:44:28 +0000
commitfca4977983cb6082047321c935e5efa64f9f5bdb (patch)
treede5919c4048b55782b005c2cfc0c7e5cea1203e8 /test
parent6cc992c3d703ecee5e44966a2a3f6580e85b60c3 (diff)
downloadchrome-ec-fca4977983cb6082047321c935e5efa64f9f5bdb.tar.gz
samus: add high battery temp warning to charge state machine
Add high (and low) battery temperature warning which sends host event to AP. After 30 seconds of out of range temp readings force shut off AP and hibernate the EC. BUG=chrome-os-partner:27641, chrome-os-partner:33111 BRANCH=samus TEST=make buildall, and write unit tests to test this condition. Change-Id: I95b7d9d753c17e4b76218a9845aa63dd1b96a500 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/235645 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/sbs_charging_v2.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/sbs_charging_v2.c b/test/sbs_charging_v2.c
index bb15a8d18b..bb5097948c 100644
--- a/test/sbs_charging_v2.c
+++ b/test/sbs_charging_v2.c
@@ -222,6 +222,7 @@ static int test_charge_state(void)
TEST_ASSERT(state == PWR_STATE_DISCHARGE);
sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(90));
state = wait_charging_state();
+ sleep(HIGH_TEMP_SHUTDOWN_TIMEOUT);
TEST_ASSERT(is_shutdown);
TEST_ASSERT(state == PWR_STATE_DISCHARGE);
sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(40));
@@ -265,14 +266,20 @@ static int test_low_battery(void)
{
test_setup(1);
- ccprintf("[CHARGING TEST] Low battery with AC\n");
-
+ ccprintf("[CHARGING TEST] Low battery with AC and positive current\n");
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2);
+ sb_write(SB_CURRENT, 1000);
wait_charging_state();
mock_chipset_state = CHIPSET_STATE_SOFT_OFF;
hook_notify(HOOK_CHIPSET_SHUTDOWN);
TEST_ASSERT(!is_hibernated);
+ ccprintf("[CHARGING TEST] Low battery with AC and negative current\n");
+ sb_write(SB_CURRENT, -1000);
+ wait_charging_state();
+ sleep(LOW_BATTERY_SHUTDOWN_TIMEOUT);
+ TEST_ASSERT(is_hibernated);
+
ccprintf("[CHARGING TEST] Low battery shutdown S0->S5\n");
mock_chipset_state = CHIPSET_STATE_ON;
hook_notify(HOOK_CHIPSET_PRE_INIT);
@@ -317,6 +324,27 @@ static int test_low_battery(void)
return EC_SUCCESS;
}
+static int test_high_temp_battery(void)
+{
+ test_setup(1);
+
+ ccprintf("[CHARGING TEST] High battery temperature shutdown\n");
+ ev_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN);
+ sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(90));
+ wait_charging_state();
+ TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_SHUTDOWN));
+ TEST_ASSERT(!is_shutdown);
+ sleep(HIGH_TEMP_SHUTDOWN_TIMEOUT);
+ TEST_ASSERT(is_shutdown);
+
+ ccprintf("[CHARGING TEST] High battery temp S0->S5 hibernate\n");
+ mock_chipset_state = CHIPSET_STATE_SOFT_OFF;
+ wait_charging_state();
+ TEST_ASSERT(is_hibernated);
+
+ return EC_SUCCESS;
+}
+
static int test_external_funcs(void)
{
int rv, temp;
@@ -650,6 +678,7 @@ void run_test(void)
{
RUN_TEST(test_charge_state);
RUN_TEST(test_low_battery);
+ RUN_TEST(test_high_temp_battery);
RUN_TEST(test_external_funcs);
RUN_TEST(test_hc_charge_state);
RUN_TEST(test_hc_current_limit);