summaryrefslogtreecommitdiff
path: root/include/usb_pd_tcpc.h
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-05-08 16:46:03 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-27 02:39:48 +0000
commit111c893524f226435b4c851db8e05d5f16ab4c0e (patch)
tree9442e194d623387113c544694ba9a6bf6b5a2023 /include/usb_pd_tcpc.h
parent5b5f737d8f6f1be15d4ab5f42f290d20576307c4 (diff)
downloadchrome-ec-111c893524f226435b4c851db8e05d5f16ab4c0e.tar.gz
pd: stm32f0: modify i2c driver to support TCPCI
Modify the stm32f0 i2c driver to support the new TCPC interface. BUG=none BRANCH=none TEST=test on oak Change-Id: Ibcb205e67d59d99a97dce090bd84bbb714ad5032 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/270173 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/usb_pd_tcpc.h')
-rw-r--r--include/usb_pd_tcpc.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/usb_pd_tcpc.h b/include/usb_pd_tcpc.h
index b954c6f7ae..0ddeab23d2 100644
--- a/include/usb_pd_tcpc.h
+++ b/include/usb_pd_tcpc.h
@@ -12,6 +12,18 @@
#define CONFIG_TCPC_I2C_BASE_ADDR 0x9c
#endif
+/* If we are a TCPC but do not a TCPM, then we implement the slave TCPCI */
+#if defined(CONFIG_USB_PD_TCPC) && !defined(CONFIG_USB_PD_TCPM_STUB)
+#define TCPCI_I2C_SLAVE
+#endif
+
+#ifdef TCPCI_I2C_SLAVE
+/* Convert TCPC address to type-C port number */
+#define TCPC_ADDR_TO_PORT(addr) (((addr) - CONFIG_TCPC_I2C_BASE_ADDR) >> 1)
+/* Check if the i2c address belongs to TCPC */
+#define ADDR_IS_TCPC(addr) (((addr) & 0xfc) == CONFIG_TCPC_I2C_BASE_ADDR)
+#endif
+
/**
* Process incoming TCPCI I2C command
*