summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-07-24 10:35:34 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-24 21:54:18 +0000
commite85a3fa0d4f8e43d2bbab90aa972bde6f6c64e5c (patch)
treee4777e271974fe821e061f288ef5cce0a636bae0 /driver
parentb339fdf6c11dcc5bb89615ab426a97469362b0a5 (diff)
downloadchrome-ec-e85a3fa0d4f8e43d2bbab90aa972bde6f6c64e5c.tar.gz
tcpc: move tcpc initialized bit into error status register
Move TCPC initialized bit from alert register into error status register. This is not part of the TCPCI spec, but the existing code creates a bug that if TCPM reboots without TCPC also rebooting, then we will never get the initialized alert from TCPC since it has already happened, so the TCPM will loop indefinitely waiting for TCPC to be ready. This fixes the bug by moving the bit to a status register, which is more appropriate. BUG=none BRANCH=none TEST=load on glados, reboot and make sure TCPM see's that the TCPC is initialized. Change-Id: I8e96b59031e01a4faec8f519727df1fa95f498bc Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/288342 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/tcpci.c12
-rw-r--r--driver/tcpm/tcpci.h2
2 files changed, 7 insertions, 7 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index cd5c783db8..8353cb15d9 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -39,17 +39,17 @@ static int init_alert_mask(int port)
int tcpm_init(int port)
{
- int rv, alert = 0;
+ int rv, err = 0;
while (1) {
rv = i2c_read16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port),
- TCPC_REG_ALERT, &alert);
+ TCPC_REG_ERROR_STATUS, &err);
/*
- * If i2c succeeds and VID is non-zero, then initialization
- * is complete
+ * If i2c succeeds and the uninitialized bit is clear, then
+ * initalization is complete, clear all alert bits and write
+ * the initial alert mask.
*/
- if (rv == EC_SUCCESS && (alert & TCPC_REG_ALERT_TCPC_INITED)) {
- /* clear all alert bits */
+ if (rv == EC_SUCCESS && !(err & TCPC_REG_ERROR_STATUS_UNINIT)) {
i2c_write16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port),
TCPC_REG_ALERT, 0xff);
return init_alert_mask(port);
diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h
index a4ee23bc0a..18f9a75e95 100644
--- a/driver/tcpm/tcpci.h
+++ b/driver/tcpm/tcpci.h
@@ -19,7 +19,6 @@
#define TCPC_REG_DEV_CAP_3 0xe
#define TCPC_REG_DEV_CAP_4 0xf
#define TCPC_REG_ALERT 0x10
-#define TCPC_REG_ALERT_TCPC_INITED (1<<14)
#define TCPC_REG_ALERT_INTRFACE_ERR (1<<11)
#define TCPC_REG_ALERT_GPIO_CHANGE (1<<10)
#define TCPC_REG_ALERT_V_ALARM_LO (1<<9)
@@ -47,6 +46,7 @@
#define TCPC_REG_POWER_STATUS 0x19
#define TCPC_REG_ERROR_STATUS 0x1a
+#define TCPC_REG_ERROR_STATUS_UNINIT (1<<7)
#define TCPC_REG_ROLE_CTRL 0x1b
#define TCPC_REG_ROLE_CTRL_SET(drp, rp, cc1, cc2) \
((drp) << 6 | (rp) << 4 | (cc2) << 2 | (cc1))