Skip to contentSkip to conversation

platform/chrome: cros_ec_typec: Track port role

PATCH Applied Prashant Malani 2 participants 2 messages Apr 20, 2021 – Apr 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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).

---
 drivers/platform/chrome/cros_ec_typec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_ec_typec.c +4 -1
index d3df1717a5fd..1a06b8c80f80 100644
@@ -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);
Signature · 1 line
2.31.1.368.gbe11c130af-goog
#1 lore raw
Quoted 4 lines · Prashant Malani

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).

Applied, thanks!

[1/1] platform/chrome: cros_ec_typec: Track port role

      commit: 670160fea22c587b384d56698bbb661fa4801534

Best regards,

Signature · 1 line
Enric Balletbo i Serra <[email protected]>