summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Herrmann <eherrmann@chromium.org>2020-08-03 15:46:58 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-09 22:59:52 +0000
commit036b58da6630b42470b2f07d286c821670358482 (patch)
tree01da0d67fa64003f7ca6dc8182227cdbda988932
parent0cd34573caa2b786bfe3528231c3206a00f3c9cf (diff)
downloadchrome-ec-036b58da6630b42470b2f07d286c821670358482.tar.gz
Volteer: Add support for RT1715
Add support for replacing the TUSB422 with the RT1715. Since they are pin-to-pin compatible and currently only used with a rework, make the decision of which to use at runtime. The logic is to check if the RT1715 is both on the I2C bus and the vendor ID matches. If either fail, default to the TUSB422 address and driver. BUG=b:162617664 TEST=make buildall TEST=check both TUSB422 functionality and RT1715 functionality BRANCH=none Change-Id: I8306f086bf030ddd7238532b1f12aa259cb72422 Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2343734 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--baseboard/volteer/baseboard.h1
-rw-r--r--board/volteer/board.c31
-rw-r--r--driver/tcpm/rt1715.h2
3 files changed, 33 insertions, 1 deletions
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index 073304ae39..024b1d521b 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -159,6 +159,7 @@
#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPM_TCPCI
+#define CONFIG_USB_PD_TCPM_RT1715
#define CONFIG_USB_PD_TCPM_TUSB422 /* USBC port C0 */
#define CONFIG_USB_PD_TCPM_PS8815 /* USBC port USB3 DB */
#define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID
diff --git a/board/volteer/board.c b/board/volteer/board.c
index 9a06e8bddd..2aef1e914b 100644
--- a/board/volteer/board.c
+++ b/board/volteer/board.c
@@ -18,6 +18,7 @@
#include "driver/retimer/bb_retimer.h"
#include "driver/sync.h"
#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/rt1715.h"
#include "driver/tcpm/tcpci.h"
#include "driver/tcpm/tusb422.h"
#include "extpower.h"
@@ -374,6 +375,31 @@ static void config_db_usb3_passive(void)
usb_muxes[USBC_PORT_C1] = mux_config_p1_usb3_passive;
}
+static void config_port_discrete_tcpc(int port)
+{
+ /*
+ * Support 2 Pin-to-Pin compatible parts: TUSB422 and RT1715, for
+ * simplicity allow either and decide at runtime which we are using.
+ * Default to TUSB422, and switch to RT1715 if it is on the I2C bus and
+ * the VID matches.
+ */
+
+ int regval;
+
+ if (i2c_read16(port ? I2C_PORT_USB_C1 : I2C_PORT_USB_C0,
+ RT1715_I2C_ADDR_FLAGS, TCPC_REG_VENDOR_ID,
+ &regval) == EC_SUCCESS) {
+ if (regval == RT1715_VENDOR_ID) {
+ CPRINTS("C%d: RT1715 detected", port);
+ tcpc_config[port].i2c_info.addr_flags =
+ RT1715_I2C_ADDR_FLAGS;
+ tcpc_config[port].drv = &rt1715_tcpm_drv;
+ return;
+ }
+ }
+ CPRINTS("C%d: Default to TUSB422", port);
+}
+
static const char *db_type_prefix = "USB DB type: ";
__override void board_cbi_init(void)
{
@@ -389,15 +415,17 @@ __override void board_cbi_init(void)
GPIO_USB_C1_RT_RST_ODL_BOARDID_0;
ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_ODL_BOARDID_0;
}
-
+ config_port_discrete_tcpc(0);
switch (usb_db) {
case DB_USB_ABSENT:
CPRINTS("%sNone", db_type_prefix);
break;
case DB_USB4_GEN2:
+ config_port_discrete_tcpc(1);
CPRINTS("%sUSB4 Gen1/2", db_type_prefix);
break;
case DB_USB4_GEN3:
+ config_port_discrete_tcpc(1);
CPRINTS("%sUSB4 Gen3", db_type_prefix);
break;
case DB_USB3_ACTIVE:
@@ -406,6 +434,7 @@ __override void board_cbi_init(void)
break;
case DB_USB3_PASSIVE:
config_db_usb3_passive();
+ config_port_discrete_tcpc(1);
CPRINTS("%sUSB3 Passive", db_type_prefix);
break;
default:
diff --git a/driver/tcpm/rt1715.h b/driver/tcpm/rt1715.h
index aff3bc3ba6..f9d2395446 100644
--- a/driver/tcpm/rt1715.h
+++ b/driver/tcpm/rt1715.h
@@ -11,6 +11,8 @@
/* I2C interface */
#define RT1715_I2C_ADDR_FLAGS 0x4E
+#define RT1715_VENDOR_ID 0x29CF
+
#define RT1715_REG_VENDOR_5 0x9B
#define RT1715_REG_VENDOR_5_SHUTDOWN_OFF BIT(5)
#define RT1715_REG_VENDOR_5_ENEXTMSG BIT(4)