diff options
author | Peter Marheine <pmarheine@chromium.org> | 2022-11-09 16:51:36 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-11-17 00:47:22 +0000 |
commit | ec31407993ec9b5ae14fed72d728a4061d656d65 (patch) | |
tree | f576b45529cfa8b2b29a7bbcbbff36e33c686b61 /include | |
parent | fcc7716bf1461477a3b3d8a53b85fdc81df677e4 (diff) | |
download | chrome-ec-ec31407993ec9b5ae14fed72d728a4061d656d65.tar.gz |
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 <pmarheine@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4015966
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Commit-Queue: Keith Short <keithshort@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/charge_state_v2.h | 3 | ||||
-rw-r--r-- | include/config.h | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h index 0817204774..5f886257d3 100644 --- a/include/charge_state_v2.h +++ b/include/charge_state_v2.h @@ -71,6 +71,9 @@ int charge_set_output_current_limit(int chgnum, int ma, int mv); * Set the charge input current limit. This value is stored and sent every * time AC is applied. * + * The input current limit is automatically derated by + * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT, if configured. + * * @param ma New input current limit in mA * @param mv Negotiated charge voltage in mV. * @return EC_SUCCESS or error diff --git a/include/config.h b/include/config.h index 10de8f80bf..baf86db418 100644 --- a/include/config.h +++ b/include/config.h @@ -1038,6 +1038,21 @@ #undef CONFIG_CHARGER_INPUT_CURRENT /* + * Percentage derating factor applied to charger input current limits. + * + * Desired charger current is reduced by this many percent when programming + * chargers via the charge manager, which is usually used to account for + * chargers that draw slightly more current than the programmed limit or to + * provide some margin for accuracy. For example, if this value is set to 4 + * and input current is limited to 1000 mA, the charger will be given a limit + * of 960 mA. + * + * Boards requiring more complex control over input current should leave this + * undefined and override board_set_charge_limit instead. + */ +#undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT + +/* * This config option is used to enable IDCHG trigger for prochot. This macro * should be set to the desired current limit to draw from the battery before * triggering prochot. Note that is has a 512 mA granularity. The function that |