From 990ca7a1bc0428ef2c705a1330ebffb87382d596 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Tue, 2 Feb 2016 13:44:43 -0800 Subject: 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 Change-Id: I239df9793773429e9b84a847e55d6753577fab32 Reviewed-on: https://chromium-review.googlesource.com/325385 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 7 +++++-- 1 file 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); } } -- cgit v1.2.1