twinkie: initialize INAs at startup

Disable INA1 to avoid leaking current from VCONN2.
Put the calibration in INA0.

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

BRANCH=none
BUG=chrome-os-partner:28337
TEST=plug Twinkie and measure VBUS current/voltage.

Change-Id: I6b063460a86a7a3dd87ec5e3c2c9b992b66db146
Reviewed-on: https://chromium-review.googlesource.com/204468
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
This commit is contained in:
Vincent Palatin
2014-06-03 11:35:01 -07:00
committed by chrome-internal-fetch
parent 5fa52a895b
commit b162ac513a
2 changed files with 7 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "ina231.h"
#include "registers.h"
#include "task.h"
#include "util.h"
@@ -83,6 +84,11 @@ static void board_init(void)
/* Enable interrupts for INAs. */
gpio_enable_interrupt(GPIO_CC2_ALERT_L);
gpio_enable_interrupt(GPIO_VBUS_ALERT_L);
/* Calibrate INA0 (VBUS) with 1mA/LSB scale */
ina231_init(0, 0x8000, INA231_CALIB_1MA(15 /*mOhm*/));
/* Disable INA1 (VCONN2) to avoid leaking current */
ina231_init(1, 0, INA231_CALIB_1MA(15 /*mOhm*/));
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);

View File

@@ -141,6 +141,6 @@ static int command_ina(int argc, char **argv)
return EC_ERROR_INVAL;
}
DECLARE_CONSOLE_COMMAND(ina, command_ina,
"[config|calib|mask|alert <val>]",
"<index> [config|calib|mask|alert <val>]",
"INA231 power/current sensing",
NULL);