diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 5dd30856d7..de7cfea731 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -306,19 +306,28 @@ static int charge_request(int voltage, int current) if (!voltage || !current) voltage = current = 0; - if (prev_volt != voltage || prev_curr != current) - CPRINTS("%s(%dmV, %dmA)", __func__, voltage, current); + if (curr.ac) { + if (prev_volt != voltage || prev_curr != current) + CPRINTS("%s(%dmV, %dmA)", __func__, voltage, current); + } + + /* + * Set current before voltage so that if we are just starting + * to charge, we allow some time (i2c delay) for charging circuit to + * start at a voltage just above battery voltage before jumping + * up. This helps avoid large current spikes when connecting + * battery. + */ + if (current >= 0) + r2 = charger_set_current(current); + if (r2 != EC_SUCCESS) + problem(PR_SET_CURRENT, r2); if (voltage >= 0) r1 = charger_set_voltage(voltage); if (r1 != EC_SUCCESS) problem(PR_SET_VOLTAGE, r1); - if (current >= 0) - r2 = charger_set_current(current); - if (r2 != EC_SUCCESS) - problem(PR_SET_CURRENT, r2); - /* * Set the charge inhibit bit when possible as it appears to save * power in some cases (e.g. Nyan with BQ24735). @@ -496,6 +505,7 @@ void charger_task(void) { int sleep_usec; int need_static = 1; + const struct charger_info * const info = charger_get_info(); /* Get the battery-specific values */ batt_info = battery_get_info(); @@ -766,6 +776,10 @@ wait_for_it: charge_request(curr.requested_voltage, curr.requested_current); } + } else { + charge_request( + charger_closest_voltage( + curr.batt.voltage + info->voltage_step), -1); } /* How long to sleep? */ diff --git a/driver/battery/samus.c b/driver/battery/samus.c index 6458af0199..89f6dc9b68 100644 --- a/driver/battery/samus.c +++ b/driver/battery/samus.c @@ -19,7 +19,7 @@ static const struct battery_info info = { * normal = 7.4V * min = 6.0V */ - .voltage_max = 8400, + .voltage_max = 8700, .voltage_normal = 7400, .voltage_min = 6000,