summaryrefslogtreecommitdiff
path: root/common/usb_pd_tcpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/usb_pd_tcpm.c')
-rw-r--r--common/usb_pd_tcpm.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/usb_pd_tcpm.c b/common/usb_pd_tcpm.c
index d24931e692..d7458fabfe 100644
--- a/common/usb_pd_tcpm.c
+++ b/common/usb_pd_tcpm.c
@@ -6,6 +6,7 @@
/* Type-C port manager */
#include "i2c.h"
+#include "timer.h"
#include "usb_pd.h"
#include "usb_pd_tcpc.h"
#include "usb_pd_tcpm.h"
@@ -19,6 +20,23 @@
static int tcpc_polarity, tcpc_vconn;
+int tcpm_init(int port)
+{
+ int rv, vid = 0;
+
+ while (1) {
+ rv = i2c_read16(I2C_PORT_TCPC, I2C_ADDR_TCPC(port),
+ TCPC_REG_VENDOR_ID, &vid);
+ /*
+ * If i2c succeeds and VID is non-zero, then initialization
+ * is complete
+ */
+ if (rv == EC_SUCCESS && vid)
+ return rv;
+ msleep(10);
+ }
+}
+
int tcpm_get_cc(int port, int *cc1, int *cc2)
{
int status;