diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-06-09 13:10:20 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-06-10 00:18:05 -0700 |
commit | e1eb211f318b0d95cf7801ba49bebce51e290833 (patch) | |
tree | 66efdcafb2d092c8efd13b9bfc2b59902607e410 | |
parent | 5cd47907a0a9d7865bea260f6d03ab795285eeef (diff) | |
download | chrome-ec-e1eb211f318b0d95cf7801ba49bebce51e290833.tar.gz |
charge_manager: Allow rejected 'Dont charge' request on init
If our battery isn't able to provide enough power to the EC on boot, we
should not cut off our input power, regardless of dual role
determination or other charging policy.
BUG=chrome-os-partner:54058
BRANCH=None
TEST=Manual on gru. Drain battery completely, attach USB-C charger,
verify that "Battery critical, don't disable charging" is seen on the
console and the EC doesn't brown out.
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I981f9dbf3d84390550bb696e561f5fa51ffc573a
Reviewed-on: https://chromium-review.googlesource.com/351224
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/kevin/board.c | 14 | ||||
-rw-r--r-- | common/charge_manager.c | 10 |
2 files changed, 22 insertions, 2 deletions
diff --git a/board/kevin/board.c b/board/kevin/board.c index 2e4060d13d..544dbbf864 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -183,6 +183,19 @@ uint16_t tcpc_get_alert_status(void) int board_set_active_charge_port(int charge_port) { enum bd99955_charge_port bd99955_port; + static int initialized; + + /* + * Reject charge port disable if our battery is critical and we + * have yet to initialize a charge port - continue to charge using + * charger ROM / POR settings. + */ + if (!initialized && + charge_port == CHARGE_PORT_NONE && + charge_get_percent() < 2) { + CPRINTS("Battery critical, don't disable charging"); + return -1; + } CPRINTS("New chg p%d", charge_port); @@ -198,6 +211,7 @@ int board_set_active_charge_port(int charge_port) break; } + initialized = 1; return bd99955_select_input_port(bd99955_port); } diff --git a/common/charge_manager.c b/common/charge_manager.c index 58f87819bd..69bda55a65 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -466,8 +466,14 @@ static void charge_manager_refresh(void) board_set_active_charge_port(new_port) == EC_SUCCESS) break; - /* 'Dont charge' request must be accepted */ - ASSERT(new_port != CHARGE_PORT_NONE); + /* + * Allow 'Dont charge' request to be rejected only if it + * is our initial selection. + */ + if (new_port == CHARGE_PORT_NONE) { + ASSERT(!active_charge_port_initialized); + return; + } /* * Zero the available charge on the rejected port so that |