From b0409436adcf68cda3bf70a2964b9fdee599189a Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Wed, 23 Apr 2014 16:39:32 -0700 Subject: [PATCH] charger v2: only configure charger when AC is on. The CL fcf26a4 enabled periodically charge_request(). However, that could fail and generates lots of error message in the EC console if the AC is not on and charger refuses the request (even it is 0v/0mA). BUG=none BRANCH=tot,nyan TEST=make runtests. Tested on big. Expect NO below annoying error message [1.353104 charge_request(0mV, 0mA)] [1.453170 charge_request(0mV, 0mA)] [1.553281 charge_request(0mV, 0mA)] [1.653317 charge_request(0mV, 0mA)] in the follwing cases: AC on, battery attached, power on, then remove/plug in AC. AC on, battery attached, power on, then remove/plug in battery. AC on, battery removed, power on, then plug in and remove battery. AC off, battery attached, power on, then plug in and remove AC. 'chgstate' also shows good state. At final, charge for 10 mins. Change-Id: Icc729c52246df1ecfb7f289b5078dbc122b20a74 Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://chromium-review.googlesource.com/196678 Reviewed-by: Lin Cloud Tested-by: Lin Cloud Reviewed-by: Devin Lu Reviewed-by: Bill Richardson --- common/charge_state_v2.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 2527d7f92a..36addbe332 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -617,16 +617,21 @@ wait_for_it: curr.requested_current = charger_closest_current(curr.requested_current); - /* - * As a safety feature, some chargers will stop charging if - * we don't communicate with it frequently enough. In manual - * mode, we'll just tell it what it already knows - */ - if (manual_mode) { - charge_request(curr.chg.voltage, curr.chg.current); - } else { - charge_request(curr.requested_voltage, - curr.requested_current); + /* Charger only accpets request when AC is on. */ + if (curr.ac) { + /* + * As a safety feature, some chargers will stop + * charging if we don't communicate with it frequently + * enough. In manual mode, we'll just tell it what it + * knows. + */ + if (manual_mode) { + charge_request(curr.chg.voltage, + curr.chg.current); + } else { + charge_request(curr.requested_voltage, + curr.requested_current); + } } /* How long to sleep? */