Commit 670160fe authored by Prashant Malani's avatar Prashant Malani Committed by Enric Balletbo i Serra
Browse files

platform/chrome: cros_ec_typec: Track port role



Stash the currently reported port role in the port struct and add a
check for that too while determining whether to re-configure on-board
Type C switches (this deals with cases like role swaps where the mux
flags don't change, but the port role does).

Signed-off-by: default avatarPrashant Malani <pmalani@chromium.org>
Suggested-by: default avatarNikunj A. Dadhania <nikunj.dadhania@intel.com>
Tested-by: default avatarDeepti Deshatty <deepti.deshatty@intel.com>
Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
Link: https://lore.kernel.org/r/20210420171008.3829549-1-pmalani@chromium.org
parent c6e939c6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ struct cros_typec_port {
	/* Variables keeping track of switch state. */
	struct typec_mux_state state;
	uint8_t mux_flags;
	uint8_t role;

	/* Port alt modes. */
	struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX];
@@ -995,10 +996,12 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
	}

	/* No change needs to be made, let's exit early. */
	if (typec->ports[port_num]->mux_flags == mux_resp.flags)
	if (typec->ports[port_num]->mux_flags == mux_resp.flags &&
	    typec->ports[port_num]->role == resp.role)
		return 0;

	typec->ports[port_num]->mux_flags = mux_resp.flags;
	typec->ports[port_num]->role = resp.role;
	ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp);
	if (ret)
		dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret);