summaryrefslogtreecommitdiff
path: root/driver/tcpm/tcpci.c
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-06-12 16:08:03 -0600
committerCommit Bot <commit-bot@chromium.org>2020-06-13 02:02:26 +0000
commite315e561f9047481ca4f776de90130182fc23311 (patch)
treecebdef56d0700a0a6a5fb5fe9faf7db1f2e01142 /driver/tcpm/tcpci.c
parent9f1e60d0d7b1c1b680144cd0e7345df64b4a9202 (diff)
downloadchrome-ec-e315e561f9047481ca4f776de90130182fc23311.tar.gz
tcpci: Add workaround for devices with broken vSafe0V
Add a flag to override checking the vSafe0V bit directly if this capability is not functional on a TCPC revision 2.0 device. BUG=b:158520242 BRANCH=none TEST=make buildall TEST=Volteer, confirm that SNK devices can be detected with TCPMv2 stack. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ia6f3a28970f240fb022cbef9d286761266224f6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2244017 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'driver/tcpm/tcpci.c')
-rw-r--r--driver/tcpm/tcpci.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index d165a92487..a510a440a3 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -30,6 +30,10 @@ static int vconn_en[CONFIG_USB_PD_PORT_MAX_COUNT];
static int rx_en[CONFIG_USB_PD_PORT_MAX_COUNT];
#endif
+#define TCPC_FLAGS_VSAFE0V(_flags) \
+ ((_flags & TCPC_FLAGS_TCPCI_REV2_0) && \
+ !(_flags & TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V))
+
/****************************************************************************
* TCPCI DEBUG Helpers
*/
@@ -294,7 +298,7 @@ static int init_alert_mask(int port)
;
/* TCPCI Rev2 includes SAFE0V alerts */
- if (tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0)
+ if (TCPC_FLAGS_VSAFE0V(tcpc_config[port].flags))
mask |= TCPC_REG_ALERT_EXT_STATUS;
/* Set the alert mask in TCPC */
@@ -743,7 +747,7 @@ bool tcpci_tcpm_check_vbus_level(int port, enum vbus_level level)
* to poll when requesting to see if we left it and
* have not yet entered Safe5V
*/
- if ((tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0) &&
+ if (TCPC_FLAGS_VSAFE0V(tcpc_config[port].flags) &&
(tcpc_vbus[port] & BIT(VBUS_SAFE0V))) {
int ext_status = 0;
@@ -1104,7 +1108,7 @@ static void tcpci_check_vbus_changed(int port, int alert, uint32_t *pd_event)
* Check for VBus change
*/
/* TCPCI Rev2 includes Safe0V detection */
- if ((tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0) &&
+ if (TCPC_FLAGS_VSAFE0V(tcpc_config[port].flags) &&
(alert & TCPC_REG_ALERT_EXT_STATUS)) {
int ext_status = 0;
@@ -1130,7 +1134,7 @@ static void tcpci_check_vbus_changed(int port, int alert, uint32_t *pd_event)
if (pwr_status & TCPC_REG_POWER_STATUS_VBUS_PRES)
/* Safe5V and not Safe0V */
tcpc_vbus[port] = BIT(VBUS_PRESENT);
- else if (tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0)
+ else if (TCPC_FLAGS_VSAFE0V(tcpc_config[port].flags))
/* TCPCI Rev2 detects Safe0V, so just clear Safe5V */
tcpc_vbus[port] &= ~BIT(VBUS_PRESENT);
else {
@@ -1425,7 +1429,7 @@ int tcpci_tcpm_init(int port)
/* Initialize power_status_mask */
init_power_status_mask(port);
- if (tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0) {
+ if (TCPC_FLAGS_VSAFE0V(tcpc_config[port].flags)) {
int ext_status = 0;
/* Read Extended Status register */