summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@google.com>2020-04-07 15:39:11 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-09 00:01:20 +0000
commit9c87cc0a1a83c65939704fb933e737269cf6455d (patch)
tree3c2c9a5d8c689e4953b916876eace09819797779
parentdc33c3e091aadd13928109936242cf7f81db61f2 (diff)
downloadchrome-ec-9c87cc0a1a83c65939704fb933e737269cf6455d.tar.gz
Add a sw flag to indicate usb_i2c status
Cr50 used to read GPIO_EN_PP3300_INA_L value to detect if USB_I2C is enabled. However it requires an external pullup. Instead, this patch adds a sw flag to indicate USB_I2C status, so that it can keep USB_I2C status regardless external HW factors. BUG=b:152946978 TEST=ran flash_ec on waddledee, ampton, and dragonegg. Signed-off-by: Namyoon Woo <namyoon@chromium.org> Change-Id: Ie1a3a8c790e9643a3b49b6c519167ee3bdecc650 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2140535 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--board/cr50/usb_i2c.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/board/cr50/usb_i2c.c b/board/cr50/usb_i2c.c
index 0bc7408329..64f9cdeaaa 100644
--- a/board/cr50/usb_i2c.c
+++ b/board/cr50/usb_i2c.c
@@ -11,25 +11,22 @@
#include "i2c.h"
#include "rdd.h"
#include "registers.h"
+#include "stdbool.h"
#include "system.h"
#include "timer.h"
#include "usb_i2c.h"
#define CPRINTS(format, args...) cprints(CC_USB, format, ## args)
+static bool usb_i2c_enabled;
+
int usb_i2c_board_is_enabled(void)
{
/* board options use the INA pins as GPIOs */
if (!board_has_ina_support())
return 0;
- /*
- * Note that this signal requires an external pullup, because this is
- * one of the real open drain pins; we cannot pull it up or drive it
- * high. On test boards without the pullup, this will mis-detect as
- * enabled.
- */
- return !gpio_get_level(GPIO_EN_PP3300_INA_L);
+ return usb_i2c_enabled;
}
static void ina_disconnect(void)
@@ -45,6 +42,7 @@ static void ina_disconnect(void)
/* Disable power to INA chips */
gpio_set_level(GPIO_EN_PP3300_INA_L, 1);
+ usb_i2c_enabled = false;
}
static void ina_connect(void)
@@ -71,6 +69,7 @@ static void ina_connect(void)
* lines are connected.
*/
i2cm_init();
+ usb_i2c_enabled = true;
}
void usb_i2c_board_disable(void)