summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2014-04-22 16:34:12 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-23 20:50:48 +0000
commitfcf26a43ab1737acc873afcc1b61b4fb20389966 (patch)
tree9215d25bcf79683b9c996941410e2911d06ef3ac /test
parent3b36337be1e165db491bc591ae95be3577886465 (diff)
downloadchrome-ec-fcf26a43ab1737acc873afcc1b61b4fb20389966.tar.gz
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 <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/196385
Diffstat (limited to 'test')
-rw-r--r--test/sbs_charging_v2.c19
1 files changed, 11 insertions, 8 deletions
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, &params,
+ 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, &params,
- sizeof(params), NULL, 0);
-}
-
/* Host Event helpers */
static int ev_is_set(int event)
{