From e6eb3f2773bfaff40a2b817c681cbd87043fb947 Mon Sep 17 00:00:00 2001 From: ChromeOS Developer Date: Fri, 21 Mar 2014 14:06:02 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/191099 Reviewed-by: Randall Spangler --- board/clapper/battery.c | 16 +++++++++++++--- 1 file 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) { -- cgit v1.2.1