Skip to content

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

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

techmore wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
techmore:upstream/tipd-cd321x-tbt3-usb-role-20261111-v3

Conversation

@techmore

Copy link
Copy Markdown
Contributor

Draft, build-only: the new role path has never run on hardware. It builds, and checkpatch reports only the missing Signed-off-by; see "Hardware runs" below.

On a T8132 SN201202x port with no USB4/Thunderbolt 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. When the port is connected, is a T8132 SN201202x (apple,t8132-sn201202x), has no router (cd321x->tbt_switch is NULL), and DATA_STATUS shows a TBT or USB4 connection without USB2/USB3, the USB role comes from the Type-C data role in STATUS: host → USB_ROLE_HOST, device → USB_ROLE_DEVICE. It does not come from DATA_STATUS's USB data role bit, because DATA_STATUS reports no USB connection here. Ports with a router, other SoCs, and connections that report USB2 or USB3 are unchanged. In the current device trees, the only T8132 ports with the CIO calibration (J713/J715) also have a router, so they are excluded.

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.

Checks on this branch: scripts/checkpatch.pl --strict reports only the missing Signed-off-by (see below). arm64 W=1 build of drivers/usb/typec/tipd/ with GCC 15.2.0 / binutils 2.46, also with CONFIG_KUNIT=y and CONFIG_TYPEC_TIPD_KUNIT_TEST=m: no warnings. There is no KUnit case: the existing CD321x tests do not drive the USB role from cd321x_update_work().

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: J604 and J624 ports have no router in the device tree either, so they would get the same role. Untested.
  • 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: this builds and applies on integration/aurora alone. On the J773g it has an effect only together with the companion atcphy patch, "phy: apple: atc: Serve USB2 for USB4/TBT on T8132 without CIO calibration". Without it, the TBT mux update fails with -ENODEV and cd321x_update_work() retries before it reaches the role.

Signed-off-by from the author to follow. The commit is posted without one; I'll add mine before it's merged.

Written with help from an LLM; I reviewed it and ran the hardware tests above.

…uter

cd321x_update_work() derives 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 Mac mini (J773g) a Thunderbolt 3 dock gives
DATA_STATUS 0x86010001, which has the data connection and TBT connection
bits and a TBT cable speed, but no USB2, USB3, DisplayPort or USB4
connection bit. The role stays USB_ROLE_NONE and the port's dwc3 never
starts an xHCI.

That is right for a port with a USB4/Thunderbolt router, which tunnels
the partner's USB. The J773g's ports have no router, and their T8132 PHY
has no CIO calibration, so the PHY serves the partner's USB2 instead of
the Thunderbolt link. Without a USB role nothing uses it.

On a T8132 SN201202x port without a router, give a TBT or USB4
connection that reports no USB2 or USB3 connection the USB role of the
port's Type-C data role, taken from STATUS, since DATA_STATUS reports no
USB connection to take the USB data role from.

Ports with a router, and other SoCs, are unchanged.

Assisted-by: LLM checkpatch
The lifecycle harness builds cd321x_update_work() from tipd/core.c on
the host. It now compares the STATUS data role against TYPEC_HOST for a
T8132 TBT3 port without a router, and the shim had no
enum typec_data_role, so physical-disconnect, fast-replug-bounce and
dropped-swap-teardown failed to compile.

Declare the enum as include/linux/usb/typec.h does.

Assisted-by: LLM
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.

1 participant