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

Commit fa06d2c8 authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: Only enable SOP' reception when acting as VCONN source



We only expect to receive SOP' messages if we have enabled
VCONN and are communicating to the cable. Initialize the PD PHY
to enable SOP' reception accordingly during PE_SRC/SNK_Startup
based on whether VCONN is enabled or not.

Change-Id: If08d37a896d706886566ee2d784af50393d9e604
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent eb73bc66
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -1197,7 +1197,6 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
		.msg_rx_cb		= phy_msg_received,
		.shutdown_cb		= phy_shutdown,
		.frame_filter_val	= FRAME_FILTER_EN_SOP |
					  FRAME_FILTER_EN_SOPI |
					  FRAME_FILTER_EN_HARD_RESET,
	};
	union power_supply_propval val = {0};
@@ -1259,6 +1258,10 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
			phy_params.data_role = pd->current_dr;
			phy_params.power_role = pd->current_pr;

			if (pd->vconn_enabled)
				phy_params.frame_filter_val |=
					FRAME_FILTER_EN_SOPI;

			ret = pd_phy_open(&phy_params);
			if (ret) {
				WARN_ON_ONCE(1);
@@ -1446,6 +1449,10 @@ static void usbpd_set_state(struct usbpd *pd, enum usbpd_state next_state)
			phy_params.data_role = pd->current_dr;
			phy_params.power_role = pd->current_pr;

			if (pd->vconn_enabled)
				phy_params.frame_filter_val |=
					FRAME_FILTER_EN_SOPI;

			ret = pd_phy_open(&phy_params);
			if (ret) {
				WARN_ON_ONCE(1);
@@ -2004,6 +2011,9 @@ static void vconn_swap(struct usbpd *pd)
	int ret;

	if (pd->vconn_enabled) {
		pd_phy_update_frame_filter(FRAME_FILTER_EN_SOP |
					   FRAME_FILTER_EN_HARD_RESET);

		pd->current_state = PE_VCS_WAIT_FOR_VCONN;
		kick_sm(pd, VCONN_ON_TIME);
	} else {
@@ -2022,6 +2032,10 @@ static void vconn_swap(struct usbpd *pd)

		pd->vconn_enabled = true;

		pd_phy_update_frame_filter(FRAME_FILTER_EN_SOP |
					   FRAME_FILTER_EN_SOPI |
					   FRAME_FILTER_EN_HARD_RESET);

		/*
		 * Small delay to ensure Vconn has ramped up. This is well
		 * below tVCONNSourceOn (100ms) so we still send PS_RDY within
+8 −0
Original line number Diff line number Diff line
@@ -347,6 +347,14 @@ int pd_phy_update_roles(enum data_role dr, enum power_role pr)
}
EXPORT_SYMBOL(pd_phy_update_roles);

int pd_phy_update_frame_filter(u8 frame_filter_val)
{
	struct usb_pdphy *pdphy = __pdphy;

	return pdphy_reg_write(pdphy, USB_PDPHY_FRAME_FILTER, frame_filter_val);
}
EXPORT_SYMBOL(pd_phy_update_frame_filter);

int pd_phy_open(struct pd_phy_params *params)
{
	int ret;
+6 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ int pd_phy_signal(enum pd_sig_type sig);
int pd_phy_write(u16 hdr, const u8 *data, size_t data_len,
		enum pd_sop_type sop);
int pd_phy_update_roles(enum data_role dr, enum power_role pr);
int pd_phy_update_frame_filter(u8 frame_filter_val);
void pd_phy_close(void);
#else
static inline int pd_phy_open(struct pd_phy_params *params)
@@ -100,6 +101,11 @@ static inline int pd_phy_update_roles(enum data_role dr, enum power_role pr)
	return -ENODEV;
}

static inline int pd_phy_update_frame_filter(u8 frame_filter_val)
{
	return -ENODEV;
}

static inline void pd_phy_close(void)
{
}