Skip to content

J773g: run the front USB-C ports' SuperSpeed half (fixed ATC2 lanes) - #2683

Draft
DjDeveloperr wants to merge 5 commits into
integration/aurorafrom
djdev/j773g-front-usb3
Draft

DjDeveloperr wants to merge 5 commits into
integration/aurorafrom
djdev/j773g-front-usb3

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

The Mac mini (M4, J773g) front USB-C ports are an on-board hub on ATC2: its USB2 half (05ac:800b) sits on raw xHCI port 1 and its SuperSpeed half (05ac:800c) on raw port 2, which ATC2's PHY carries on its lanes. There is no port controller on ATC2, so no Type-C mux ever asks the PHY for USB3, and only the USB2 half comes up today. macOS 27.2 links the SuperSpeed half at 10 Gb/s on this machine.

This runs ATC2's SuperSpeed lanes the way macOS 27.2 does, as an MMIO trace of macOS booting on the J773g shows, selected by device tree data and nothing else.

The sequence (from the trace)

Apple's device tree gives ATC2's PHY two properties the Type-C PHYs don't have: atc-lane-config = <2 0> and atc-plug-orientation = 1. With the controller held in reset and its clamp on, macOS then:

  1. sets up the USB2 PHY (host signal 0x1c07007, then the run state);
  2. powers the PHY up (MISC reset, CTRL 0x5, 0x7, 0x3, 0xb with the status polls) and applies the AXI2AF, LIOA, fabric, common-configuration and common lists, lane 0's USB3 lists, the AUX calibration, lane mode 0x489, crossbar 0x110, no lane swap, the efuse values, and releases the PHY reset (CTRL 0x1b);
  3. starts the common block: CFG0 small, big, clamp off, BGBIAS, RCAL poll;
  4. hands the PIPE over without the PIPE lock: override values 0x16 to 0x10, override 0 to 1 (receiver-valid only), then the T8132 host BIST: CFG1 0x181, OV1 0x4100000, OV2 0x220, pulse, STATUS2 0x84 to 0x04, ack; OV1 0x6100000, OV2 0x220, pulse, STATUS2 0xc4, 0xc4, then 0x44, ack; the native PHY out of reset with power-down 3 in one write (0x1332 to 0x333); OV2 0, pulse, CFG1 0x180; then the mux to USB3 (0x22, 0x2, 0x0, 0x8) and the override off;
  5. releases the controller's clamp and then its reset (0x10, 0x0, 0x1);
  6. sets the controller up, resets xHCI, and only then enables the dummy PHY beside the USB3 one (0x333 to 0x8333), and runs xHCI;
  7. powers the SuperSpeed root port, warm-resets it ~100 ms later, and the hub's SuperSpeed half links in U0 at speed 5 (PORTSC 0x1603), ~1 s before its USB2 half connects.

Changes

  • dt-bindings: phy: apple,atcphy: apple,lane-config and apple,plug-orientation, T8132 only, each requiring the other, carrying the ADT values. Only the traced values (<2 0>, 1) are allowed.
  • phy: apple: atc: a fixed-hub PHY with those properties runs the lanes from probe on, in this driver's existing USB3 and DisplayPort epoch (which is the trace's programming for lane configuration <2 0>; no DP AUX or link is started). Before the controller leaves reset, the reset controller hands the PIPE over as in step 4: no lock, receiver-valid only, phase 2 complete once STATUS2 bit 7 has cleared next to bit 6, power-down and native reset in one write. The dummy PHY is enabled from the host's set_mode, as in step 6, not at probe. After a power-off the lanes come back the same way at the next reset release. A failed handover starts the host on USB2 alone, as for any fixed-hub port, and lanes that cannot start without being touched leave the port on USB2 at probe.
  • arm64: dts: apple: t8132-j773g: the ADT values on &atcphy2, the USB3 PHY and super-speed-plus on &dwc3_2 (macOS leaves the controller's Gen1 force clear), and the hub's SuperSpeed half as hub@2. The hub GPIO hogs are unchanged.

Without the properties nothing changes: the Type-C ports, the J700's fixed hub and the other generations keep their paths (the new branches all depend on the new flag).

Testing

  • tools/asahi/run-host-tests.py --only atc: 6/6, including the atc-usb3 mutations (58 killed, 3 new). --only dwc3: 1/1.
  • tools/testing/selftests/drivers/apple/atc-t8132-usb3.py gets a new case that runs the extracted handover against the T8132 MMIO model and checks it write for write against the trace values above, with negative controls for the bit-6-only phase 2 completion and for a PIPE lock, plus the start from off (epoch, RCAL, then the handover), the latched failures and no retry. The PIPE handler harness checks the order around the reset release and the dummy PHY, with three new mutations.
  • The apple-dcp suite passes 90/90 with this host's clang -Wunused-but-set-global/unused warnings off; with them on, the same 15 cases fail to compile on integration/aurora and on this branch.
  • dtschema with these bindings: no new messages for the J773g DTB; the Back Left port's nodes are identical.
  • The atc.c change builds as a module against the 7.3.0 J773g kernel.

Untested on hardware.

Not in this change

The trace shows a few things around the link that this does not do. They are the first places to look if the SuperSpeed half doesn't link:

  • The hub's reset (usb3hub_rst, AP GPIO 198) is low until ~260 ms after the PIPE handover in the trace; the DT hogs it high from early boot.
  • macOS warm-resets the empty SuperSpeed root port ~200 ms after xHCI starts; Linux does not reset an empty port.
  • macOS sets bit 0 of AXI2AF +0x104 and +0x108 right after the ATC2 common power domain comes on.
  • macOS applies the controller's DRD host tunable (+0x20 low byte 0x1b); the J773g DT does not map that page.

Assisted-by: LLM (Claude:Opus 5.5)

On the Mac mini (M4), the SuperSpeed lanes of ATC2's PHY go to the
on-board hub behind the front USB-C ports instead of to a connector, and
no port controller selects a mode for them. Apple's device tree gives
that PHY two properties the Type-C PHYs don't have, atc-lane-config
<2 0> and atc-plug-orientation 1, and macOS 27.2 runs the lanes from
them by itself: USB3 on lane 0, unswapped, next to an idle DisplayPort
lane, as an MMIO trace of macOS on that machine shows.

Describe the two values as apple,lane-config and apple,plug-orientation,
for T8132 only, each requiring the other. Only the values of that trace
are allowed.

Signed-off-by: Diljit Singh <hey@djdev.me>
A T8132 PHY with apple,lane-config serves a fixed hub whose SuperSpeed
half is wired to the PHY's lanes, with no Type-C mux to ask for USB3.
The PHY enters USB3 only from such a mux today, so that half never links
and the Mac mini's front ports run at high speed.

Bring the lanes up as macOS 27.2 does on the Mac mini's front ports,
from an MMIO trace of macOS on that machine:

- At probe, with the controller held in reset, the PHY takes the lane
  configuration <2 0>: USB3 on lane 0 next to a DisplayPort lane (lane
  mode 0x489, crossbar 0x110, no lane swap), with the AUX calibration
  and the common block's start (CFG0, BGBIAS, the RCAL poll). That is
  this driver's USB3 and DisplayPort epoch without DP AUX or a link.
- Before the reset is released, the PIPE moves to the USB3 PHY with
  only the receiver-valid override, and without the PIPE lock, which
  nothing could acknowledge with the controller in reset. The host
  BIST is the T8132 one, but its second transition is waited out until
  STATUS2 bit 7 has cleared next to bit 6 (0xc4, 0xc4, then 0x44), and
  the native PHY leaves reset with power-down 3 in one write (0x1332 to
  0x333). The mux then goes to USB3 and the override comes off; the
  clamp and the reset are released after that.
- The dummy PHY beside it is enabled once the host is set up, before
  xHCI runs (0x333 to 0x8333), not at probe.

The lanes come back the same way when the host's power-off took them
down. A handover that fails starts the host on USB2 alone, as for any
fixed-hub port, and lanes that cannot start without being touched leave
the port on USB2 at probe. Without the property nothing changes: the
Type-C ports, the J700's fixed hub and the other generations keep their
paths.

The host models run the extracted handover against the T8132 MMIO model
write for write as in the trace, with negative controls for the bit 6
phase 2 completion and for a PIPE lock, and check the order around the
reset release and the dummy PHY in the PIPE handler harness.

Signed-off-by: Diljit Singh <hey@djdev.me>
The front USB-C ports' hub has a SuperSpeed half (05ac:800c) on ATC2's
SuperSpeed root port next to its USB2 half (05ac:800b), and macOS 27.2
links it at 10 Gb/s on this machine (from an MMIO trace: speed 5 in that
root port's PORTSC, with the controller's Gen1 force left clear).

Give ATC2's PHY the lane configuration and plug orientation of the ADT's
atc-phy2, give the controller its USB3 PHY and SuperSpeed Plus, and
describe the hub's SuperSpeed half on raw port 2. The hub's GPIOs stay
as they are.

Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide

Copy link
Copy Markdown
Contributor

An early read. Selecting this by the two ADT-derived properties, with the binding allowing only the traced values and each one requiring the other, is the right shape: the Type-C ports and the J700's fixed hub can't take the new path by accident. It's also good to see the traced sequence written with named values in atc.c rather than raw words.

The main open question is sleep. The new path runs the lanes from probe on, and I don't see a suspend/resume hook for it in the diff. If ATC2's domains lose power across a deep sleep (or s2idle drops them, as on T6050 in #2664), the hub's SuperSpeed half would come back without the PHY sequence, and only its USB2 half would reconnect. Either repeat steps 2–7 on resume for a fixed-lane PHY, or keep its domains on across the sleep. A row with the front-port hub's SuperSpeed device listed before and after one sleep would show which is needed.

Minor: apple,plug-orientation accepts only 1 (normal). If another fixed-hub board ever routes its lanes reversed, the binding will need the other value, so a comment saying 1 is "normal" in the ADT's sense would help the next person.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (M4 Mac mini, macOS 27.2 firmware 26B123) row for this PR: the clean-room front-USB3 kit 8e13c8c

  • Kit: default kernel 7.3.0-ARCH-m4drv8 (010c3eb, Image 1170cd25); DTB e981c981 (38810fbd + this PR's &atcphy2 / &dwc3_2 front-port properties) plus the /chosen asahi,efi-system-partition line (75eba7e5 as booted); phy-apple-atc.ko d43cf9a8 (+ the running kernel's typec.ko, its module dependency) loaded by the kboot initramfs before the root switch; dwc3-apple stock.
  • 1. PHY: probe of 412a90000.phy with driver phy-apple-atc returned 0; none of the fixed-lane warnings (Unknown fixed lane configuration / Fixed SuperSpeed lanes ... / USB3 BIST phase 1|2 timed out / Host starts with its PIPE not parked / T8132 calibration incomplete).
  • 2. The hub's SuperSpeed half:

usb 1-1: New USB device found, idVendor=05ac, idProduct=800b, bcdDevice=56.15
usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 2 using xhci-hcd
usb 2-1: New USB device found, idVendor=05ac, idProduct=800c, bcdDevice=56.15
hub 2-1:1.0: USB hub found
hub 2-1:1.0: 2 ports detected

(Gen 2x1, as macOS links; the USB2 half 05ac:800b on bus 1 unchanged.)
- **3. xHCI port02 (xhci-hcd.1.auto):** `0x0c001663 Speed=5 Link=U3 CCS PP WDE WOE PED` on all 5 reads over 10 s (connected, powered, SuperSpeed Plus, U3 = the idle hub suspended).
- **4. Back Left unchanged:** exactly 3x `sn201202x 1-0a: failed to configure Type-C connection: -19` and 1x `sn201202x 1-0a: cable revalidation failed after 3 attempts`, nothing new.
- **Next reboot:** the proxy and its CDC interfaces came back on the following Stage 1 boot (proxy back: aura uartproxy 1.0.0b13-g5dcf6, CDC 2 ifs; guard: PMU panic counter @0xf802: 0x00 -> 0x00 (boot errors 0, panics 0)).

Assisted-by: LLM (Claude:Opus 5.5)

State explicitly that apple,plug-orientation value 1 corresponds to the
normal (unswapped) orientation in Apple's device tree, with USB3 on
lane 0.

Signed-off-by: Diljit Singh <hey@djdev.me>
Add a host test exercising fixed SuperSpeed lanes across suspend-to-idle
(retaining the active host epoch) and deep sleep (refusing suspend until
the host parks PIPE and powers OFF, then restoring steps 2-7 from cold
reset registers on resume).

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Pushed two small follow-up commits (fast-forward to fde9372352):

  1. a04d45fd5d — clarified apple,plug-orientation in Documentation/devicetree/bindings/phy/apple,atcphy.yaml to state explicitly that 1 is the normal (unswapped) orientation in Apple's device tree, USB3 on lane 0.
  2. fde9372352 — added host-test coverage (ok 15 in tools/testing/selftests/drivers/apple/atc-t8132-usb3.py) for the fixed SuperSpeed sleep lifecycle:
    • s2idle (PM_SUSPEND_TO_IDLE): dwc3_2 keeps the host running (host_active = true), so atcphy_suspend() retains the active common epoch.
    • deep sleep (PM_SUSPEND_MEM): dwc3_apple_core_stop() calls phy_power_off(usb3) -> atcphy_usb3_power_off(), which parks PIPE to DUMMY and runs atcphy_configure_t8132(OFF) before atcphy_suspend(); on resume, atcphy_dwc3_reset_deassert() -> atcphy_fixed_ss_start() restores the clamp from cold reset registers and re-runs steps 2–7 before releasing DWC3_RESET_N.

A J773g hardware sleep/resume row confirming 05ac:800c (usb 2-1) before and after sleep is still pending.

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, that answers the sleep question in code. atcphy_dwc3_reset_deassert() re-runs atcphy_fixed_ss_start() for a fixed-lane PHY whenever the controller comes out of reset, so a deep sleep that powers the PHY off gets steps 2–7 again before DWC3_RESET_N is released, and s2idle keeps the host and the common epoch. The plug-orientation wording is clear now. Resolved from my side pending the J773g row you list (05ac:800c on usb 2-1 before and after one s2idle and one deep sleep).

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Live J773g (T8132, macOS 27.2 26B123) front USB3 verification row (7.3.0-ARCH-m4prod4) — boot + 3/3 s2idle cycles PASS (rtcwake -d /dev/rtc1 -m mem -s 8, mem_sleep=s2idle, pm_test=none, 0 disconnects, 0 speed downgrades, 0 oops/warnings/SErrors):

  • Boot enumeration:
[   18.416815] usb 1-1: new high-speed USB device number 2 using xhci-hcd
[   18.541521] usb 1-1: New USB device found, idVendor=05ac, idProduct=800b, bcdDevice=56.15
[   18.544268] usb 1-1: Product: USB2 Hub
[   18.653076] usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 2 using xhci-hcd
[   18.666340] usb 2-1: New USB device found, idVendor=05ac, idProduct=800c, bcdDevice=56.15
[   18.669498] usb 2-1: Product: USB3 Gen2 Hub
  • Sysfs USB enumeration (identical pre-sleep and after s2idle1, s2idle2, s2idle3; usb_dev_suspend/usb_dev_resume returned 0 on every cycle):
1-1            05ac:800b spd=480   USB2 Hub
2-1            05ac:800c spd=10000 USB3 Gen2 Hub
3-1            0781:5567 spd=480   Cruzer Blade

Real J773g Deep Sleep (mem_sleep=deep) row incoming next on v5.

Assisted-by: LLM (Gemini:4 Neon)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verified across 3/3 real Deep Sleep cycles (dcp66-m4prod5-deepsleep) on live M4 Mac mini (J773g / T8132, macOS 27.2 26B123, 7.3.0-ARCH-m4prod5):

Cycle boot object resumes Front USB3 (05ac:800c / 05ac:800b) Errors / Disconnects
1 0 -> 1 05ac:800c 10000 (10 Gbps) + 05ac:800b 480 Mbps alive 0
2 1 -> 2 05ac:800c 10000 (10 Gbps) + 05ac:800b 480 Mbps alive 0
3 2 -> 3 05ac:800c 10000 (10 Gbps) + 05ac:800b 480 Mbps alive 0

0 disconnects, 0 speed downgrades, and 0 kernel oops/warnings/SErrors across all 3 wakes.

Assisted-by: LLM (Gemini:4 Neon)

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