diff options
author | Aseda Aboagye <aaboagye@google.com> | 2017-09-22 10:18:46 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-10-23 04:28:24 -0700 |
commit | faec1ed7d5dc5f122b20741f523695e39a5b7966 (patch) | |
tree | 6dfab58127512774a79f9a170b2a3888b8e09285 | |
parent | 6c995e7e882e6693acb283a5042e40368c9aaf53 (diff) | |
download | chrome-ec-faec1ed7d5dc5f122b20741f523695e39a5b7966.tar.gz |
zoombini: Reject chg port none w/ critical batt.
In the event where we don't have a battery, or the battery is criticial,
we should reject the charge port of "none" such that we don't stop
charging.
BUG=b:66516888
BRANCH=None
TEST=Flash zoombini; Unplug battery, plug in a Type-C charger, verify
that board doesn't enter a reboot loop.
TEST=Repeat the above test with all Type-C ports.
Change-Id: I794e370d5ba578adb76b3fb6edddb82ab72578bb
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/678836
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | board/zoombini/board.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/board/zoombini/board.c b/board/zoombini/board.c index 86ae2d8fff..a9bd30e382 100644 --- a/board/zoombini/board.c +++ b/board/zoombini/board.c @@ -216,10 +216,23 @@ int board_set_active_charge_port(int port) { int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_COUNT); + static int initialized; if (!is_real_port && port != CHARGE_PORT_NONE) return EC_ERROR_INVAL; + /* + * Reject charge port none if our battery is critical and we + * have yet to initialize a charge port - continue to charge using + * charger ROM / POR settings. + */ + if (!initialized && + port == CHARGE_PORT_NONE && + charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { + CPRINTS("Bat critical, don't stop charging"); + return -1; + } + CPRINTS("New chg p%d", port); if (port == CHARGE_PORT_NONE) { @@ -227,6 +240,7 @@ int board_set_active_charge_port(int port) gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 1); gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 1); gpio_set_level(GPIO_USB_C2_CHARGE_EN_L, 1); + initialized = 1; return EC_SUCCESS; } @@ -242,6 +256,7 @@ int board_set_active_charge_port(int port) gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, port != 0); gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, port != 1); gpio_set_level(GPIO_USB_C2_CHARGE_EN_L, port != 2); + initialized = 1; return EC_SUCCESS; } |