Skip to content

usb: typec: tipd: Set a USB role for TBT3 on T8132 ports without a router - #1703

Draft
techmore wants to merge 3 commits into
aurora-silicon:mainfrom
techmore:upstream/tipd-cd321x-tbt3-usb-role-20261111-v3
Draft

techmore wants to merge 3 commits into
aurora-silicon:mainfrom
techmore:upstream/tipd-cd321x-tbt3-usb-role-20261111-v3

Conversation

@techmore

@techmore techmore commented Nov 12, 2026 •

Copy link
Copy Markdown

Draft: the updated role path builds and has host coverage. It has never run on hardware.

On a port whose PHY supplies USB2 in place of USB4/Thunderbolt and which has no router, give a Thunderbolt 3 (or USB4) connection that reports no USB2 or USB3 connection the USB role of the port's Type-C data role. Without a role, the port's USB controller never starts (run 56 below). With one, the controller should start and use the USB2 that the PHY serves, but that has not run on hardware yet.

Why. cd321x_update_work() takes the USB role only from the USB2 and USB3 connection bits of DATA_STATUS. In Thunderbolt 3 alt mode the controller sets neither. On the J773g (Mac mini M4), a Thunderbolt 3 dock on Back Right gave DATA_STATUS 0x86010001. It has the data connection and TBT connection bits and a TBT cable speed, but no USB2, USB3, DisplayPort or USB4 connection bit. With a router that is fine, because the router tunnels the dock's USB. The J773g's rear ports have no router in the device tree, and their T8132 PHY has no CIO calibration. With "phy: apple: atc: Serve USB2 for USB4/TBT on T8132 without CIO calibration", the PHY serves the partner's USB2 there instead. But with the role left at USB_ROLE_NONE, dwc3 never creates the xHCI that would use it.

The change. The ATC PHY advertises USB2 tunnel fallback through the Type-C mux after it has checked the port's CIO calibration. TIPD uses that capability when the cable is connected, a TBT or USB4 link is reported without USB2/USB3 status, and no router is present. It derives the role from the Type-C STATUS and starts it after mux configuration. A port without the capability keeps its existing role selection.

Hardware runs. These ran on one J773g, natively, with kernels based on #1192 plus local J773g test commits. None of them ran this patch's role path:

  • Run 56, without this change: the dock entered Thunderbolt 3 alt mode (SVID 0x8087), and the PHY served USB2 (state mode 2 alt 0x8087 -> PHY mode 1: 0). DATA_STATUS read back 0x86010001, from a read-only register dump. No rear xHCI came up; only the front controller's buses were present. This is the failure the patch addresses.
  • Run 57: the kernel had an earlier version of this role code, gated on the J773g machine compatible instead of on a T8132 port without a router. The dock did not enter Thunderbolt 3 in that boot. It entered DisplayPort alt mode (PHY in USB3+DP), DATA_STATUS reported USB, the existing role path brought up the rear xHCI, and its hub, Ethernet and HID devices enumerated. So the new role path did not run. The other rear port (another Mac, USB4) reports USB2 in DATA_STATUS and took the existing path.

Test-only setup, not part of this PR: runs 56 and 57 used local sn201202x module parameters to steer the dock's mode entry. j773g_no_usb4 clears USB4 host capability in the DFP VDO (TX_IDENTITY), and j773g_no_tbt3 clears thunderBoltModeEnabled (INTEL_VID_CONFIG). Both replay a pre-Linux connection with DISC. The DFP VDO change is why the dock went to Thunderbolt 3 in run 56 instead of USB4. Those knobs write the controller's configuration and are J773g test aids only.

Not tested:

  • This code on any hardware, in Thunderbolt 3 or USB4.
  • Whether the dwc3 runs cleanly in host mode while the port controller stays in Thunderbolt 3.
  • Whether a Thunderbolt 3 dock drives USB2 on D+/D- at all.
  • Other T8132 boards. A port’s eligibility now depends on its reported PHY capability and router presence.
  • A T8132 port whose router is described but whose driver has not bound (probe stops waiting for it): tbt_switch is NULL, so a Thunderbolt 3 connection gets the USB role. When the router binds later, cd321x_tbt_attach_work() takes its switch and reapplies the cable state. Whether that then drops the role has not been run.

Dependency: #1702. This branch includes the two #1702 commits atop integration/aurora at 5746ef8a5, with the TIPD change last. Merge the PHY change first or advance the base once it lands.

Current review update

On 1d5fa6357, native ARM64 built the ATC, Type-C mux and TIPD objects. The only TIPD compiler warning also appears on the unchanged base. The host disconnect scenarios passed 127 assertions with a scratch-only adjustment for ext26 model definitions that the unchanged base harness also lacks. The focused cases cover TBT/USB4 device-role selection, no fallback capability, a present router, and mux failure. A J773g rear Thunderbolt 3 dock run showing xHCI startup and USB2 device enumeration remains outstanding.

The original contribution disclosed LLM assistance without naming a model.

Assisted-by: LLM (OpenAI:Codex)

@techmore
techmore force-pushed the upstream/tipd-cd321x-tbt3-usb-role-20261111-v3 branch from 39bd46e to 9b0ca00 Compare November 13, 2026 22:58
@techmore
techmore marked this pull request as ready for review November 14, 2026 01:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T01:23:44.074731Z 9b0ca00 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@RyanTheTide

Copy link
Copy Markdown

Early note on this draft (no full review yet):

  1. drivers/usb/typec/tipd/core.c:1155: the new role path is gated on the apple,t8132-sn201202x compatible, but the condition it really depends on is "no router and the PHY serves USB2 for a TBT/USB4 partner". !cd321x->tbt_switch already covers the router half. Key the rest on what the PHY reports (for example a property or capability exposed by the ATC PHY when it lacks the CIO calibration, or the PHY mode it actually selected), so any port with the same hardware situation gets the role without a per-SoC compatible check.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

On 110861f, cd321x_update_work() still takes the USB role only from the USB2 and USB3 connection bits, so a TBT3 partner on a port without a router still gets no role. Both commits apply cleanly on 110861f. It pairs with #1702 (PHY serves USB2 without the CIO calibration). @techmore, two things are still open: key the new branch on what the PHY reports instead of the apple,t8132-sn201202x compatible, as in the earlier review note, and a J773g row with a Thunderbolt 3 dock on a rear port that shows the xHCI starting and a USB2 device enumerating.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, 1 compiler warnings in the files it touches. Host tests (tools/asahi/run-host-tests.py --only) on 110861f plus this change: apple-dcp passes (1/1).

…tion

The SN201202x port controllers of the Mac mini (J773g) enter USB4 by
themselves with a USB4 dock or another Mac, and Thunderbolt 3 alt mode
with a Thunderbolt 3 dock. atcphy_typec_target_mode() maps those states
to the USB4 and TBT PHY modes, which atcphy_mux_check() refuses with
-ENODEV on a T8132 PHY without the CIO calibration. The J773g device tree
has none. The failed mux update makes cd321x_update_work() retry before
it sets the USB role, so the port ends up with

  sn201202x 1-08: failed to configure Type-C connection: -19
  sn201202x 1-08: cable revalidation failed after 3 attempts

and its dwc3 controller never starts an xHCI.

USB 2.0 on D+/D- does not depend on the USB4 or Thunderbolt link. As is
already done for the DisplayPort pin assignments this PHY cannot carry,
serve the partner's USB2 instead of refusing the mode.

The CIO fallback has to come before the DisplayPort fallback picks its
USB mode: that one compares its result with target_mode, and started
from the USB4 mode it would put USB4 back.

Ports with the CIO calibration are unchanged. A KUnit case covers both.

Signed-off-by: Sean Dolbec <sdolbec1@gmail.com>
The ATC USB3 host test and the apple-dcp phy, pm, quiesce and dwc3
host tests compile functions taken from drivers/phy/apple/atc.c.
Define dev_info() as a no-op beside their existing logging shims so
the generated host C keeps compiling when one of those functions
prints an informational message.

Signed-off-by: Sean Dolbec <sdolbec1@gmail.com>
When a USB4 or Thunderbolt partner has neither a router nor the usual
USB connection status bits, a USB role is appropriate only if the
mux supplies USB2 instead of the tunnel. Have the ATC PHY advertise
that capability from its calibration result. Use the capability in
TIPD and continue to activate the role only after mux configuration.

Signed-off-by: Sean Dolbec <sdolbec1@gmail.com>
@techmore
techmore force-pushed the upstream/tipd-cd321x-tbt3-usb-role-20261111-v3 branch from 9b0ca00 to 1d5fa63 Compare November 24, 2026 03:02

Copy link
Copy Markdown
Author

Updated the draft to 1d5fa6357, stacked on #1702. TIPD now tests a USB2 fallback capability reported by the mux provider, with no controller-compatible gate. ATC sets that capability after the CIO calibration check. An absent router and TBT/USB4 status are still required; TIPD applies the role after mux configuration. Native ARM64 ATC, mux and TIPD objects built, and the focused host harness exercised device-role selection and the negative cases. The rear Thunderbolt 3 dock run showing xHCI startup and USB2 enumeration on J773g remains outstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants