From ec31407993ec9b5ae14fed72d728a4061d656d65 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Wed, 9 Nov 2022 16:51:36 +1100 Subject: Add CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT Many boards derate their charge current limits by some fixed ratio, which results in duplicate code appearing in many different boards. Since nearly all of these are in implementations of board_set_charge_limit() and themselves call charge_set_input_current_limit(), make that derating a config option and move it into charge_set_input_current_limit(). This makes most boards' implementations uniform and ripe for further simplification in later changes. For those boards that do more complex adjustments, those can be retained by keeping the existing logic in board_set_charge_limit(). Several boards also uselessly defined multiple versions of board_set_charge_limit(): the redundant ones are removed. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=follow-up CLs delete uncovered code Change-Id: I0a7162e72538a91ad06ba85b91a10b93eb6af96b Signed-off-by: Peter Marheine Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4015966 Code-Coverage: Zoss Commit-Queue: Keith Short Reviewed-by: Keith Short --- board/elm/board.c | 2 -- board/elm/board.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'board/elm') diff --git a/board/elm/board.c b/board/elm/board.c index 4007d34379..329c411c8a 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -340,8 +340,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* Limit input current 95% ratio on elm board for safety */ - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); pd_send_host_event(PD_EVENT_POWER_CHANGE); diff --git a/board/elm/board.h b/board/elm/board.h index 2dc53dab75..31a6ec7b61 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -44,6 +44,7 @@ #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 #define CONFIG_CHARGER_DISCHARGE_ON_AC +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHIPSET_MT817X #define CONFIG_CMD_TYPEC #define CONFIG_EXTPOWER_GPIO -- cgit v1.2.1