diff options
author | Ryan Zhang <Ryan.Zhang@quantatw.com> | 2016-07-15 11:10:59 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-17 21:23:55 -0700 |
commit | c9f150c3686d6148ec6b73b65c4689b6eb78b6b8 (patch) | |
tree | be50807a2f087922372465dc823e9183d33125ea | |
parent | 9c1e181e16e67f3f8c00b07588b1df9c21be9ed8 (diff) | |
download | chrome-ec-c9f150c3686d6148ec6b73b65c4689b6eb78b6b8.tar.gz |
Elm: 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:54944
BRANCH=master
TEST=Manual on Elm. 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.
Change-Id: I7782d333da89b872e33ea31304f878ca490329cf
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/360781
Reviewed-by: YH Huang <yh.huang@mediatek.com>
Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | board/elm/board.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/board/elm/board.c b/board/elm/board.c index 87b2db8281..1849756686 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -302,6 +302,19 @@ int board_set_active_charge_port(int charge_port) charge_port < CONFIG_USB_PD_PORT_COUNT); /* check if we are source VBUS on the port */ int source = gpio_get_level(GPIO_USB_C0_5V_EN); + 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; + } if (is_real_port && source) { CPRINTF("Skip enable p%d", charge_port); @@ -318,6 +331,7 @@ int board_set_active_charge_port(int charge_port) gpio_set_level(GPIO_USB_C0_CHARGE_L, 0); } + initialized = 1; return EC_SUCCESS; } |