summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-02-17 11:34:53 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-18 04:53:05 +0000
commitf41d33b1d7432f159d3a24c8c31c064852620618 (patch)
tree0ff16b4a1bc72e2d502b94f5272fea683ef66c25
parentaaa76256819c4a961073be3955fcc1668fa9e346 (diff)
downloadchrome-ec-f41d33b1d7432f159d3a24c8c31c064852620618.tar.gz
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 <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/250463 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
-rw-r--r--board/samus/extpower.c29
1 files 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;