summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-12-16 11:47:48 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-23 18:16:18 +0000
commit91bbfb780c1383db9bcade9a63716a53e1725862 (patch)
tree3a1113b7bb94e5711c9a25fdce527484fe7deecf
parent2d4b6d2f43e8cbe95514b449ab28a484ca276730 (diff)
downloadchrome-ec-91bbfb780c1383db9bcade9a63716a53e1725862.tar.gz
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>
-rw-r--r--common/charge_state_v2.c28
-rw-r--r--driver/battery/samus.c2
2 files changed, 22 insertions, 8 deletions
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 (voltage >= 0)
- r1 = charger_set_voltage(voltage);
- if (r1 != EC_SUCCESS)
- problem(PR_SET_VOLTAGE, r1);
+ 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);
+
/*
* 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,