summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-03-04 19:07:23 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-17 19:13:35 +0000
commit6e4f5c6a44df835f3fec7282aad37ac611d3f64b (patch)
tree861bdef2d17da80196e58d5bb64905adbd450439 /common/usbc/usb_pe_drp_sm.c
parent8984434913efaafda4c172c15b98ddd3cb636dd8 (diff)
downloadchrome-ec-6e4f5c6a44df835f3fec7282aad37ac611d3f64b.tar.gz
TCPMv2: Don't enter Tx BIST mode when VBUS > VSafe5V
By spec we are only allowed to enter BIST mode when VBUS is at vSafe5V. This CL adds a check in pe_bist_tx_entry to make sure that BIST test mode is only entered if VBUS is at the correct level. We compared to the expected nominal VBUS level and not the actual measured level as not all boards will have accurate enough VBUS measurements. BUG=b:180957710 BRANCH=None TEST=Verfied that quiche can pass the TDA.2.2.7 compliance test. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: Icc2e5ff6c32374c89490e5bea79af2c4517ea295 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2738397 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usbc/usb_pe_drp_sm.c')
-rw-r--r--common/usbc/usb_pe_drp_sm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 8a62427006..39d390dc86 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -4908,9 +4908,28 @@ static void pe_bist_tx_entry(int port)
{
uint32_t *payload = (uint32_t *)rx_emsg[port].buf;
uint8_t mode = BIST_MODE(payload[0]);
+ int vbus_mv;
+ int ibus_ma;
print_current_state(port);
+ /* Get the current nominal VBUS value */
+ if (pe[port].power_role == PD_ROLE_SOURCE) {
+ const uint32_t *src_pdo;
+
+ dpm_get_source_pdo(&src_pdo, port);
+ pd_extract_pdo_power(src_pdo[pe[port].requested_idx - 1],
+ &ibus_ma, &vbus_mv);
+ } else {
+ vbus_mv = pe[port].supply_voltage;
+ }
+
+ /* If VBUS is not at vSafe5V, then don't enter BIST test mode */
+ if (vbus_mv != PD_V_SAFE5V_NOM) {
+ pe_set_ready_state(port);
+ return;
+ }
+
if (mode == BIST_CARRIER_MODE_2) {
/*
* PE_BIST_Carrier_Mode embedded here.