summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2018-08-15 15:41:49 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-09-07 18:36:38 -0700
commit37809307f7b3422d8488feb0c4806615e6af72af (patch)
treee030b1c00bdd81bacd3e088fe69386b9c8af7534
parenta530eb162a6aab5db3dee940ba2718e5a1924f8a (diff)
downloadchrome-ec-37809307f7b3422d8488feb0c4806615e6af72af.tar.gz
tcpc: Add driver for TI TUSB422 tcpc
Initial driver for TUSB422 TCPC which is a tcpci compliant TCPC. This TCPC does not inlude a Type C mux and uses the tcpci driver for all of the methods. BUG=b:111281797 BRANCH=none TEST=Verified operation as sink on DragonEgg. Have not verified source operation, or low power/auto-toggle modes as those config options can't be enabled on ITE at this point. Change-Id: I783a5e2c4a13bc0b8fa4da4b134588382542024c Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1178994 Commit-Ready: Jett Rink <jettrink@chromium.org> Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--driver/build.mk1
-rw-r--r--driver/tcpm/tusb422.c66
-rw-r--r--driver/tcpm/tusb422.h16
-rw-r--r--include/config.h1
4 files changed, 84 insertions, 0 deletions
diff --git a/driver/build.mk b/driver/build.mk
index f95d80748d..74bf4c573a 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -113,6 +113,7 @@ driver-$(CONFIG_USB_PD_TCPM_ANX7688)+=tcpm/anx7688.o
driver-$(CONFIG_USB_PD_TCPM_ANX7447)+=tcpm/anx7447.o
driver-$(CONFIG_USB_PD_TCPM_PS8751)+=tcpm/ps8xxx.o
driver-$(CONFIG_USB_PD_TCPM_PS8805)+=tcpm/ps8xxx.o
+driver-$(CONFIG_USB_PD_TCPM_TUSB422)+=tcpm/tusb422.o
# USB mux high-level driver
driver-$(CONFIG_USBC_SS_MUX)+=usb_mux.o
diff --git a/driver/tcpm/tusb422.c b/driver/tcpm/tusb422.c
new file mode 100644
index 0000000000..0e6a6c51d5
--- /dev/null
+++ b/driver/tcpm/tusb422.c
@@ -0,0 +1,66 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Type-C port manager for TI TUSB422 Port Controller */
+
+#include "common.h"
+#include "tusb422.h"
+#include "tcpci.h"
+#include "tcpm.h"
+#include "timer.h"
+#include "usb_pd.h"
+
+#ifndef CONFIG_USB_PD_TCPM_TCPCI
+#error "TUSB422 is using a standard TCPCI interface"
+#error "Please upgrade your board configuration"
+
+#endif
+
+int tusb422_tcpci_tcpn_init(int port)
+{
+ int rv = tcpci_tcpm_init(port);
+
+ if (rv)
+ return rv;
+
+ /*
+ * VBUS detection is supposed to be enabled by default, however the
+ * TUSB422 has this disabled following reset.
+ */
+ /* Enable VBUS detection */
+ return tcpc_write16(port, TCPC_REG_COMMAND, 0x33);
+}
+
+const struct tcpm_drv tusb422_tcpm_drv = {
+ .init = &tusb422_tcpci_tcpn_init,
+ .release = &tcpci_tcpm_release,
+ .get_cc = &tcpci_tcpm_get_cc,
+#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
+ .get_vbus_level = &tcpci_tcpm_get_vbus_level,
+#endif
+ .select_rp_value = &tcpci_tcpm_select_rp_value,
+ .set_cc = &tcpci_tcpm_set_cc,
+ .set_polarity = &tcpci_tcpm_set_polarity,
+ .set_vconn = &tcpci_tcpm_set_vconn,
+ .set_msg_header = &tcpci_tcpm_set_msg_header,
+ .set_rx_enable = &tcpci_tcpm_set_rx_enable,
+ .get_message_raw = &tcpci_tcpm_get_message_raw,
+ .transmit = &tcpci_tcpm_transmit,
+ .tcpc_alert = &tcpci_tcpc_alert,
+#ifdef CONFIG_USB_PD_DISCHARGE_TCPC
+ .tcpc_discharge_vbus = &tcpci_tcpc_discharge_vbus,
+#endif
+#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
+ .drp_toggle = &tcpci_tcpc_drp_toggle,
+#endif
+#ifdef CONFIG_USBC_PPC
+ .set_snk_ctrl = &tcpci_tcpm_set_snk_ctrl,
+ .set_src_ctrl = &tcpci_tcpm_set_src_ctrl,
+#endif
+ .get_chip_info = &tcpci_get_chip_info,
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ .enter_low_power_mode = &tcpci_enter_low_power_mode,
+#endif
+};
diff --git a/driver/tcpm/tusb422.h b/driver/tcpm/tusb422.h
new file mode 100644
index 0000000000..2a01eb4725
--- /dev/null
+++ b/driver/tcpm/tusb422.h
@@ -0,0 +1,16 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* TI TUSB422 Type-C port controller */
+
+#ifndef __CROS_EC_USB_PD_TCPM_TUSB422_H
+#define __CROS_EC_USB_PD_TCPM_TUSB422_H
+
+/* I2C interface */
+#define TUSB422_I2C_ADDR 0x40
+
+extern const struct tcpm_drv tusb422_tcpm_drv;
+
+#endif /* defined(__CROS_EC_USB_PD_TCPM_TUSB422_H) */
diff --git a/include/config.h b/include/config.h
index 429339654a..82ba112171 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3190,6 +3190,7 @@
#undef CONFIG_USB_PD_TCPM_PS8751
#undef CONFIG_USB_PD_TCPM_PS8805
#undef CONFIG_USB_PD_TCPM_MT6370
+#undef CONFIG_USB_PD_TCPM_TUSB422
/*
* Adds an EC console command to erase the ANX7447 OCM flash.