diff options
author | Duncan Laurie <dlaurie@google.com> | 2017-03-07 09:43:37 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-03-09 01:09:35 -0800 |
commit | 97b7f85ffe75ade72530b056a7024360a6b14e6d (patch) | |
tree | 5bc3c4a9eede9ad46c4bc1e4097fde690fd1b75d /board/eve/battery.c | |
parent | 06fbe70e50e99ef3d15d749049318049a0dbd48e (diff) | |
download | chrome-ec-97b7f85ffe75ade72530b056a7024360a6b14e6d.tar.gz |
eve: discharge on AC when no charger is inserted
To prevent in rush current from the charger when attached, enable
discharge on AC until the charger is detected.
This required enabling charger profile override which was previously
not getting called, so discharging was never disabled.
BUG=b:36024657
BRANCH=none
TEST=build and boot on eve, ensure battery charges with AC attached
Change-Id: Ie5912c1d4981d894366f36f31607d5f66a04c346
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/450951
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/eve/battery.c')
-rw-r--r-- | board/eve/battery.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/board/eve/battery.c b/board/eve/battery.c index e20d35dd85..31aad580fb 100644 --- a/board/eve/battery.c +++ b/board/eve/battery.c @@ -8,6 +8,7 @@ #include "battery.h" #include "battery_smart.h" #include "bd9995x.h" +#include "charge_ramp.h" #include "charge_state.h" #include "console.h" #include "ec_commands.h" @@ -194,11 +195,59 @@ enum battery_disconnect_state battery_get_disconnect_state(void) return BATTERY_NOT_DISCONNECTED; } +static int charger_should_discharge_on_ac(struct charge_state_data *curr) +{ + /* Can not discharge on AC without battery */ + if (curr->batt.is_present != BP_YES) + return 0; + + /* Do not discharge on AC if the battery is still waking up */ + if (!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && + !(curr->batt.status & STATUS_FULLY_CHARGED)) + return 0; + + /* + * In light load (<450mA being withdrawn from VSYS) the DCDC of the + * charger operates intermittently i.e. DCDC switches continuously + * and then stops to regulate the output voltage and current, and + * sometimes to prevent reverse current from flowing to the input. + * This causes a slight voltage ripple on VSYS that falls in the + * audible noise frequency (single digit kHz range). This small + * ripple generates audible noise in the output ceramic capacitors + * (caps on VSYS and any input of DCDC under VSYS). + * + * To overcome this issue enable the battery learning operation + * and suspend USB charging and DC/DC converter. + */ + if (!battery_is_cut_off() && + !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && + (curr->batt.status & STATUS_FULLY_CHARGED)) + return 1; + + /* + * To avoid inrush current from the external charger, enable + * discharge on AC 2till the new charger is detected and charge + * detect delay has passed. + */ + if (!chg_ramp_is_detected() && curr->batt.state_of_charge > 2) + return 1; + + return 0; +} + int charger_profile_override(struct charge_state_data *curr) { const struct battery_info *batt_info; /* battery temp in 0.1 deg C */ int bat_temp_c = curr->batt.temperature - 2731; + int disch_on_ac = charger_should_discharge_on_ac(curr); + + charger_discharge_on_ac(disch_on_ac); + + if (disch_on_ac) { + curr->state = ST_DISCHARGE; + return 0; + } batt_info = battery_get_info(); /* Don't charge if outside of allowable temperature range */ |