mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-11 18:35:28 +00:00
samus: set BQ voltage to battery voltage when AC disconnected
Set charge state machine voltage to just above the battery voltage when AC is disconnected. Also send new current before sending new voltage to charger when there is a change. These changes reduce input current spikes caused by current inrush into the battery and thereby decrease chance of overcurrenting power supply on connect. BUG=chrome-os-partner:33862 BRANCH=samus TEST=load onto samus instrumented with input current probe. when AC is attached note that initial current spike is much lower with this change. Change-Id: I7760cd2b709c6b3536cf2a9449bb1f46800ce10a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/237245 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
2d4b6d2f43
commit
91bbfb780c
@@ -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? */
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user