From a04a2cb9af4c71773cfa0ea1b7aa9528cc1dc62f Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Fri, 9 Sep 2016 10:41:34 -0700 Subject: [PATCH] kevin: Use maximum negotiated charge limit on critical battery To improve spec compliance, we reduce input current limit on PD voltage transition. This may cause us to brownout if the battery cannot provide sufficient current, so use the max. negotiated current when our battery is critical. BUG=chrome-os-partner:56139 BRANCH=None TEST=Boot with critical battery on kevin, verify system boots to OS without brownout. Change-Id: I1bdb2b7168c7b810af789e2206d0420f5d2bdcdd Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/383733 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Vincent Palatin --- board/kevin/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/board/kevin/board.c b/board/kevin/board.c index 37e6f646a8..fb134c31e4 100644 --- a/board/kevin/board.c +++ b/board/kevin/board.c @@ -238,6 +238,17 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma) { + /* + * Ignore lower charge ceiling on PD transition if our battery is + * critical, as we may brownout. + */ + if (supplier == CHARGE_SUPPLIER_PD && + charge_ma < 1500 && + charge_get_percent() < 2) { + CPRINTS("Using max ilim %d", max_ma); + charge_ma = max_ma; + } + charge_set_input_current_limit(MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT)); }