From faeaf04ec20b67eb9804015c0cff304408dafdc9 Mon Sep 17 00:00:00 2001 From: "david.huang" Date: Wed, 10 Jan 2018 14:56:35 +0800 Subject: Yuna: Change charge voltage for battery Change battery charge voltage based on Cycle Count or State of Health for different battery. BRANCH=yuna BUG=b:37727454 TEST=Use console command "charger" to check charge voltage with different battery. Change-Id: Idcdac0e2e3efa815b660d3b3b8db7a091e4ceb98 Signed-off-by: David Huang Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/858991 Tested-by: Stefan Reinauer Reviewed-by: Vincent Wang Reviewed-by: Scott Collyer --- board/yuna/bq24707a.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/board/yuna/bq24707a.c b/board/yuna/bq24707a.c index 7ac082554c..1dd52816af 100644 --- a/board/yuna/bq24707a.c +++ b/board/yuna/bq24707a.c @@ -152,40 +152,40 @@ int charger_get_voltage(int *voltage) static int battery_charge_voltage_check(void) { - int cycle, fcc, dc, soh, rv, change = 0; + int cycle, fcc, dc, soh, rv; char device[10]; if (!battery_device_name(device, sizeof(device))) { - CPRINTF("Battery device name : %s", device); if (!strcasecmp(device, "AC14B8K")) { rv = battery_cycle_count(&cycle); - if (!rv && cycle >= 21) { - CPRINTF("Cycle change charge voltage\n"); - change = 1; - return change; - } + if (!rv && cycle >= 21) + return 1; } else if (!strcasecmp(device, "AC14B3K")) { rv = battery_full_charge_capacity(&fcc); rv &= battery_design_capacity(&dc); if (!rv) { soh = fcc*100/dc; - if (soh <= 95) { - CPRINTF("SOH change charge voltage\n"); - change = 1; - return change; - } + if (soh <= 95) + return 1; } } } - return change; + return 0; } int charger_set_voltage(int voltage) { + char device[10]; + if (battery_charge_voltage_check()) { if (voltage != 0) { - CPRINTF("Change charge voltage\n"); - voltage = charger_closest_voltage(17000); + if (!battery_device_name(device, sizeof(device))) { + if (!strcasecmp(device, "AC14B8K")) + voltage = 17008; + else if (!strcasecmp(device, "AC14B3K")) + voltage = 17200; + } + voltage = charger_closest_voltage(voltage); } } else voltage = charger_closest_voltage(voltage); -- cgit v1.2.1