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

Commit 0efff128 authored by Jack Pham's avatar Jack Pham
Browse files

usb: typec: ucsi: Notify USB role switch only if partner supports USB data



In cases where a port partner does not support USB data, we can avoid
starting the USB controller via usb_role_switch. UCSI should indicate
whether a partner supports USB data or not via the connector status
partner flags field, so check whether the 'USB' bit is set before
calling usb_role_switch_set_role().

Change-Id: Ia78dc9ecb3ff0c349e9debfa8e998c9d350a09ab
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 8c86f959
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -498,6 +498,10 @@ static void ucsi_partner_change(struct ucsi_connector *con)
	if (!completion_done(&con->complete))
		complete(&con->complete);

	/* Only notify USB controller if partner supports USB data */
	if (!(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) & UCSI_CONSTAT_PARTNER_FLAG_USB))
		u_role = USB_ROLE_NONE;

	ret = usb_role_switch_set_role(ucsi->usb_role_sw, u_role);
	if (ret)
		dev_err(ucsi->dev, "%s(): failed to set role(%d):%d\n",
@@ -570,6 +574,11 @@ static void ucsi_handle_connector_change(struct work_struct *work)
		else
			ucsi_unregister_partner(con);

		/* Only notify USB controller if partner supports USB data */
		if (!(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) &
				UCSI_CONSTAT_PARTNER_FLAG_USB))
			u_role = USB_ROLE_NONE;

		ret = usb_role_switch_set_role(ucsi->usb_role_sw, u_role);
		if (ret)
			dev_err(ucsi->dev, "%s(): failed to set role(%d):%d\n",
@@ -883,6 +892,10 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
		ucsi_register_partner(con);
	}

	/* Only notify USB controller if partner supports USB data */
	if (!(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) & UCSI_CONSTAT_PARTNER_FLAG_USB))
		role = USB_ROLE_NONE;

	ret = usb_role_switch_set_role(ucsi->usb_role_sw, role);
	if (ret)
		dev_err(ucsi->dev, "%s(): failed to set role(%d):%d\n",