usb: pd: force disconnect upon unexpected SRC->SNK transition

While in Source mode, a notification that a source is attached
is unexpected. In this case, force a disconnect in order to
clean up state and turn off VBUS and Vconn.

Change-Id: Ie576feeb7622376e8cb0dd8454b626b3b24b190b
Signed-off-by: Jack Pham <jackp@codeaurora.org>
This commit is contained in:
Jack Pham 2017-07-24 10:05:05 -07:00 committed by Gerrit - the friendly Code Review server
parent 3b399a415c
commit 4a32817fda

View file

@ -2479,6 +2479,16 @@ static int psy_changed(struct notifier_block *nb, unsigned long evt, void *ptr)
if (pd->current_pr == PR_SINK) if (pd->current_pr == PR_SINK)
return 0; return 0;
/*
* Unexpected if not in PR swap; need to force disconnect from
* source so we can turn off VBUS, Vconn, PD PHY etc.
*/
if (pd->current_pr == PR_SRC) {
usbpd_info(&pd->dev, "Forcing disconnect from source mode\n");
pd->current_pr = PR_NONE;
break;
}
pd->current_pr = PR_SINK; pd->current_pr = PR_SINK;
break; break;