diff options
Diffstat (limited to 'board/clapper/battery.c')
-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) { |