summaryrefslogtreecommitdiff
path: root/common/battery.c
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2014-04-24 13:34:59 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-25 03:41:58 +0000
commit3ac560d41bf8c225725cdf03c2b4f4d723739d0f (patch)
tree687b9335e739ffd62ffe910742bd8a87e987537a /common/battery.c
parentb0409436adcf68cda3bf70a2964b9fdee599189a (diff)
downloadchrome-ec-3ac560d41bf8c225725cdf03c2b4f4d723739d0f.tar.gz
battery: don't talk to battery after cut-off
Add a shortcut in smart battery driver and i2c passthru. Once the battery cut-off order is submitted (in the factory line), the EC will no longer talk to battery. BUG=chrome-os-partner:28248 BRANCH=tot,nyan TEST=See below > remove AC, cutoff: expect system is off. > cutoff, then remove AC: expect system is off. > cutoff, wait for 1 min, then remove AC: expect system is off. Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Change-Id: Ied963c19d17d581ce99e4543469cf2fa165f0439 Reviewed-on: https://chromium-review.googlesource.com/196657 Tested-by: Yung-chieh Lo <yjlou@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Yung-chieh Lo <yjlou@chromium.org>
Diffstat (limited to 'common/battery.c')
-rw-r--r--common/battery.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/common/battery.c b/common/battery.c
index 19ad2e49b8..b6e79bb383 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -9,12 +9,18 @@
#include "charge_state.h"
#include "common.h"
#include "console.h"
+#include "extpower.h"
#include "gpio.h"
+#include "hooks.h"
#include "host_command.h"
#include "timer.h"
#include "util.h"
#include "watchdog.h"
+#ifdef CONFIG_BATTERY_CUT_OFF
+static int is_cut_off;
+#endif
+
#ifdef CONFIG_BATTERY_PRESENT_GPIO
#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
#error "Don't define both CONFIG_BATTERY_PRESENT_CUSTOM and" \
@@ -252,19 +258,44 @@ DECLARE_CONSOLE_COMMAND(battery, command_battery,
#ifdef CONFIG_BATTERY_CUT_OFF
-int battery_command_cut_off(struct host_cmd_handler_args *args)
+int battery_is_cut_off(void)
+{
+ return is_cut_off;
+}
+
+static void clean_cut_off(void)
+{
+ if (extpower_is_present())
+ is_cut_off = 0;
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, clean_cut_off, HOOK_PRIO_DEFAULT);
+
+static int battery_command_cut_off(struct host_cmd_handler_args *args)
{
- return board_cut_off_battery();
+ int rv = board_cut_off_battery();
+ if (!rv)
+ is_cut_off = 1;
+
+ return rv;
}
DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off,
EC_VER_MASK(0));
static int command_cutoff(int argc, char **argv)
{
- return board_cut_off_battery();
+ int rv = board_cut_off_battery();
+ if (!rv)
+ is_cut_off = 1;
+
+ return rv;
}
DECLARE_CONSOLE_COMMAND(cutoff, command_cutoff,
"",
"Cut off the battery output",
NULL);
+#else
+int battery_is_cut_off(void)
+{
+ return 0; /* Always return NOT cut off */
+}
#endif /* CONFIG_BATTERY_CUT_OFF */