twinkie: turn on/off VCONN INA

the VCONN INA is off by default to avoid a leakage path on CC2.
Turn it on when asking for a VCONN measurement ("twinkie vconn"),
then off aftwerwards.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=none
TEST=On the Twinkie command-line, "tw vconn" with the Twinkie interposed
between a Samus and a DingDong.

Change-Id: I8cd78b285512644af0824a44c735585b684fee66
Reviewed-on: https://chromium-review.googlesource.com/239212
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2015-01-07 09:26:25 -08:00
committed by ChromeOS Commit Bot
parent 963d4762b2
commit dce1b1e8b1

View File

@@ -427,9 +427,21 @@ static int cmd_rx_threshold(int argc, char **argv)
static int cmd_ina_dump(int argc, char **argv, int index)
{
if (index == 1) { /* VCONN INA is off by default, switch it on */
ina2xx_write(index, INA2XX_REG_CONFIG, 0x4123);
/*
* wait for the end of conversion : 2x 1.1ms as defined
* by the Vb and Vsh CT bits in the CONFIG register above.
*/
udelay(2200);
}
ccprintf("%s = %d mV ; %d mA\n", index == 0 ? "VBUS" : "VCONN",
ina2xx_get_voltage(index), ina2xx_get_current(index));
if (index == 1) /* power off VCONN INA */
ina2xx_write(index, INA2XX_REG_CONFIG, 0);
return EC_SUCCESS;
}