summaryrefslogtreecommitdiff
path: root/board/cr50/usb_i2c.c
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2017-02-02 19:42:32 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-06 14:50:31 -0800
commit2e0df8b6c66c2150dbac853a1abe67d41e46acf9 (patch)
tree571e3e40336f50a6e45648d42725a3a15e629691 /board/cr50/usb_i2c.c
parenta3b0d7c8979fab5e3fe7f0151ff5d3e221e6531b (diff)
downloadchrome-ec-2e0df8b6c66c2150dbac853a1abe67d41e46acf9.tar.gz
cr50: Have INAs and I2Cm enabled when rdd is attached
The INAs are only used for development and testing purposes. Therefore, the 3.3V rail to the INAs is off by default and the I2Cm module is not enabled. Enabling INA power and connecting the I2Cm module was done at the beginning of each USB to I2C request. The problem with this approach is that INA measurments didn't always succeed due to not enough time for the INAs to initialize. Rather than add some arbitrary delay, it is better to tie the INAs to when rdd is attached/detached. It is only when rdd is attached that the INAs will be accessed, so there is no need to enable/disable for each individual I2C transaction. This CL ties the enabling/disabling of the INA and I2Cm module to the rdd state. This change makes the previous use of usb_i2c_board_enable() and usb_i2c_board_disable() obslete. BRANCH=none BUG=chrome-os-partner:62375 TEST=manual Connect servo with suzyq connected: sudo servod -p 0x5014 -b eve -c eve_r0_inas.xml Then execute single INA reads dut-control pp3300_dx_edp_mv and verify that it returns meaningful numbers. Without this CL single reads via dut-control would always return 0. Change-Id: I799552bfd0701efd1828a0d720ac2a6cedee5ca1 Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/436864 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'board/cr50/usb_i2c.c')
-rw-r--r--board/cr50/usb_i2c.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/board/cr50/usb_i2c.c b/board/cr50/usb_i2c.c
index 8ba90c5f63..786a886c7f 100644
--- a/board/cr50/usb_i2c.c
+++ b/board/cr50/usb_i2c.c
@@ -35,7 +35,6 @@ static void ina_disconnect(void)
/* Disable power to INA chips */
gpio_set_level(GPIO_EN_PP3300_INA_L, 1);
}
-DECLARE_DEFERRED(ina_disconnect);
static void ina_connect(void)
{
@@ -65,29 +64,24 @@ static void ina_connect(void)
i2cm_init();
}
-void usb_i2c_board_disable(int debounce)
+void usb_i2c_board_disable(void)
{
if (!i2c_enabled())
return;
- /*
- * Wait to disable i2c in case we are doing a bunch of i2c transactions
- * in a row.
- */
- hook_call_deferred(&ina_disconnect_data, debounce ? 1 * SECOND : 0);
+ ina_disconnect();
}
int usb_i2c_board_enable(void)
{
- if (device_get_state(DEVICE_SERVO) != DEVICE_STATE_OFF) {
+ if (device_get_state(DEVICE_SERVO) == DEVICE_STATE_ON) {
CPRINTS("Servo is attached I2C cannot be enabled");
- usb_i2c_board_disable(0);
+ usb_i2c_board_disable();
return EC_ERROR_BUSY;
}
- hook_call_deferred(&ina_disconnect_data, -1);
-
if (!i2c_enabled())
ina_connect();
+
return EC_SUCCESS;
}