Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a32817f authored by Jack Pham's avatar Jack Pham Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarJack Pham <jackp@codeaurora.org>
parent 3b399a41
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2479,6 +2479,16 @@ static int psy_changed(struct notifier_block *nb, unsigned long evt, void *ptr)
		if (pd->current_pr == PR_SINK)
			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;
		break;