From 2ff6a30c47142db02be4b52ab42f2dd4da5aeb59 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Wed, 12 Nov 2014 08:55:34 -0800 Subject: samus: enable bq learn mode to avoid backboosting For samus, use learn mode on BQ24773 to avoid the soft start that causes backboosting on some boards. BUG=chrome-os-partner:33644 BRANCH=samus TEST=tested in EE lab on a board that was backboosting reliable. this fixes backboosting at 5V, and also on 20V to 5V transitions. Change-Id: I97c52a55ba07662d444e67bfbc9ca488b530f423 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/229282 Reviewed-by: Duncan Laurie --- board/samus/extpower.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/board/samus/extpower.c b/board/samus/extpower.c index 4da7e655a7..60f97a4da2 100644 --- a/board/samus/extpower.c +++ b/board/samus/extpower.c @@ -8,6 +8,7 @@ * Drive high in S5-S0 when AC_PRESENT is high, otherwise drive low. */ +#include "charger.h" #include "chipset.h" #include "common.h" #include "extpower.h" @@ -25,10 +26,24 @@ int extpower_is_present(void) */ static void extpower_deferred(void) { + static int extpower_prev; + int extpower = extpower_is_present(); + + if (extpower && !extpower_prev) { + charger_discharge_on_ac(0); + } else if (extpower && extpower_prev) { + /* glitch on AC_PRESENT, attempt to recover from backboost */ + charger_discharge_on_ac(1); + charger_discharge_on_ac(0); + } else { + charger_discharge_on_ac(1); + } + extpower_prev = extpower; + hook_notify(HOOK_AC_CHANGE); /* Forward notification to host */ - if (extpower_is_present()) + if (extpower) host_set_single_event(EC_HOST_EVENT_AC_CONNECTED); else host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED); @@ -66,6 +81,8 @@ static void extpower_init(void) { extpower_buffer_to_pch(); + hook_call_deferred(extpower_deferred, 0); + /* Enable interrupts, now that we've initialized */ gpio_enable_interrupt(GPIO_AC_PRESENT); } -- cgit v1.2.1