summaryrefslogtreecommitdiff
path: root/power/common.c
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-10-20 16:44:18 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-21 22:44:58 +0000
commit60ddb3987a60a4a8b3a9daad9150021d017d0497 (patch)
treedd8ad8bcaab27fb80fb661880bb0fc08ee97456e /power/common.c
parentba98b92bbb03a62a466a36fbb50843a37602d98d (diff)
downloadchrome-ec-60ddb3987a60a4a8b3a9daad9150021d017d0497.tar.gz
samus: change hibernate delay to 7 days
Add macro for default hibernate delay, and set to 7 days on samus. Also, adds CONFIG_ option for hibernating early if low on battery. For samus, setting early hibernate at 1 day when battery < 10%. BUG=chrome-os-partner:33088 BRANCH=samus TEST=make buildall Added ccprintf("Target shutdown: %.6ld\n", target_time); to print out target shutdown time after setting it. Verifed the following on samus 1) If CONFIG_HIBERNATE_DELAY_SEC is left at default 3600 (samus board.h does not overwrite it), then target time is 3600s. 2) If CONFIG_HIBERNATE_DELAY_SEC is defined in samus/board.h, then target time equals that value. 3) If CONFIG_HIBERNATE_DELAY_SEC is defined as 1 week and CONFIG_HIBERNATE_BATT_PCT is defined to 10% and CONFIG_HIBERNATE_BATT_SEC is 1 day, then when battery is between 8-10% target time is 1 day and if battery is at 11%, target time is 1 week. Change-Id: Ief155ad6c327775fa348d3458fc47ee9dd8569c3 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224520 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'power/common.c')
-rw-r--r--power/common.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/power/common.c b/power/common.c
index 96c6966900..e08fcf369c 100644
--- a/power/common.c
+++ b/power/common.c
@@ -5,6 +5,7 @@
/* Common functionality across all chipsets */
+#include "charge_state.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -54,7 +55,7 @@ static uint64_t last_shutdown_time; /* When did we enter G3? */
#ifdef CONFIG_HIBERNATE
/* Delay before hibernating, in seconds */
-static uint32_t hibernate_delay = 3600;
+static uint32_t hibernate_delay = CONFIG_HIBERNATE_DELAY_SEC;
#endif
/**
@@ -146,9 +147,15 @@ static enum power_state power_common_state(enum power_state state)
if (extpower_is_present())
task_wait_event(-1);
else {
- uint64_t target_time = last_shutdown_time +
- hibernate_delay * 1000000ull;
+ uint64_t target_time;
uint64_t time_now = get_time().val;
+ uint32_t delay = hibernate_delay;
+#ifdef CONFIG_HIBERNATE_BATT_PCT
+ if (charge_get_percent() <= CONFIG_HIBERNATE_BATT_PCT
+ && CONFIG_HIBERNATE_BATT_SEC < delay)
+ delay = CONFIG_HIBERNATE_BATT_SEC;
+#endif
+ target_time = last_shutdown_time + delay * 1000000ull;
if (time_now > target_time) {
/*
* Time's up. Hibernate until wake pin