From a4e14b97193fe079d18e929ce9d28b586d5418de Mon Sep 17 00:00:00 2001 From: Scott Chao Date: Wed, 16 Sep 2020 18:45:28 +0800 Subject: eldrid: limit input current to 90% Protect adapter provide overcurrent. And follow OEM charger policy to set 90% input current limit when S0. BUG=b:169025944 BRANCH=none TEST=make -j BOARD=eldrid TEST=make buildall Signed-off-by: Scott Chao Change-Id: Idc5aa532aaf5f4c7db45d9db2e1ce66032611a53 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2413810 Reviewed-by: Abe Levkoy --- board/eldrid/board.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'board') diff --git a/board/eldrid/board.c b/board/eldrid/board.c index dad5e88cf2..e1baf7bf55 100644 --- a/board/eldrid/board.c +++ b/board/eldrid/board.c @@ -8,6 +8,7 @@ #include "common.h" #include "accelgyro.h" #include "cbi_ec_fw_config.h" +#include "charge_state_v2.h" #include "driver/accel_bma2x2.h" #include "driver/accelgyro_bmi160.h" #include "driver/bc12/pi3usb9201.h" @@ -117,6 +118,21 @@ __override bool board_is_tbt_usb4_port(int port) && ((usb_db == DB_USB4_GEN2) || (usb_db == DB_USB4_GEN3))); } +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + /* + * Follow OEM request to limit the input current to + * 90% negotiated limit when S0. + */ + if (chipset_in_state(CHIPSET_STATE_ON)) + charge_ma = charge_ma * 90 / 100; + + charge_set_input_current_limit(MAX(charge_ma, + CONFIG_CHARGER_INPUT_CURRENT), + charge_mv); +} + /******************************************************************************/ /* Physical fans. These are logically separate from pwm_channels. */ -- cgit v1.2.1