From 54cc6d298cfd56be57c7efd808eeaad5e95e5347 Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Fri, 8 Dec 2017 11:34:11 -0800 Subject: coral: Add request nil override for Nasher BYD and LG batteries To avoid inadvertenly shutting off the charger, for these 2 batteries if the battery SOC is 0% and the battery requests 0 for voltage and current, then override this request with precharge current and max voltage to ensure that the battery wakes up. BUG=b:67018220 BRANCH=coral TEST=Connected external passive load and drained BYD battery to point where the D-FET gets disabled (~8.6v). Then connect external charger and verify that battery does requrest 0V/0A and that the override is active and the battery wakes up correctly. This CL was also verified in by Nasher ODM testing. Change-Id: Iff9ceffa010ac3e14107220f2a0c6eb475c1e46d Signed-off-by: Scott Collyer Reviewed-on: https://chromium-review.googlesource.com/817878 Tested-by: Scott Collyer Reviewed-by: Shawn N Commit-Queue: Scott Collyer --- board/coral/battery.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/board/coral/battery.c b/board/coral/battery.c index a103e5ec84..c4c922cacc 100644 --- a/board/coral/battery.c +++ b/board/coral/battery.c @@ -56,6 +56,7 @@ struct fet_info { struct fuel_gauge_info { const char *manuf_name; const char *device_name; + const uint8_t override_nil; const struct ship_mode_info ship_mode; const struct fet_info fet; }; @@ -328,6 +329,7 @@ static const struct board_batt_params info[] = { [BATTERY_LGC] = { .fuel_gauge = { .manuf_name = "LGC-LGC3.553", + .override_nil = 1, .ship_mode = { .reg_addr = 0x0, .reg_data = { 0x10, 0x10 }, @@ -356,6 +358,7 @@ static const struct board_batt_params info[] = { [BATTERY_BYD] = { .fuel_gauge = { .manuf_name = "BYD", + .override_nil = 1, .ship_mode = { .reg_addr = 0x0, .reg_data = { 0x10, 0x10 }, @@ -599,6 +602,30 @@ int charger_profile_override(struct charge_state_data *curr) return 0; } + /* + * Some batteries, when fully discharged, may request 0 voltage/current + * which can then inadvertently disable the charger leading to the + * battery not waking up. For this type of battery, marked by + * override_nil being set, if SOC is 0 and requested voltage/current is + * 0, then use precharge current and max voltage instead. + */ + if (board_battery_type != BATTERY_TYPE_COUNT && + info[board_battery_type].fuel_gauge.override_nil) { + int v = info[board_battery_type].batt_info.voltage_max; + int i = info[board_battery_type].batt_info.precharge_current; + + if (curr->requested_voltage == 0 && + curr->requested_current == 0 && + curr->batt.state_of_charge == 0) { + /* + * Battery is dead, override with precharge current and + * max voltage setting for the battery. + */ + curr->requested_voltage = v; + curr->requested_current = i; + } + } + return 0; } -- cgit v1.2.1