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

Commit 92f6a823 authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: update PHY roles immediately after DR_Swap



In case of DR_Swap, update the PHY DR role immediately after
accepting the request (or receiving an accept from the peer)
so as to have the correct roles sent out by the Auto-GoodCRC
mechanism. This is in case another message is received while
still busy handling the extcon notifications to stop/start
the host/peripheral stack.

Change-Id: I93197583a88c9ad0c291e3756f96c4858f591392
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent bd6ea954
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -1775,15 +1775,19 @@ static void dr_swap(struct usbpd *pd)
	usbpd_dbg(&pd->dev, "%s: current_dr(%d)\n", __func__, pd->current_dr);

	if (pd->current_dr == DR_DFP) {
		pd->current_dr = DR_UFP;
		pd_phy_update_roles(pd->current_dr, pd->current_pr);

		stop_usb_host(pd);
		if (pd->peer_usb_comm)
			start_usb_peripheral(pd);
		pd->current_dr = DR_UFP;
	} else if (pd->current_dr == DR_UFP) {
		pd->current_dr = DR_DFP;
		pd_phy_update_roles(pd->current_dr, pd->current_pr);

		stop_usb_peripheral(pd);
		if (pd->peer_usb_comm)
			start_usb_host(pd, true);
		pd->current_dr = DR_DFP;

		/* ensure host is started before allowing DP */
		extcon_blocking_sync(pd->extcon, EXTCON_USB_HOST, 0);
@@ -1792,7 +1796,6 @@ static void dr_swap(struct usbpd *pd)
				SVDM_CMD_TYPE_INITIATOR, 0, NULL, 0);
	}

	pd_phy_update_roles(pd->current_dr, pd->current_pr);
	dual_role_instance_changed(pd->dual_role);
}