From f41d33b1d7432f159d3a24c8c31c064852620618 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Tue, 17 Feb 2015 11:34:53 -0800 Subject: samus: avoid attempting unwedge charge circuit if VBUS is at 5V Change unwedge code to not attempt unwedging circuit if VBUS is at 5V because the circuit can't wedge itself at 5V. If BQ PROCHOT is high, we should just read it to clear it, and move on. BUG=chrome-os-partner:36081 BRANCH=samus TEST=test with ramp code. make sure ramp never gets stuck at minimum value because we are in the middle of unwedging the circuit when ramp starts. also test that manually wedging charge circuit with zinger using "charger voltage 7000" is still recovered from. Change-Id: I209bf324eab39bdca1948b7764870a909ea480c8 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/250463 Reviewed-by: Duncan Laurie --- board/samus/extpower.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/board/samus/extpower.c b/board/samus/extpower.c index c0b5283777..3947dc7de9 100644 --- a/board/samus/extpower.c +++ b/board/samus/extpower.c @@ -289,7 +289,7 @@ static int log_charge_wedged(void) static void check_charge_wedged(void) { - int rv, prochot_status, boostin_voltage; + int rv, prochot_status, batt_discharging_on_ac, boostin_voltage; static int counts_since_wedged; static int charge_stalled_count = CHARGE_STALLED_COUNT; uint8_t *batt_flags = host_get_memmap(EC_MEMMAP_BATT_FLAG); @@ -301,13 +301,22 @@ static void check_charge_wedged(void) if (rv) prochot_status = 0; + batt_discharging_on_ac = + (*batt_flags & EC_BATT_FLAG_AC_PRESENT) && + (*batt_flags & EC_BATT_FLAG_DISCHARGING); + + /* + * If PROCHOT is set or we are discharging on AC, then we + * need to know boostin_voltage. + */ + if (prochot_status || batt_discharging_on_ac) + boostin_voltage = get_boostin_voltage(); + /* * If AC is present, and battery is discharging, and * boostin voltage is above 5V, then we might be wedged. */ - if ((*batt_flags & EC_BATT_FLAG_AC_PRESENT) && - (*batt_flags & EC_BATT_FLAG_DISCHARGING)) { - boostin_voltage = get_boostin_voltage(); + if (batt_discharging_on_ac) { if (boostin_voltage > 6000) charge_stalled_count--; else if (boostin_voltage >= 0) @@ -326,15 +335,17 @@ static void check_charge_wedged(void) counts_since_wedged++; /* - * If PROCHOT is asserted, then charge circuit is wedged. If - * charging has been stalled long enough, then also consider - * the circuit wedged. To unwedge the charge circuit turn - * on learn mode and notify PD to disable charging on all ports. + * If PROCHOT is asserted AND boost_in voltage is above 5V, + * then charge circuit is wedged. If charging has been stalled + * long enough, then also consider the circuit wedged. + * + * To unwedge the charge circuit turn on learn mode and notify + * PD to disable charging on all ports. * Note: learn mode is critical here because when in this state * backboosting causes >20V on boostin even after PD disables * CHARGE_EN lines. */ - if ((prochot_status && + if ((prochot_status && boostin_voltage > 6000 && counts_since_wedged >= MIN_COUNTS_BETWEEN_UNWEDGES) || charge_stalled_count <= 0) { counts_since_wedged = 0; -- cgit v1.2.1