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>
This commit is contained in:
Shawn Nematbakhsh
2016-02-02 13:44:43 -08:00
committed by chrome-bot
parent 9abc13d25a
commit 990ca7a1bc

View File

@@ -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);
}
}