summaryrefslogtreecommitdiff
path: root/baseboard
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2022-11-09 16:51:36 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-17 00:47:22 +0000
commitec31407993ec9b5ae14fed72d728a4061d656d65 (patch)
treef576b45529cfa8b2b29a7bbcbbff36e33c686b61 /baseboard
parentfcc7716bf1461477a3b3d8a53b85fdc81df677e4 (diff)
downloadchrome-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 'baseboard')
-rw-r--r--baseboard/brya/charger_bq25720.c7
-rw-r--r--baseboard/grunt/baseboard.c5
-rw-r--r--baseboard/grunt/baseboard.h1
-rw-r--r--baseboard/octopus/baseboard.c7
-rw-r--r--baseboard/octopus/baseboard.h4
5 files changed, 5 insertions, 19 deletions
diff --git a/baseboard/brya/charger_bq25720.c b/baseboard/brya/charger_bq25720.c
index a4fa209246..7fabd2082e 100644
--- a/baseboard/brya/charger_bq25720.c
+++ b/baseboard/brya/charger_bq25720.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 5fbf2823be..50db1887f1 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -467,11 +467,6 @@ int board_set_active_charge_port(int port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- /*
- * Limit the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 95 / 100;
charge_set_input_current_limit(
MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 1c19c05330..b83b274d49 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -73,6 +73,7 @@
* See also b/111214767
*/
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c
index 0f012d1352..b35bbcd67b 100644
--- a/baseboard/octopus/baseboard.c
+++ b/baseboard/octopus/baseboard.c
@@ -301,13 +301,6 @@ int board_set_active_charge_port(int port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- /*
- * Empirically, the charger seems to draw a little more current that
- * it is set to, so we reduce our limit by 5%.
- */
-#if defined(CONFIG_CHARGER_BQ25710) || defined(CONFIG_CHARGER_ISL9238)
- charge_ma = (charge_ma * 95) / 100;
-#endif
charge_set_input_current_limit(
MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index 724540d0f0..8662749c98 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -125,6 +125,8 @@
*/
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 200
+/* Charger seems to overdraw by about 5% */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#elif defined(VARIANT_OCTOPUS_CHARGER_BQ25703)
#define CONFIG_CHARGER_BQ25703
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
@@ -133,6 +135,8 @@
*/
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 50
+/* Charger seems to overdraw by about 5% */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#elif defined(CONFIG_CHARGER_RUNTIME_CONFIG)
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_BQ25710