summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usbc/usb_pe_drp_sm.c19
-rw-r--r--include/usb_pd.h1
2 files changed, 20 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.
diff --git a/include/usb_pd.h b/include/usb_pd.h
index f1171d6583..534e0b7ceb 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -275,6 +275,7 @@ enum pd_rx_errors {
/* Voltage thresholds in mV (Table 7-24, PD 3.0 Version 2.0 Spec) */
#define PD_V_SAFE0V_MAX 800
#define PD_V_SAFE5V_MIN 4750
+#define PD_V_SAFE5V_NOM 5000
#define PD_V_SAFE5V_MAX 5500
/* USB Type-C voltages in mV (Table 4-3, USB Type-C Release 2.0 Spec) */