summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-07-30 06:06:24 +0800
committerChromeBot <chrome-bot@google.com>2013-07-29 19:50:55 -0700
commit9972aee4e8dd18d8fc87bcb4f8b999dec686f33c (patch)
treec9b8fb0eb4f186ebb7b760a73b48bd233e96bf92
parent6ec9723e938b078d7df19d987add0bd1bc8af81f (diff)
downloadchrome-ec-9972aee4e8dd18d8fc87bcb4f8b999dec686f33c.tar.gz
spring: Check battery cut off in PMU task
Now we are not doing EC hibernate, let's move battery cut off check to PMU task so that it's called periodcally. BUG=chrome-os-partner:21107 TEST=Discharge the battery and unplug AC. Check battery is cut off. BRANCH=Spring Change-Id: I859fae81fd1f94df6903a0e2bbee5707e7ea13c4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/63641 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/battery_spring.c3
-rw-r--r--common/gaia_power.c14
-rw-r--r--common/pmu_tps65090_charger.c3
3 files changed, 6 insertions, 14 deletions
diff --git a/common/battery_spring.c b/common/battery_spring.c
index 34fb2f8aed..4156537968 100644
--- a/common/battery_spring.c
+++ b/common/battery_spring.c
@@ -6,6 +6,7 @@
*/
#include "battery_pack.h"
+#include "chipset.h"
#include "console.h"
#include "host_command.h"
#include "i2c.h"
@@ -48,6 +49,8 @@ int battery_check_cut_off(void)
if (!BATTERY_CUT_OFF_MV)
return 0;
+ if (chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_SUSPEND))
+ return 0;
if (battery_voltage(&voltage))
return 0;
if (voltage > BATTERY_CUT_OFF_MV)
diff --git a/common/gaia_power.c b/common/gaia_power.c
index a652122e53..c2affbc4ca 100644
--- a/common/gaia_power.c
+++ b/common/gaia_power.c
@@ -23,7 +23,6 @@
* - If XPSHOLD is dropped by the AP, then we power the AP off
*/
-#include "battery_pack.h"
#include "clock.h"
#include "chipset.h" /* This module implements chipset functions too */
#include "common.h"
@@ -585,19 +584,6 @@ void gaia_power_task(void)
gaia_power_init();
ap_on = 0;
- /*
- * If we are waken by RTC, check if we want to cut off the battery
- * instead of booting the AP
- */
- if (system_get_reset_flags() & RESET_FLAG_RTC_ALARM) {
- int rv;
- auto_power_on = 0;
- ccprintf("[%T Wake from RTC. Check battery.]\n");
- rv = battery_check_cut_off();
- ccprintf("[%T Want cut off = %d]\n", rv);
- system_hibernate(CONFIG_HIBERNATE_WAKE_PERIOD_SECS, 0);
- }
-
while (1) {
/* Wait until we need to power on, then power on */
wait_for_power_on();
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index c81db6a2e2..6f057fbe39 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -5,6 +5,7 @@
* TI TPS65090 PMU charging task.
*/
+#include "battery_pack.h"
#include "board.h"
#include "clock.h"
#include "chipset.h"
@@ -455,6 +456,8 @@ void pmu_charger_task(void)
board_usb_charge_update(0);
#endif
+ battery_check_cut_off();
+
/*
* When battery is extremely low, the internal voltage can not
* power on its gas guage IC. Charging loop will enable the