diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-01-14 16:11:47 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-15 05:13:14 +0000 |
commit | 88ccbe9323c2f7fdd0234bfcd561c2021c74eb4f (patch) | |
tree | 058d369f853c83dddb70112ed22d8d744c6730a7 | |
parent | 64ada6e3d8220e51a64b30ff15878f1abff11a47 (diff) | |
download | chrome-ec-88ccbe9323c2f7fdd0234bfcd561c2021c74eb4f.tar.gz |
charger: Make critical battery shutdown timeout a config option
Certain platforms may wish to have a longer shutdown timeout, so make
the timeout a config option.
BUG=chrome-os-partner:35188
TEST=Manual on Samus with subsequent CL. Set config option to increase
timeout, verify that timeout is extended.
BRANCH=Samus
Change-Id: I69feb0d31fdc53e533671dec1e88ba96cc4553c2
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/240815
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | common/charge_state_v1.c | 2 | ||||
-rw-r--r-- | common/charge_state_v2.c | 2 | ||||
-rw-r--r-- | include/charge_state.h | 3 | ||||
-rw-r--r-- | include/config.h | 12 | ||||
-rw-r--r-- | test/sbs_charging_v2.c | 12 |
5 files changed, 20 insertions, 11 deletions
diff --git a/common/charge_state_v1.c b/common/charge_state_v1.c index a39499a75d..b817049138 100644 --- a/common/charge_state_v1.c +++ b/common/charge_state_v1.c @@ -30,7 +30,7 @@ #define DEBOUNCE_TIME (10 * SECOND) #define LOW_BATTERY_SHUTDOWN_TIMEOUT_US \ - (CRITICAL_BATTERY_SHUTDOWN_TIMEOUT * SECOND) + (CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT * SECOND) #ifndef BATTERY_AP_OFF_LEVEL #define BATTERY_AP_OFF_LEVEL 0 diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index e692f68703..85a0d661c6 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -29,7 +29,7 @@ #define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) #define CRITICAL_BATTERY_SHUTDOWN_TIMEOUT_US \ - (CRITICAL_BATTERY_SHUTDOWN_TIMEOUT * SECOND) + (CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT * SECOND) #define PRECHARGE_TIMEOUT_US (PRECHARGE_TIMEOUT * SECOND) #define LFCC_EVENT_THRESH 5 /* Full-capacity change reqd for host event */ diff --git a/include/charge_state.h b/include/charge_state.h index ab9c1043b5..97c6ca404e 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -10,9 +10,6 @@ /* Stuff that's common to all charger implementations can go here. */ -/* Seconds after AP battery shutdown warning before we kill the AP */ -#define CRITICAL_BATTERY_SHUTDOWN_TIMEOUT 30 - /* Seconds to spend trying to wake a non-responsive battery */ #define PRECHARGE_TIMEOUT 30 diff --git a/include/config.h b/include/config.h index 1f2a5bcee6..529e4134d1 100644 --- a/include/config.h +++ b/include/config.h @@ -126,6 +126,18 @@ #undef CONFIG_BATTERY_SMART /* + * Critical battery shutdown timeout (seconds) + * + * If the battery is at extremely low charge (and discharging) or extremely + * high temperature, the EC will shut itself down. This defines the timeout + * period in seconds between the critical condition being detected and the + * EC shutting itself down. Note that if the critical condition is corrected + * before the timeout expiration, the EC will not shut itself down. + * + */ +#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT 30 + +/* * Support battery cut-off as host command and console command. * * Once defined, you have to implement a board_cut_off_battery() function diff --git a/test/sbs_charging_v2.c b/test/sbs_charging_v2.c index a42d286378..7bf467d2be 100644 --- a/test/sbs_charging_v2.c +++ b/test/sbs_charging_v2.c @@ -222,7 +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(CRITICAL_BATTERY_SHUTDOWN_TIMEOUT); + sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); TEST_ASSERT(is_shutdown); TEST_ASSERT(state == PWR_STATE_DISCHARGE); sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(40)); @@ -277,7 +277,7 @@ static int test_low_battery(void) ccprintf("[CHARGING TEST] Low battery with AC and negative current\n"); sb_write(SB_CURRENT, -1000); wait_charging_state(); - sleep(CRITICAL_BATTERY_SHUTDOWN_TIMEOUT); + sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); TEST_ASSERT(is_hibernated); ccprintf("[CHARGING TEST] Low battery shutdown S0->S5\n"); @@ -293,7 +293,7 @@ static int test_low_battery(void) hook_notify(HOOK_CHIPSET_SHUTDOWN); wait_charging_state(); /* after a while, the EC should hibernate */ - sleep(CRITICAL_BATTERY_SHUTDOWN_TIMEOUT); + sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); TEST_ASSERT(is_hibernated); ccprintf("[CHARGING TEST] Low battery shutdown S5\n"); @@ -303,7 +303,7 @@ static int test_low_battery(void) sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2); wait_charging_state(); /* after a while, the EC should hibernate */ - sleep(CRITICAL_BATTERY_SHUTDOWN_TIMEOUT); + sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); TEST_ASSERT(is_hibernated); ccprintf("[CHARGING TEST] Low battery AP shutdown\n"); @@ -334,7 +334,7 @@ static int test_high_temp_battery(void) wait_charging_state(); TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_SHUTDOWN)); TEST_ASSERT(!is_shutdown); - sleep(CRITICAL_BATTERY_SHUTDOWN_TIMEOUT); + sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); TEST_ASSERT(is_shutdown); ccprintf("[CHARGING TEST] High battery temp S0->S5 hibernate\n"); @@ -666,7 +666,7 @@ static int test_low_battery_hostevents(void) TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_SHUTDOWN)); TEST_ASSERT(!is_shutdown); /* after a while, the AP should shut down */ - sleep(CRITICAL_BATTERY_SHUTDOWN_TIMEOUT); + sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); TEST_ASSERT(is_shutdown); return EC_SUCCESS; |