summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}