summaryrefslogtreecommitdiff
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
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>
-rw-r--r--board/samus/board.h4
-rw-r--r--include/config.h13
-rw-r--r--power/common.c13
3 files changed, 27 insertions, 3 deletions
diff --git a/board/samus/board.h b/board/samus/board.h
index 394b621d74..d3bcc6a169 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -49,6 +49,10 @@
#define CONFIG_FANS 2
#define CONFIG_GESTURE_DETECTION
#define CONFIG_GESTURE_SAMPLING_INTERVAL_MS 5
+#undef CONFIG_HIBERNATE_DELAY_SEC
+#define CONFIG_HIBERNATE_DELAY_SEC (3600 * 24 * 7)
+#define CONFIG_HIBERNATE_BATT_PCT 10
+#define CONFIG_HIBERNATE_BATT_SEC (3600 * 24)
#define CONFIG_PECI_TJMAX 100
#define CONFIG_PWM
#define CONFIG_PWM_KBLIGHT
diff --git a/include/config.h b/include/config.h
index 59256c816a..ba9efeb4c7 100644
--- a/include/config.h
+++ b/include/config.h
@@ -587,6 +587,19 @@
/* Enable system hibernate */
#define CONFIG_HIBERNATE
+/* Default delay after shutting down before hibernating */
+#define CONFIG_HIBERNATE_DELAY_SEC 3600
+
+/*
+ * Use to define going in to hibernate early if low on battery.
+ * CONFIG_HIBERNATE_BATT_PCT specifies the low battery threshold
+ * for going into hibernate early, and CONFIG_HIBERNATE_BATT_SEC defines
+ * the minimum amount of time to stay in G3 before checking for low
+ * battery hibernate.
+ */
+#undef CONFIG_HIBERNATE_BATT_PCT
+#undef CONFIG_HIBERNATE_BATT_SEC
+
/* For ECs with multiple wakeup pins, define enabled wakeup pins */
#undef CONFIG_HIBERNATE_WAKEUP_PINS
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