summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-02-02 13:44:43 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-02-02 23:48:04 -0800
commit990ca7a1bc0428ef2c705a1330ebffb87382d596 (patch)
tree4832bdf6245b25a7cc7906e829dedd62985f552f
parent9abc13d25a583b80fb9f54c8d157dddfdb242659 (diff)
downloadchrome-ec-990ca7a1bc0428ef2c705a1330ebffb87382d596.tar.gz
pd: Reinitialize state variables on TCPC reset
Resetting our state to default without also resetting the power role may lead to a state / role mismatch. BUG=chrome-os-partner:49563 TEST=Verify kunimitsu correctly detects charger at either polarity on sysjump. BRANCH=glados Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I239df9793773429e9b84a847e55d6753577fab32 Reviewed-on: https://chromium-review.googlesource.com/325385 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/usb_pd_protocol.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index b40ed0e98f..ccd55a8078 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1468,18 +1468,21 @@ void pd_task(void)
* Otherwise, go to the default disconnected state
* and force renegotiation.
*/
- if (
+ if (pd[port].vdm_state == VDM_STATE_DONE && (
#ifdef CONFIG_USB_PD_DUAL_ROLE
(PD_ROLE_DEFAULT == PD_ROLE_SINK &&
pd[port].task_state == PD_STATE_SNK_READY) ||
#endif
(PD_ROLE_DEFAULT == PD_ROLE_SOURCE &&
- pd[port].task_state == PD_STATE_SRC_READY)) {
+ pd[port].task_state == PD_STATE_SRC_READY))) {
tcpm_set_polarity(port, pd[port].polarity);
tcpm_set_msg_header(port, pd[port].power_role,
pd[port].data_role);
tcpm_set_rx_enable(port, 1);
} else {
+ /* Ensure state variables are at default */
+ pd[port].power_role = PD_ROLE_DEFAULT;
+ pd[port].vdm_state = VDM_STATE_DONE;
set_state(port, PD_DEFAULT_STATE);
}
}