diff options
author | ChromeOS Developer <dparker@chromium.org> | 2014-03-21 14:06:02 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-03-25 00:43:18 +0000 |
commit | e6eb3f2773bfaff40a2b817c681cbd87043fb947 (patch) | |
tree | b545f620669016912fc8c9bfadb1f54e67d30be8 | |
parent | d44f38a733e605fdd5201d7c2a84a2eb84ddad57 (diff) | |
download | chrome-ec-e6eb3f2773bfaff40a2b817c681cbd87043fb947.tar.gz |
Clapper: Use HOOK_INIT to disable battery cuttoff
Previously the battery cutoff disable code was
relying on an extra AC change event that was sent
at power-on.
BUG=chrome-os-partner:27160
BRANCH=None
TEST=Enable ship mode with "ectool batterycutoff"
or "battcutoff" on the EC console. Disconnect
AC power (if connected) to turn off. Pluc AC
power back in for 1 second and unplug again.
System should stay powered.
Change-Id: I390aebc2d486bb9513914781eb68dc9e6c22fb89
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/191099
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | board/clapper/battery.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/board/clapper/battery.c b/board/clapper/battery.c index 376fbf7840..e0ed9fd4e6 100644 --- a/board/clapper/battery.c +++ b/board/clapper/battery.c @@ -65,8 +65,8 @@ static int cutoff(void) return rv; } -/* This is triggered when the AC state changes */ -static void wakeup(void) +/* This is triggered when the EC is powered or reset */ +static void wakeup_deferred(void) { int tmp; @@ -79,7 +79,17 @@ static void wakeup(void) } } } -DECLARE_HOOK(HOOK_AC_CHANGE, wakeup, HOOK_PRIO_DEFAULT); +DECLARE_DEFERRED(wakeup_deferred); + +static void wakeup(void) +{ + /* + * The deferred call ensures that wakeup_deferred is called from a + * task. This is required to talk to the battery over I2C. + */ + hook_call_deferred(wakeup_deferred, 0); +} +DECLARE_HOOK(HOOK_INIT, wakeup, HOOK_PRIO_DEFAULT); static int battery_command_cut_off(struct host_cmd_handler_args *args) { |