From 275606d104183c09ecabae3affa914e9f3b22926 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Mon, 16 Feb 2015 15:01:39 -0800 Subject: samus: avoid waking extpower task until task has been initialized Fix booting without battery by avoiding waking the extpower task until it has run extpower_board_hacks() the first time. The problem was if there was no battery and AC was attached, extpower_board_hacks() would run twice on boot, once in extpower task initialization, before the while(1) loop, and a second time due to the AC_PRESENT interrupt. This would cause extpower_board_hacks() to think that AC had transitioned from 1 to 1, which represents a glitch on ACOK, so it would disable charging, thus causing us to lose power. BUG=chrome-os-partner:35570 BRANCH=samus TEST=load on a samus and boot with and without battery Change-Id: Idf6d0022f7dbedbb66a2fbe1c2b7dd885eabc43b Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/250301 Reviewed-by: Shawn N Reviewed-by: Duncan Laurie --- board/samus/extpower.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'board') diff --git a/board/samus/extpower.c b/board/samus/extpower.c index 19f4a5d5ff..c0b5283777 100644 --- a/board/samus/extpower.c +++ b/board/samus/extpower.c @@ -35,6 +35,9 @@ static int bkboost_detected; /* Charging is disabled */ static int charge_is_disabled; +/* Extpower task has been initialized */ +static int extpower_task_initialized; + /* * Charge circuit occasionally gets wedged and doesn't charge. * This variable keeps track of the state of the circuit. @@ -70,10 +73,12 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, extpower_shutdown, HOOK_PRIO_DEFAULT); void extpower_interrupt(enum gpio_signal signal) { + /* Trigger notification of external power change */ extpower_buffer_to_pch(); - /* Trigger notification of external power change */ - task_wake(TASK_ID_EXTPOWER); + /* Wake extpower task only if task has been initialized */ + if (extpower_task_initialized) + task_wake(TASK_ID_EXTPOWER); } static void extpower_init(void) @@ -369,6 +374,7 @@ void extpower_task(void) extpower_board_hacks(extpower, extpower_prev); extpower_prev = extpower; + extpower_task_initialized = 1; /* Enable backboost detection interrupt */ gpio_enable_interrupt(GPIO_BKBOOST_DET); -- cgit v1.2.1