summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-03-13 22:02:22 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-24 19:27:56 +0000
commit2b86994b8368c36a54d32f36984b2ae9a2997295 (patch)
tree4e0f38dd6ada8349b23b0df9b6a6530356c3d74d /common
parent0252cc3de4092702043b367ace18dfc97f3327aa (diff)
downloadchrome-ec-2b86994b8368c36a54d32f36984b2ae9a2997295.tar.gz
TCPMv2: Not enable PD comm on TX Phy reset if not in a connected state
If PD is not in a connected state, the previous approach was to enable PD comm on TX Phy reset and then disable it later (the SM_RUN case in prl_run()). In this short period of time, the TCPC wil respond GoodCRC to the PD message and the PD partner will go forward to the next state that messes up its state machine and causes an unexpected hard reset. We should not enable PD comm if not in a connected state. BRANCH=None BUG=b:151159750 TEST=Tested on Trogdor, with extra patches to fix the DP discovery and separate the Tx and Rx buffers. Unplugged battery and plugged a 20V charger and verified it boot fine, no reboot loop. TEST=Built chocodile_vpdmcu image successfully. TEST=make runtests -j Change-Id: Ic819787f1ec0085abdded3bab8ecbcb813495408 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2107882 Reviewed-by: Sam Hurst <shurst@google.com>
Diffstat (limited to 'common')
-rw-r--r--common/usbc/usb_prl_sm.c4
-rw-r--r--common/usbc/usb_tc_ctvpd_sm.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index 5805d1278e..769a103fe5 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -467,10 +467,10 @@ static void prl_tx_phy_layer_reset_entry(const int port)
{
if (IS_ENABLED(CONFIG_USB_TYPEC_CTVPD)
|| IS_ENABLED(CONFIG_USB_TYPEC_VPD)) {
- vpd_rx_enable(1);
+ vpd_rx_enable(pd_is_connected(port));
} else {
tcpm_clear_pending_messages(port);
- tcpm_set_rx_enable(port, 1);
+ tcpm_set_rx_enable(port, pd_is_connected(port));
}
}
diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c
index 194bb664fe..804c733485 100644
--- a/common/usbc/usb_tc_ctvpd_sm.c
+++ b/common/usbc/usb_tc_ctvpd_sm.c
@@ -222,6 +222,17 @@ test_mockable_static void print_current_state(const int port)
CPRINTS("C%d: %s", port, tc_state_names[get_state_tc(port)]);
}
+int pd_is_connected(int port)
+{
+ return (get_state_tc(port) == TC_ATTACHED_SNK) ||
+ (get_state_tc(port) == TC_ATTACHED_SRC);
+}
+
+bool pd_is_disconnected(int port)
+{
+ return !pd_is_connected(port);
+}
+
/**
* Disabled
*