summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2019-10-25 01:54:37 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-01 05:42:13 +0000
commit888210c360e209006198b0465b8e662d73fe653a (patch)
tree873b8922d3e7fa97d2da358cdbb401841d0198bd
parentf21ba2ec6940758e49bff5b0bd78d148a7026a53 (diff)
downloadchrome-ec-888210c360e209006198b0465b8e662d73fe653a.tar.gz
atlas: initialize max charge current
the isl923x is strapped to initialize the charge current to 3A. however, its default max charge current limit is 3.072. when the charge current exceeds the current limit, the charger asserts PROCHOT which means the AP gets throttled to 400MHz until the charge_state machine updates the current limit. on an unlocked system, we don't change the charge limit from its default, so we never apply the 5% derating needed to avoid the isl923x from over-currenting the charger. the solution is to over-ride the 3A strapping of the isl923x by appling a 5% derated current request early when we boot up. BUG=b:141533503 BRANCH=none TEST=atlas no longer boots into PROCHOT on 5v3a charger Change-Id: Idba55edf7b1c0eec36b6583aa0b276c3cb1f0c89 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1889312 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit 40b0cd04aeb2ac5c59b295106fb5d4cd2d2397a5) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1894803 Reviewed-by: Caveh Jalali <caveh@google.com> Commit-Queue: Caveh Jalali <caveh@google.com>
-rw-r--r--board/atlas/board.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 4fa4224601..faf36caa68 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -514,6 +514,22 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
+/*
+ * Limit the input current to 95% negotiated limit,
+ * to account for the charger chip margin.
+ */
+
+static int charger_derate(int current)
+{
+ return current * 95 / 100;
+}
+
+static void board_charger_init(void)
+{
+ charger_set_input_current(charger_derate(PD_MAX_CURRENT_MA));
+}
+DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT);
+
/**
* Set the charge limit based upon desired maximum.
*
@@ -525,11 +541,7 @@ 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 the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = (charge_ma * 95) / 100;
+ charge_ma = charger_derate(charge_ma);
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}