usb: typec: tcpm: restart DRP toggling on Ra/Open in TOGGLING
Subsystems (3)
PATCH v2 1/1 usb: typec: tcpm: restart DRP toggling on Ra/Open in TOGGLING
When a DRP port using a TCPCI controller such as RT1711H/RT1715 or its ETEK ET7303/ET7304 compatible silicon is connected via an e-marked USB-C cable (for example to a USB-C PD charger whose own port is temporarily open), the TCPC can stop DRP toggling during its Rp phase upon detecting a single Ra pull-down, reporting CC_STATUS with LOOKING4CONNECTION=0, CONNECTRESULT=0 (Rp), and (Ra, Open) or (Open, Ra).
In _tcpm_cc_change(), case TOGGLING only transitions out of TOGGLING for source (Rd), sink (Rp), audio accessory (Ra+Ra), and debug accessory (Rd+Rd / Rp+Rp) states. (Ra, Open) and (Open, Ra) fall through with no state change and no call to tcpm_start_toggling(). Because the TCPC has already exited hardware toggling, the port remains stuck presenting static Rp: PD chargers never see Rd and never source VBUS, and subsequent USB host connections fail to enumerate until another TCPC_CMD_LOOK4CONNECTION command is issued. (fusb302 already avoids this internally by restarting toggling in fusb302_handle_togdone_src() on unexpected CC states.)
In _tcpm_cc_change(), under port->lock, when port->state is TOGGLING on a TYPEC_PORT_DRP port and the reported CC state is (Ra, Open) or (Open, Ra), restart DRP toggling starting in Rd via tcpm_start_toggling(port, TYPEC_CC_RD). Starting the next cycle in Rd lets an attached PD source detect Rd and apply VBUS instead of immediately re-triggering Rp+Ra. If tcpm_start_toggling() fails (for example on a transient bus error), fall back to SNK_UNATTACHED so the state machine does not remain stuck in TOGGLING with hardware toggling stopped.
Per TCPCI Rev 2.0 Table 4-15, while LOOKING4CONNECTION=1 the CC1/CC2 fields report Open/Open (00b), never Ra, so (Ra, Open) and (Open, Ra) cannot false-trigger while a TCPCI controller is still toggling.
The wedged (Ra, Open) failure mode was observed on an MT6789 smartphone using an ETEK ET7303 TCPC (RT1711H/RT1715 compatible) with Anker and Apple USB-C PD chargers over e-marked C-to-C cables.
---
Changes in v2:
- Move recovery from rt1711h_irq() in tcpci_rt1711h.c into _tcpm_cc_change() case TOGGLING in tcpm.c, serializing all TCPC writes under port->lock via tcpm_start_toggling(port, TYPEC_CC_RD).
- Fall back to SNK_UNATTACHED if tcpm_start_toggling() fails.
- Update Fixes tag to f0690a25a140 and add [email protected] to Cc (per Heikki Krogerus).
v1 (withdrawn):
https://lore.kernel.org/r/[email protected]
Testing note:
- Regression-tested on an MT6789 smartphone with ETEK ET7303/RT1715 (tcpci_rt1711h without driver-local recovery) across 10 USB-C PD/PPS, Type-C, and USB host attach/detach cycles in both orientations with no regressions.
- The wedged CC_STATUS=0x01 (LOOKING4CONNECTION=0, Rp, Ra/Open) failure mode was directly captured in ET7303 I2C registers on the same board.
Found and drafted with an AI coding assistant.
drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +8 -0
@@ -6624,6 +6624,14 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,tcpm_set_state (port,SRC_ATTACH_WAIT ,0 ); else if (tcpm_port_is_debug_sink(port) || tcpm_port_is_sink(port)) tcpm_set_state(port, SNK_ATTACH_WAIT, 0); + else if (port->port_type == TYPEC_PORT_DRP && + ((port->cc1 == TYPEC_CC_RA && + port->cc2 == TYPEC_CC_OPEN) || + (port->cc1 == TYPEC_CC_OPEN && + port->cc2 == TYPEC_CC_RA))) { +if (!tcpm_start_toggling (port,TYPEC_CC_RD )) +tcpm_set_state (port,SNK_UNATTACHED ,0 ); + }break ;case CHECK_CONTAMINANT :/* Wait for Toggling to be resumed */
Signature · 1 line
2.54.0 (Apple Git-157)
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 18 lines
From: Ilia Snezhkov <[email protected]>
When a DRP port using a TCPCI controller such as RT1711H/RT1715 or its ETEK ET7303/ET7304 compatible silicon is connected via an e-marked USB-C cable (for example to a USB-C PD charger whose own port is temporarily open), the TCPC can stop DRP toggling during its Rp phase upon detecting a single Ra pull-down, reporting
CC_STATUSwith LOOKING4CONNECTION=0, CONNECTRESULT=0 (Rp), and (Ra, Open) or (Open, Ra).In
_tcpm_cc_change(), case TOGGLING only transitions out of TOGGLING for source (Rd), sink (Rp), audio accessory (Ra+Ra), and debug accessory (Rd+Rd / Rp+Rp) states. (Ra, Open) and (Open, Ra) fall through with no state change and no call totcpm_start_toggling(). Because the TCPC has already exited hardware toggling, the port remains stuck presenting static Rp: PD chargers never see Rd and never source VBUS, and [ ... ]
Apple USB-C PD chargers over e-marked C-to-C cables.
Quoted 3 lines
Fixes f0690a25a140 ("staging: typec: USB Type-C Port Manager (tcpm)")Signed-off-by Ilia Snezhkov <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1