From b162ac513aa801b53d17a53591b73a303c675bdc Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Tue, 3 Jun 2014 11:35:01 -0700 Subject: twinkie: initialize INAs at startup Disable INA1 to avoid leaking current from VCONN2. Put the calibration in INA0. Signed-off-by: Vincent Palatin 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 Tested-by: Vincent Palatin Reviewed-by: Todd Broch --- board/twinkie/board.c | 6 ++++++ driver/ina231.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/board/twinkie/board.c b/board/twinkie/board.c index 22ad27ad38..5a5ad855f3 100644 --- a/board/twinkie/board.c +++ b/board/twinkie/board.c @@ -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); diff --git a/driver/ina231.c b/driver/ina231.c index 73f03910e2..8736e916e9 100644 --- a/driver/ina231.c +++ b/driver/ina231.c @@ -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 ]", + " [config|calib|mask|alert ]", "INA231 power/current sensing", NULL); -- cgit v1.2.1