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

Commit 6b370ce5 authored by Jack Pham's avatar Jack Pham Committed by Hemant Kumar
Browse files

usb: pd: send Not Supported message when operating in 3.0



PD 3.0 requires the Not Supported message to be sent after
receiving a message that is not supported. Add this to both
PE_SNK_READY and PE_SRC_READY states when there is an
unhandled message. If 3.0 sink-only mode is enabled, also
disallow PR_SWAP, VCONN_SWAP, and GET_SOURCE_CAP, so that the
state machine can fall through to responding with Not Supported.

Change-Id: If28bfcb1a483fcdb0c398c66d26fe7b1607b461a
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 2d979e61
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -2025,6 +2025,15 @@ static void usbpd_sm(struct work_struct *w)
			vconn_swap(pd);
		} else if (IS_DATA(rx_msg, MSG_VDM)) {
			handle_vdm_rx(pd, rx_msg);
		} else if (rx_msg && pd->spec_rev == USBPD_REV_30) {
			/* unhandled messages */
			ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0,
					SOP_MSG);
			if (ret) {
				usbpd_err(&pd->dev, "Error sending Not supported\n");
				usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET);
			}
			break;
		} else if (pd->send_pr_swap) {
			pd->send_pr_swap = false;
			ret = pd_send_msg(pd, MSG_PR_SWAP, NULL, 0, SOP_MSG);
@@ -2265,7 +2274,8 @@ static void usbpd_sm(struct work_struct *w)
				usbpd_err(&pd->dev, "Error sending Sink Caps\n");
				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
			}
		} else if (IS_CTRL(rx_msg, MSG_GET_SOURCE_CAP)) {
		} else if (IS_CTRL(rx_msg, MSG_GET_SOURCE_CAP) &&
				pd->spec_rev == USBPD_REV_20) {
			ret = pd_send_msg(pd, MSG_SOURCE_CAPABILITIES,
					default_src_caps,
					ARRAY_SIZE(default_src_caps), SOP_MSG);
@@ -2288,7 +2298,8 @@ static void usbpd_sm(struct work_struct *w)
			}

			dr_swap(pd);
		} else if (IS_CTRL(rx_msg, MSG_PR_SWAP)) {
		} else if (IS_CTRL(rx_msg, MSG_PR_SWAP) &&
				pd->spec_rev == USBPD_REV_20) {
			/* lock in current mode */
			set_power_role(pd, pd->current_pr);

@@ -2306,7 +2317,8 @@ static void usbpd_sm(struct work_struct *w)
					POWER_SUPPLY_PROP_PR_SWAP, &val);
			usbpd_set_state(pd, PE_PRS_SNK_SRC_TRANSITION_TO_OFF);
			break;
		} else if (IS_CTRL(rx_msg, MSG_VCONN_SWAP)) {
		} else if (IS_CTRL(rx_msg, MSG_VCONN_SWAP) &&
				pd->spec_rev == USBPD_REV_20) {
			/*
			 * if VCONN is connected to VBUS, make sure we are
			 * not in high voltage contract, otherwise reject.
@@ -2334,6 +2346,15 @@ static void usbpd_sm(struct work_struct *w)
			vconn_swap(pd);
		} else if (IS_DATA(rx_msg, MSG_VDM)) {
			handle_vdm_rx(pd, rx_msg);
		} else if (rx_msg && pd->spec_rev == USBPD_REV_30) {
			/* unhandled messages */
			ret = pd_send_msg(pd, MSG_NOT_SUPPORTED, NULL, 0,
					SOP_MSG);
			if (ret) {
				usbpd_err(&pd->dev, "Error sending Not supported\n");
				usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET);
			}
			break;
		} else if (pd->send_request) {
			pd->send_request = false;
			usbpd_set_state(pd, PE_SNK_SELECT_CAPABILITY);