[PATCH v1 1/1] platform/chrome: cros_ec_typec: Re-register cable on late SOP' discovery
From: Shiva kumar Martalu Gachanti
Date: Fri Dec 04 2026 - 04:39:19 EST
When the EC negotiates with docks that trigger repeated VCONN swaps
(such as in DRP Try.SRC mode), SOP' cable discovery can be delayed.
Currently, cros_ec_typec registers the cable sysfs object early with
blank (0x0) identity VDOs and marks sop_prime_disc_done = true.
Subsequent SOP' discovery notifications are then ignored, leaving the
cable identity VDOs blank and core cable descriptor properties (active,
pd_revision, and plug type) stale.
Update cros_typec_handle_status() and cros_typec_handle_sop_prime_disc()
to re-evaluate SOP' discovery when a placeholder cable with zero
id_header is present:
1. Allow cros_typec_handle_status() to re-invoke SOP' discovery if the
registered cable still has a zero id_header.
2. Keep the existing placeholder cable if valid identity VDOs are still
unavailable on a subsequent check.
3. Once valid SOP' identity VDOs arrive, tear down the placeholder cable
(along with its plug and altmodes) via cros_typec_remove_cable()
before parsing the new identity and re-registering the cable cleanly.
Signed-off-by: Shiva kumar Martalu Gachanti <shivakumarmar@xxxxxxxxxxxx>
---
drivers/platform/chrome/cros_ec_typec.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index c7781aea0b88b..8cfce61965674 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -859,6 +859,22 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p
goto sop_prime_disc_exit;
}
+ /*
+ * If a placeholder cable was registered earlier with zero identity
+ * (e.g. when SOP' discovery was delayed by VCONN swaps), keep it if
+ * valid VDOs are still unavailable; otherwise tear it down before
+ * parsing the new identity so it can be re-registered cleanly.
+ */
+ if (port->cable) {
+ if (disc->identity_count == 0 || disc->discovery_vdo[0] == 0)
+ return 0;
+
+ dev_dbg(typec->dev,
+ "Port %d: Re-registering cable with valid identity (0x%08x)\n",
+ port_num, disc->discovery_vdo[0]);
+ cros_typec_remove_cable(typec, port_num);
+ }
+
/* Parse the PD identity data, even if only 0s were returned. */
cros_typec_parse_pd_identity(&port->c_identity, disc);
@@ -1064,7 +1080,9 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num
}
if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE &&
- !typec->ports[port_num]->sop_prime_disc_done) {
+ (!typec->ports[port_num]->sop_prime_disc_done ||
+ (typec->ports[port_num]->cable &&
+ typec->ports[port_num]->c_identity.id_header == 0))) {
u16 sop_prime_revision;
/* Convert BCD to the format preferred by the TypeC framework */
--
2.56.1.915.g69d5ec7298-goog