mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
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>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
64ada6e3d8
commit
88ccbe9323
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -125,6 +125,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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user