From fcf26a43ab1737acc873afcc1b61b4fb20389966 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Tue, 22 Apr 2014 16:34:12 -0700 Subject: charger v2: supports charger watchdog Some chargers support a timeout mechanism that it would stop charging if no voltage/current setting comes from battery or EC. This is designed for safety. In charger v1, it always updates charger periodically. But in v2, old code only updates charger when needed. New code updates the charger periodically. Also keep the ability for debugging. A manual mode is introduced so that any requested volt/curr from host and force idle mode request would trigger this mode. To leave this mode, just disable the force idle mode. BUG=chrome-os-partner:28201,chrome-os-partner:28208 BRANCH=nyan TEST=See below. Plug AC and battery. Wait for 10 mins and the battery is charged normally. 'chgstate idle on': the charger doesn't charge the battery. 'chgstate idle off': charge again. Plug in AC and remove battery: No annoying repeated message and works fine. Plug in battery and remove AC: No annoying repeated message and works fine. Power up machine with battery only: No annoying repeated message and works fine. Power up machine with AC only: No annoying repeated message and works fine. Change-Id: I00d62f8afa2fe2627ea9259f11679ced02af897a Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://chromium-review.googlesource.com/196385 --- test/sbs_charging_v2.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/sbs_charging_v2.c b/test/sbs_charging_v2.c index 095405b3bb..31dfb34e25 100644 --- a/test/sbs_charging_v2.c +++ b/test/sbs_charging_v2.c @@ -105,6 +105,14 @@ static int wait_charging_state(void) return state; } +static int charge_control(enum ec_charge_control_mode mode) +{ + struct ec_params_charge_control params; + params.mode = mode; + return test_send_host_command(EC_CMD_CHARGE_CONTROL, 1, ¶ms, + sizeof(params), NULL, 0); +} + /* Setup init condition */ static void test_setup(int on_ac) { @@ -134,18 +142,13 @@ static void test_setup(int on_ac) gpio_set_level(GPIO_AC_PRESENT, 0); } + /* Reset the charger state to initial state */ + charge_control(CHARGE_CONTROL_NORMAL); + /* Let things stabilize */ wait_charging_state(); } -static int charge_control(enum ec_charge_control_mode mode) -{ - struct ec_params_charge_control params; - params.mode = mode; - return test_send_host_command(EC_CMD_CHARGE_CONTROL, 1, ¶ms, - sizeof(params), NULL, 0); -} - /* Host Event helpers */ static int ev_is_set(int event) { -- cgit v1.2.1