Repository navigation
J873g: USB4 on the rear USB-C ports through tipd and atc.c (T8152 routers, PCIe-C, M6 Mac mini) - #2178
Open
sithglan wants to merge 148 commits into
Open
J873g: USB4 on the rear USB-C ports through tipd and atc.c (T8152 routers, PCIe-C, M6 Mac mini)#2178sithglan wants to merge 148 commits into
sithglan wants to merge 148 commits into
Conversation
The T8152 (M6) Always-On Processor differs from the T8140 one: its setup port is not reachable from the AP, so it has one mailbox, and its audio service uses six serializer power domains and the jack, speaker and speaker-sense ADMAC channels. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Add the Mac mini M6 (J873) sound card. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873 (Mac mini M6) AOP runs the same firmware generation as T8140 (EPIC v4, iBoot-loaded, started by the AP), but the T8140 "setup port" is not reachable from the AP: mailbox 1 of the AOP's mailbox bank and the ADT aop-exclave-mailbox both bus-error. The firmware boots without it: RTKit protocol 12, then its "audio" EPIC service. Add apple,t8152-aop with the T8140 configuration minus the setup port, starting every advertised endpoint. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The Mac mini (M6, J873) speaker runs a 250-BCLK TDM frame, which the SN012776's ratio auto-detection rejects. Describe the property that fixes the ratio instead. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873 (Mac mini M6) AOP runs the speaker frame at 250 BCLKs of 12 MHz. The SN012776 cannot auto-detect that ratio and mutes with "fault: bad TDM clock". With TAS2764_CLK_CFG (register 0x60) set to 0x30 and TDM_CFG0 bit 6 set it accepts the frame and plays. Do that when the new ti,bclk-ratio property names the ratio; only this one ratio is supported. Source of the value: the register write was first seen in the macOS SN012776 driver; it is a single register value, and its effect (no fault, correct playback) was verified on J873 hardware. No table or code was taken from macOS. The field is initialised in probe, so non-OF matches keep auto-detection. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The SDOUT1 mux offers the ASP receive channels as a source, but no DAPM route connected them, so selecting "ASP RX CH1" or "ASP RX CH2" left the capture path without an input. The J873 and J813 AOP audio services use it to loop the playback stream back. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
On T8152 (J873, Mac mini M6) the AOP firmware owns the audio fabric, as on T8140. Its "audio" EPIC service offers cout/cin (the CS42L84 jack, base-ns ADMAC TX5/RX5, MCA4) and spkr (the SN012776 speaker, TX1, MCA0). Each service is an ASoC back-end DAI: startup attaches it, requests pw0 (which raises the audio fabric) and powers the MCA leaves, all of which are required. pwrd starts the serializer clocks at prepare, before ASoC unmutes the codecs: the jack codec locks its PLL to the bit clock, and the speaker amplifier reports "bad TDM clock" whenever it runs without one. The jack restarts its clocks on every prepare so that a stream restarted after an underrun begins on a frame boundary; the mono speaker (one slot per frame) keeps them running. The front-ends are dmaengine PCMs on the base-ns channels: the jack in stereo, the speaker in mono (its serializer runs one 32-bit slot; stereo frames play at half pitch). The firmware's serializer configuration (property 701) is byte-identical to the one macOS publishes, so the driver leaves it alone. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873 (Mac mini M6) uses the T8152 AOP audio driver as its CPU component: the CS42L84 jack on "cout" (DSP_A | IB_NF, one-BCLK sync pulse) and one SN012776 on "spkr" (I2S, NB_IF: data sampled on the rising edge, as macOS programs the amp). Each AOP front-end owns the DMA channel of one serializer, so the speaker can only be fed from the secondary front-end; the new spk_secondary_only sets the speaker mux accordingly, and spk_dai_fmt gives the speaker link its own format. There is no qualified speaker protection for J873 yet (no verified sense path, thermal model or power budget), so the speaker fails closed: it is only enabled with please_blow_up_my_speakers. Opted in, it runs as macOS runs it: amp gain 15 (ADT speaker-config) and no volume lock (safe_vol 0), since there is no sense stream for a protection daemon. The jack is not affected. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8142 AOP keeps its crash buffer in its own slot of its DART stream and asks for it on endpoint 1 with that IOVA. A client without shmem_setup refused the request, so the firmware never got its crash buffer acknowledged. APPLE_RTKIT_FIRMWARE_OWNED_CRASHLOG takes such a buffer as the firmware's, without a CPU mapping, and acknowledges the request unchanged; a later crash is reported without a log. RtKit::new_with_firmware_crashlog() selects it at runtime, so a driver can use it for one SoC only. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8142 AOP (MacBook Air J813) waits for the host on a setup port, as the T8140 one does: the ADT's aop-exclave-mailbox at 0x3d067c000 (AOP ASC + 0x4007c000, not behind the arm-io translation). Its EPMAP announces other service endpoints than T8140's fixed set (0x4, 0x20, 0x23 and 0x32 on J813), so take the endpoints that must get buffers from the EPMAP when the match data says so. The firmware places its own crash log buffer in its firmware-mapped DART slot; accept it as the firmware's, as for G17P. After the setup boot all AFK endpoints start, and with the audio fabric left to the firmware (see the J813 device tree) the firmware announces its "audio" EPIC service. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Behind an AOP the serializer feeding a capture channel is the firmware's, and it stops in the middle of a frame whenever it likes. A capture that stays open across such stops (the speaker V/I sense, which a protection daemon reads for as long as it runs) then carries the partial frame forward: every later frame is off by its words, and the samples of one amplifier are read as another's. On the MacBook Air J813 one restart in three slipped by one 16-bit word. Let a client pass the frame size in bytes as a u32 in dma_slave_config.peripheral_config. A paused cyclic capture on such a channel resumes at the next frame boundary of its current period: the reports completed before the pause are accounted for, the rings are reset and the rest of the period is submitted from the aligned address, then whole periods as before. Without a frame size nothing changes. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J813 speaker stream (ADT iop-audio-controller/audio-speaker) differs from J873's: four SN012776 in 32-bit playback slots 0-3, and their voltage and current sense back on the same stream's RX side (base-ns RX0) as eight 16-bit slots. Make the speaker and sense shapes per-SoC match data: J873 keeps one playback channel; T8142 gets four, and an 8-channel S16_LE "Speaker Sense" front-end. The sense capture is the speaker serializer's RX, which the firmware stops anywhere in a frame. Before every `pwrd` of the speaker, restart a running sense capture at a frame boundary (apple-admac realignment, the partial frame reads as zeros), so that a protection daemon that keeps it open attributes each amplifier's voltage and current to the right one. The sense back-end also attaches the speaker service and requests `pw0 ` at startup: its front-end requests the ADMAC channel next, and the ADMAC only answers while the firmware holds the audio fabric up. Opening the sense before any other stream since the AOP started (speakersafetyd at boot) otherwise faults the bus. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
MacBook Air 13" M5 (T8142): as on J873 the AOP firmware owns the audio fabric and the CPU component is the T8152-style AOP audio driver. The jack is a CS42L84 on "cout", the speakers four SN012776 (one woofer and one tweeter per side) on "spkr", with their V/I sense on the same stream. As on the other SN012776 laptops the speaker volume stays locked until a protection daemon (speakersafetyd) holds it. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The MacBook Air J813's three microphones are the AOP's "hpai" service (ADT iop-audio-controller/audio-hp-mic): the firmware runs the PDM part and delivers 48 kHz float32 frames of three channels (the ADT's audio-hp-mic-proxy description: 12 bytes per frame) on leap-s ADMAC RX0. There is no codec, so it gets a card of its own with one capture PCM, named like the other AOP microphone cards (AppleJ813HPAI, "MacBook Air J813 High-Power Audio Interface", driver aop_audio) so that the existing UCM and DSP configurations for those apply. As on T8140: open attaches the service and requests pw0 (which raises the LEAP fabric), powers the LEAP leaves (leap-s ADMAC, RX0, LEAP MCA), and only then requests the channel, whose registers fault without them. The trigger starts the DMA and queues pwrd behind it; started earlier, the LEAP produces into a channel nobody services. Close releases the channel, then pw0 and the leaves. The card exists only where the DT gives the LEAP power domains (all three); J873 is unchanged. The dmaengine substream setup moves into a helper shared with the ASoC front-ends. Tested on J813: a tone from the speakers reads -44 to -49 dBFS on all three channels, 70 dB over the quiet floor, exactly while it plays; PipeWire picks up the card with asahi-audio's J613 beamformer graph. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
integration/aurora added the nCal boot argument and word-wise boot-argument access to AopHwConfig. Both machine configurations keep the firmware's own boot arguments unchanged, so set ncal to zero and leave word access off. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Every boot on the J616s logged "spi-nor spi0.0: supply vcc not found, using dummy regulator". The M1, M2, M3, J713 and J700 trees describe the flash's always-on PMU rail as a fixed regulator; the M4 Pro/Max tree came later and has none. Add the same regulator and point the flash at it. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
Preserve current RTKit crashlog and GPU handling while retaining the expanded macaudio bindings and adding J813/J873 compatibles. Original audio commits and authorship are preserved.
…ation Test whether COUT standby supplies the missing cold-boot fabric setup. A muted zero-data jack stream permitted HPAI capture and subsequent capture-only opens on J813; standby without any playback is the next hardware qualification step. Preserve Thomas Glanzmann’s driver and adapt the T8140 DMA sync-stop pattern from Ryan Murray, also flushing queued HPAI work before DMA teardown. No LPAI buffer binding or codec unmute is performed.
…queue Describe the T8142 microphone DMA and LEAP power domains and card names in the shared audio binding. Queue sleeping firmware power requests on system_dfl instead of the deprecated system workqueue, as directed by the runtime warning observed during hardware capture tests.
…-initialization-20261106 ASoC: apple: integrate J813 audio with first-open microphone initialization
…616-nor-vcc arm64: dts: apple: t604x-j614-j616: Describe the boot NOR flash supply
Resolves sound/soc/apple/macaudio.c: aurora-wip added spk_dai_fmt and spk_secondary_only (J813/J873) where integration added tweeter_hpf_granted (speaker protection ownership); the struct keeps all three. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
…nc-20261107 Merge integration/aurora into aurora-wip (11-07)
Brings aurora-wip up to integration/aurora 068dfce: pcie-apple endpoint reset retry (aurora-silicon#1069) and the tools/aurora-sep PKGBUILD checksum fix (aurora-silicon#1068). Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
…n/wip-sync-20261107b aurora-wip <- integration/aurora 068dfce (aurora-silicon#1068, aurora-silicon#1069). Clean merge, W=1 pcie-apple.o 0 warnings on the merged tree, CI host-tests/rust-build/source pass. Merge train (MTR).
Brings aurora-wip up to the tested release branch: CTXR execmem (aurora-silicon#985, aurora-silicon#1079), KFIX speaker sleep and resume fixes (aurora-silicon#1077, aurora-silicon#1080), JPEG v2 (aurora-silicon#1072), Jonathan's G17 and USB work (aurora-silicon#1073-aurora-silicon#1076), brcmfmac flowring count (aurora-silicon#1081), ANE H16 startup restart (aurora-silicon#1066) and the Touch ID per-prompt match (aurora-silicon#904). Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
Adds the 11-07 evening batch: t8140 disabled SPI3/FPWM0/SPMI nodes (aurora-silicon#1034), J700 CPU zones (aurora-silicon#1043), J616C fans (aurora-silicon#1092) and the thunderbolt DP PM workqueue fix (aurora-silicon#1098). Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
…n/wip-sync-20261107c Gate on the exact head tree 6c684e8 (buildbox): fleet22-config Image+modules+dtbs build rc=0, 0 errors, 0 warnings, 5890 modules (= fleet); run-host-tests 193/193; apple-dcp host selftests 86/86 (fleet baseline 86/86). CI host-tests/source/rust-build green. Brings aurora-wip up to integration/aurora 810b92c.
Brings aurora-wip up to fleet25: DT descriptions (aurora-silicon#1029, aurora-silicon#1030, aurora-silicon#1112), the J715 board (aurora-silicon#1129), Stockholm NFC (aurora-silicon#1042, aurora-silicon#1136), the AV1 tile check (aurora-silicon#1100), the M4 Max ANE profile and AVD quirk (aurora-silicon#1088, aurora-silicon#1091), boot-log fixes (aurora-silicon#1103, aurora-silicon#1104) and the Neo ANE memory floor (aurora-silicon#1137). Conflicts: macaudio.c and apple,macaudio.yaml, where aurora-wip's J813 and J873 entries and integration's J715 entries were added at the same spot. Keep all of them. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
The USB-C PD controllers behind the J873g's (T8152) SPMI controller at 0x308908000 answer as the T8132 ones do: no register-selection interrupt, so a selection is polled, and the payload length of the selected register is read from register 0x1f. Their event, sleep and wake sources are interrupts 11/17/19, 37/43/45 and 63/69/71 of that controller. Add apple,t8152-sn201202x with apple,t8132-sn201202x as fallback, so that the T8132 interrupt layout (irq, sleep, wake) applies. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
… as Type-C mode switches A T8152 DCP drives the rear USB-C port whose PD controller reports a DisplayPort sink. So far the DCP read the controllers itself, through apple,usb-pd. The controllers belong to the USB Type-C port driver instead, which passes the DisplayPort alt mode state of a port to the Type-C mode switches its connector's graph leads to. Describe one display switch per port, shared by the DCPs: the port's usb-c node in the shared ports node (the one apple,usb-c-ports refers to) is the mode switch, with an endpoint at the display port (port@3) of the port's usb-c-connector. The DCPs already share these nodes for the port's PHY registers and tunables, and each port has one owner at a time. One switch per DCP instead would fill the three mode switches a connector's port driver looks at (fwnode_typec_mux_get() collects the matches into a three-entry array and stops at the third endpoint without an error), and leave out the port's ATC PHY, which needs one for USB4. Drop apple,usb-pd, which nothing reads any more. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 DCPs found a USB-C display by reading the rear ports' PD controllers over SPMI every 250 ms (t8152_pd.c): plug and orientation from STATUS (0x1a), DisplayPort connection, pin assignment and HPD from DATA_STATUS (0x5f), through the controllers' register window (select at 0x00, length at 0x1f, data from 0x20). With tipd bound to the same controllers, tipd failed to read its events while the display path polled. The controllers belong to tipd now. Take the state from the Type-C class instead: one Type-C mode switch per rear port, the port's usb-c node in the shared ports node, with an endpoint at the display port of the port's connector. tipd sets the port's mode on it. The switch records whether the port is in DisplayPort alt mode with HPD high, the lanes of the pin assignment (two for B, D and F, which share the cable with USB 3) and the plug orientation of the Type-C port, once, next to the port claims of t8152_atc.c, and tells every DCP that drives USB-C to look at the ports. The port claim and the PHY, crossbar and DPTX handling of t8152_atc.c and iboot_drm.c stay as they were. One switch per port, not one per DCP: a connector's port driver takes three mode switches at most (TYPEC_MUX_MAX_DEVS; fwnode_connection_find_matches() stops at the third endpoint and returns success). A switch per DCP would fill all three on every J873g rear connector, and the port's ATC PHY, which needs one for USB4, would never be called. A HPD pulse is not a new sink. Without a video stream, an EV2780 drops HPD for about 160 ms every 4.7 s; the PD controller reports it after the fact, and tipd passes it on as HPD low and then high. Connecting the sink anew on each pulse kept its link from coming up (link faults, one lane, then a standby link trained at RBR whose mode list lacked the enabled mode, so the next DPMS on failed atomic check). The 250 ms poll never saw these pulses. A switch event is looked at 100 ms later, which takes such a low and high together, and only a changed plug (orientation, lanes) or a sink that leaves DP alt mode with its partner is a new connection. dcp-fabric.c's route layer itself does not fit these DCPs: it switches a DP PHY and the display crossbar through their drivers and connects the sink through the DCP's IOMFB DPTX service, while the iBoot interface DCPs program the ATC PHY and the crossbar themselves and connect through their own DPTX port service. Their switches only record the state, in t8152_typec.c. The 250 ms work now only re-arms while a DCP can take the shared HDMI port, whose HPD line has no interrupt. The PD controller reset that made a sink which stopped answering AUX enter DP alt mode again (a cold reset, "Gaid", then system power state S0, "SSPS") is gone: the controller is tipd's, and tipd puts it into S0 whenever it sets the controller up. What remains is the DisplayPort side, at most once a minute: release the link and connect the port's sink again. HPD changes now reach the display path as they happen. The first DCP that probes registers the switches, ahead of everything else in its probe, and they stay until the driver is unloaded: tipd keeps the switch it found, and must not wait for a DCP that cannot start. A switch that cannot be registered is disabled in the live tree, so that tipd goes on without it. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
… tipd The PD controllers of the three rear USB-C ports were described for the display path alone, which read them over SPMI itself. Describe them for tipd, which owns them from now on, and the display path takes their DisplayPort alt mode state from the Type-C class: - the controllers as apple,t8152-sn201202x, with the T8132 fallback: tipd's SPMI transport then polls the register selection and reads the payload length from register 0x1f, as these controllers need; - the SPMI controller (AIC 682) as the interrupt controller of their event, sleep and wake sources: 11/17/19 (back-middle), 37/43/45 (back-left) and 63/69/71 (back-right), rising edge, as in the ADT. In a test with the compatibles and interrupts alone, tipd bound all three, took its events by interrupt, and both display partners showed DisplayPort alt mode active; - a usb-c-connector per controller, whose display port (port@3) leads to the port's usb-c node in the main DCP's shared ports node, the port's one display switch for all three DCPs. The USB port (port@0) stays unlinked: the USB data path is not changed here. The DCP's usb-c nodes lose apple,usb-pd, which nothing reads any more. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
On T8152 the video decoder, the USB4 routers and their PHYs and the USB controllers are powered through PMGR2 PSD services instead of PMGR power-state registers. Each service has a 0x100-byte block with a target state, an acknowledge bit and the current state. Describe one service per node as a power domain, with an optional apple,always-on for a service whose consumers cannot restore what another agent set up in its blocks yet. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Provide each T8152 PMGR2 PSD service as a power domain. Power-on requests state 0 and power-off the cold state 6. The driver waits for the acknowledge before it reads the state, because reading the state consumes the acknowledge. A service marked apple,always-on is powered at probe and kept on. Otherwise the domain starts in the state the hardware reports, so genpd powers off a service that nothing uses. The consumers include IRQ-safe devices, the DARTs, so the domains are IRQ-safe and a transition is polled atomically, as the PMGR power states are. On the J873g the AVD service (50) reaches state 0 in 390-500 us and the cold state in about 240 us; the timeout is 10 ms. The AVD and the USB4 routers' CIO services, which so far each had their own variant of this, and the USB controllers (services 175 and 176) use it. It has its own Kconfig symbol, APPLE_PMGR_PSD, on by default with ARCH_APPLE and built in by the shared asahi.config profile. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The two front USB-C ports of the Mac mini (2026, J873g) sit behind an on-board USB3 hub. The hub's SuperSpeed lanes are wired to the Type-C PHY of the SoC's ATC2 directly, without a Type-C mux or port controller in between, so that PHY only ever runs one fixed USB3 configuration. Describe the T8152 variant in that role, with a boolean apple,fixed-usb3 that marks such a port: the PHY runs USB3 on lane 0 from probe on, ignores mux and orientation changes and provides only the USB3 PHY of its controller. The controller's USB2 side and reset stay with the bootloader, so the T8152 PHY has no #reset-cells and no Type-C switch properties. The PHY is described by its core and pipehandler banks. On T8152 the core bank also holds the USB controller's DARTs, and the PHY's power and reset block sits behind them. It needs four power domains, listed in the order they are powered up: the ATC's USB_AON power state, its common PSD service and its COMMON_DP_0 and COMMON_DP_1 power states. The other variants keep their single power domain and #reset-cells. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873g front ports reach their on-board USB3 hub through ATC2's Type-C PHY, wired to the hub without a Type-C mux. So far the hub ran at USB2 only: the bootloader leaves the PHY powered down and the PIPE on the controller's dummy PHY. Support the T8152 PHY in that role in the shared ATC driver. T8152 shares the T8142 generation's power and reset block, tunables and PIPE handler, with a different layout: the USB controller's DARTs sit at 0x20000 and 0x40000 of the ATC window, so the power and reset block follows at 0x60000, its lane swap is bit 1 there, and the reset the power-up releases first is a separate always-on sync reset at 0x60030. The crossbar is at 0x4c and the USB3 mode's existing setting, USB3+DP with single PMA 0x008, gives the value 0x110; there is no lane mode register to program. Describe this in the match data, with zero for the layout of the other SoCs, and leave the power-up and power-down, the tunables, the crossbar and the PIPE switch to the existing code. What remains T8152 code: - Lane 0 is powered up on its own after the common-a tunables (LFPS receivers, sleep, clamp, AHB reset) and down again with the PHY. Without it the lane registers stay in AHB reset, drop the lane tunables and the PHY never reports PIPE PhyStatus. The crossbar is set right after, before the remaining tunables, as in the T8152 sequence. - While the PIPE moves to the PHY, the BIST overrides hold lane 0's PIPE reset and power-down, stepping from P2 to P3, and the non-selected PHY override is released under them. The T8152 PIPE handler takes the lock request but does not acknowledge it: with the controller out of reset, no acknowledge came within 150 ms in either direction, while the PIPE moved to USB3 and back to the dummy PHY under the request. So T8152 changes the PIPE under the request without waiting for the acknowledge; otherwise every USB3 start fails. A fixed-USB3 port, apple,fixed-usb3, is a host by construction. Probe maps only the core and PIPE windows, the core without claiming it as it holds the DARTs, powers the PHY's power domains in the order they are listed and brings the PHY up in USB3. It registers only the USB3 PHY: no reset controller, Type-C mux or switch, as the controller's reset and USB2 side stay with the bootloader. The PIPE is routed when the controller powers the USB3 PHY on, after its core reset, which also sets the PHY up again after a power-off. If that fails the host starts with its PIPE parked, so the hub keeps USB2. The T8152 register sequence is the one of the earlier standalone driver, with which the hub enumerated at 10 Gb/s. The other SoCs keep their register accesses: the new layout fields are zero for them, and the new code runs for T8152 or a fixed-USB3 port only. KUnit cases check the T8152 crossbar, lane and power block accesses. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The two front USB-C ports sit behind an on-board VL822 hub on usb-drd2. The hub's USB2 side is on the controller's eUSB2 PHY, which the loader sets up, and its USB3 side on ATC2's Type-C PHY, wired directly without a Type-C mux. So far the controller was limited to high speed and the hub ran at USB2 only. Describe ATC2's PHY as an apple,t8152-atcphy with apple,fixed-usb3, hand it to usb-drd2 as its USB3 PHY and drop the controller's high-speed limit. Nothing changes for usb-drd1 (the back-left port). The PHY's power domains are ATC2's USB_AON, COMMON_DP_0 and COMMON_DP_1 PMGR power states, in a new node for the ATCs' block of PMGR states at 0x308290000, and its common domain, PSD service 57 (ADT clock-gates 57). The T8152 USB3 bring-up runs the power states without automatic power management, so they are marked apple,no-auto-pm. The tunables are the groups of the ADT's atc-phy2 node (26A434) that apply to USB3 on lane 0, in the order they are applied: the common and PLL defaults as common-a, the fabric, PLL and USBC0 groups as common-b and the lane 0 groups as lane0-usb. Some of them differ between the four ATCs of the same machine, so they likely carry per-device calibration. There is no atcphy2 alias, as the loader's ATC tunable copy would replace them with values for another PHY layout. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Allow the five ACIO register windows, LSTX GPIO and router firmware tunables used by T8142. Describe its native PCIe-C compatible and require the shared MSI vector base. Include the T8142 pinctrl fallback chain used by the AOP LSTX pin. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
T8142 uses the Intr2AXI controller layout but its three-cell AIC interrupt specifier and MSI window differ from T6050. Match it natively. This allows a tunnelled NVMe controller to allocate working MSI-X interrupts. For T8132 and T8142 the slice is checked against the device tree alone. msi-ranges names the AIC input of global vector apple,msi-vector-base in a linear window, so the window's AIC base is msi-ranges minus apple,msi-vector-base, and the slice is checked by its shape: an edge-rising SPI, 32 vectors, 32-aligned, above the internal port's vectors and inside the 8-bit map target. This replaces T8132's table of ECAM apertures and its AIC base 1506 behind a machine check. The T8132 trees give 1602 - 0x60 = 1634 - 0x80 = 1506, and every J813 PCIe node gives 1741. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Each T8152 USB4 router's coprocessor has a 0x80-byte mailbox window with the counted FIFOs of the SMC mailbox, at offset 0x80 of its register block. Describe it with apple,t8152-smc-mailbox as the fallback, so the SMC mailbox's match data serves it, and with its send-empty and recv-not-empty interrupts. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 CIO reset block resets the rear USB4 routers of the J873g. It has a request and an acknowledge register instead of T8142's control register, so it gets its own compatible. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 CIO reset block requests a router reset in register 0x68 and acknowledges it in 0x6c. Wait for the router's pair of busy bits to clear, request, wait for the acknowledgment and clear it. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The DARTs of the J873g rear USB4 routers (NHI streams) and of their PCIe-C tunnels are Gen3 DARTs like the display ones, but start unlocked with inactive streams. Each has its own slot in the shared TLB invalidation aperture, and its ADT tunables and DMA window. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The DARTs of the T8152 USB4 routers and their PCIe-C tunnels are Gen3 DARTs that, unlike the display ones, the bootloader leaves unlocked with inactive streams. Admit cold Gen3 setup for the instances their compatibles select, with version 0x300, their tunables and inactive streams, and initialize them before enabling translation: clear the streams, apply the tunables and invalidate through the Gen3 TLBI aperture, which is now mapped before the reset. Domains use two-level 16K tables inside a single 64 GiB DMA window, as iBoot's display streams do. - ACIO DART (apple,t8152-acio-dart): 32 streams, NHI streams 0-11 and 16-27. - PCIe-C DART (apple,t8152-pciec-dart): translated streams 0-252, with 253 and 255 in bypass for host transactions and MSI writes to the AIC (the ADT reserves them), firmware's stream 254 preserved, 16K pages, 42-bit addresses; it must be tunnelled and have its power domain. Without the bypass on 255, NVMe completions were polled and the DART faulted at the AIC. Each DART invalidates through the TLBI slot its "tlbi" resource names. The slot has to be the port's own: with port 3's slot on port 1's DART, reads returned wrong data with DART faults. The locked display DARTs and all other Gen3 instances stay as they were. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The PCIe-C ports tunnelled through the J873g rear USB4 routers are laid out like T8142's: Intr2AXI MSI slices, the T6050 tunnel controls, and no port reset of their own. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 tunnelled PCIe-C ports use the T6050 tunnel controls with the Intr2AXI MSI path, like T8142, and their MSI slices are checked the same way: from msi-ranges and apple,msi-vector-base alone. The J873g's three bridges use 0x60 (CIO0, ECAM 0x1c50000000), 0x80 (CIO1, 0x1c60000000) and 0xc0 (CIO3, 0x1c80000000) of the window at AIC 1879. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Add the T8152 ACIO and NHI. The T8152 router CPU is started by a reconfiguration request through its mailbox, so it has no cpu window. A second range maps the shared Gen3 TLB invalidation aperture for the router's DART. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 router is a Type 7 MXWrap-v2p3 that a reconfiguration request starts through its counted mailbox. Its DP IN path is not qualified. Release the CIO domains in reverse order and suspend each one synchronously, because deleting the device link only queues an idle request: the PHY reset and the next router start need them cold. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873g's three rear USB-C ports have T8152 ATC PHYs behind a Type-C mux, with a USB4 router behind each. Linux runs them in CIO (USB4) mode only for now: their DisplayPort alt mode is still driven by the display controllers, and their USB2 side by the bootloader. Allow a T8152 PHY without apple,fixed-usb3 for such a port: its core bank alone (the power and reset block at 0x60000 is part of it, and the display controllers map the same bank), the orientation and mode switches with port@0 to the connector's SuperSpeed port, the ATC's four power domains in power-up order, and the common and lane CIO tunables. The display controller takes the PHY through its DisplayPort PHY. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873g's three rear USB-C ports have T8152 ATC PHYs with a USB4 router behind each. Their DisplayPort alt mode is still programmed by the display driver (drm/apple's T8152 code), and their USB2 side is the bootloader's. Run such a PHY in CIO mode for a USB4 partner and leave it to the display driver otherwise, as a Type-C port of its own kind (cio_only, selected by the T8152 match data for a PHY without apple,fixed-usb3). The Type-C port driver sets the mux before it starts the router and after it stops it, as on T8142. CIO mode uses the T8152 layout of the fixed-USB3 support: the power and reset block at 0x60000 with the sync reset at 0x60030, the crossbar at 0x4c (USB4 0, USB4 swapped 1), no lane mode register. It differs from USB3 in that both lanes are powered up, one after the other, between the common-a tunables and the others (LFPS receivers 0x1e24 bits 12/16 and 14/18, then the lane controls at 0x1e18 and 0x1e1c out of sleep, unclamped and out of AHB reset), and in that a reversed plug sets the lane swap (bit 1 of 0x60008) next to the swapped crossbar, where T8142 leaves it clear. On the way down AUX is clamped (0x1e24 bit 10, sleeps 6 and 8 cleared) and both lanes' LFPS receivers are dropped before the lanes, as the T8152 CIO shutdown does: these always-on controls keep their state while the common block is off. The lanes are only touched while the register bus (0x60000 bit 3) is out of reset. This is the sequence the earlier port monitor ran, with which a rear port trained USB4 at 2 x 20 Gb/s and carried an NVMe enclosure at 16 GT/s x4. The PHY's four power domains (USB_AON, the common PSD service, DP_0, DP_1) are attached without device links. They are held while the PHY runs CIO mode, and dropped synchronously after the CIO shutdown, so that the common block goes cold before the next partner: a training from a powered common block asserted in the router's firmware. The PHY and the display driver take turns, explicitly: - The display driver powers the PHY's DP PHY on before it touches the PHY and off when it has let go of it. The DP PHY holds the domains for it and keeps CIO mode out: a USB4 mode change fails with -ETIMEDOUT, and the mux declares its timeouts transient, so the port driver retries until the display is gone. A DP PHY power-on in CIO mode fails with -EBUSY. - Either takes the PHY only when its power and reset block is as its power-up leaves it (0x60000 = 0x4, no sleep acknowledged, sync reset 0); CIO mode is refused otherwise. - A display the bootloader started has all four domains on and a busy block at probe. Its domains are then held for the display driver, which takes the PHY over, until its DP PHY goes off. Once DisplayPort moves into this driver, the DP PHY programs it itself, both modes switch under the PHY's lock and this arbitration goes away. Thunderbolt alt mode is refused on these ports for now: the T8152 routers have only been run with USB4 partners. The other SoCs are unchanged: the new paths are taken for a cio_only PHY or the T8152 generation only, and T8152 now sets has_usb4, which a fixed-USB3 port's tunable list does not consult. KUnit cases check the CIO lanes, crossbar and swap in both orientations, the power-down, the idle test and which Type-C states ask for CIO. The DCP host-test fixtures that compile the power-up and power-down get the new field. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A rear USB-C port's ATC PHY is also its USB4 PHY, run by the ATC PHY driver, which powers the PHY. Give each usb-c port node the port's PHY in DisplayPort use (PHY_TYPE_DP): a DCP powers it while it drives the PHY, from before a cold start until the PHY is powered down, and the PHY driver keeps the PHY powered and out of USB4 meanwhile. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 DCPs powered a rear USB-C port's ATC PHY themselves: before a cold start they set the port's USB_AON, DP_0 and DP_1 PMGR power states (PS +0x100, +0, +0x20) to 0xf and its common PSD service to 0, and after a power-down they set back those that had been off. The same PHY now runs CIO mode for USB4, through the ATC PHY driver, which powers it through the PMGR and PSD power domain drivers. With two writers of the same states, one would switch off what the other uses, or leave the power domain drivers believing a domain on that is off. Take the PHY through the port's DP PHY instead (the usb-c node's phys): power it on before the cold start's first PHY access and off once the PHY is powered down. The PHY driver then holds the PHY's power domains and keeps it out of USB4; while the PHY runs USB4 the power-on fails with -EBUSY and the cold start with it. A display the bootloader left running is kept powered by the PHY driver from its probe; the DCP that adopts it powers the DP PHY on at once and so takes that over. A port whose common block runs but whose DP PHY cannot be powered is in USB4, not a bootloader display: the power and reset block (CFG +0x60000) reads 0x1b in both. The PMGR and PSD state registers are still read to tell whether the PHY can be looked at. The DisplayPort programming itself is unchanged. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The three rear USB-C ports' ATC PHYs (ADT atc-phy0, 1 and 3) were only known to the display controllers, as register windows they program and power themselves. Describe them as T8152 Type-C PHYs, which the ATC PHY driver runs in CIO mode for USB4: - their core windows (0x403000000, 0x40b000000, 0x413000000, 0x84000 each, also mapped by the display controllers); - the orientation and mode switches, linked to the SuperSpeed port (port@1) of the port's usb-c-connector; - their power domains, in power-up order: the ATC's USB_AON, its common PSD service (55, 56, 58) and its COMMON_DP_0/1 power states, new nodes next to ATC2's. The USB_AON states are kept on, as ATC2's: they hold the rear USB controllers' state the loader set up; - the CIO tunables of the ADT's atc-phyN groups, at the PHY blocks they apply to: the common defaults before the lanes are powered up, the fabric, PLL and remaining common groups after them, then each lane's groups. They are the lists the earlier port monitor applied, with which a rear port trained USB4. The display controllers' usb-c port nodes take the PHYs through their DP PHY, which powers them while a controller drives the port. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A reboot or power-off shuts the PCIe-C host and the router's and the tunnel's DARTs down before the router, while a started router still runs over them. With the J873g's rear ports, the earlier port monitor stopped the routers from a reboot notifier for this. Without a port monitor, do that in the router driver: for routers whose match data asks for it (T8152), stop a started router from a reboot notifier, as the port driver does for an unplugged cable, and refuse a new start from then on. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Describe the three rear USB4 routers (ADT acio0, acio1, acio3) with their mailboxes, NHI, ACIO DARTs, PCIe-C tunnels and their DARTs, the CIO reset block, the PSD services they need and the LSTX pins. Generated from the J873g ADT, including the router, NHI, DART and PCIe-C tunables and the router DROMs, whose UID field is the port index. Each router coprocessor's mailbox has apple,t8152-smc-mailbox as its fallback and the two interrupts of the ADT's acio-cpuN node, which list send-empty first, as the SMC mailbox's do. Each router's Thunderbolt switch (its port@1) is linked to the USB4 port (port@4) of its port's usb-c-connector, as on the J813: the PD controller driver sets the port's ATC PHY to CIO mode and then starts the router with the cable's EUDO and orientation, and stops the router before it takes the PHY out of CIO mode. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Every enabled DART must name the power state of the engine it serves (scripts/dtc/apple-dart-pd-check.py). The three rear routers' NHI DARTs named none. A DART sits inside its router, so it takes the router's first PSD service (59, 60 and 62: ADT acioN power-gates), the one the router powers up first and down last. The router populates the DART only once it is powered and its firmware is ready, and removes it before it powers down, so the DART's vote never holds the router on after a stop. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
sithglan
force-pushed
the
thomas/j873-usb4
branch
from
November 22, 2026 14:50
f083bd3 to
5f89281
Compare
Contributor
Author
|
Right: the back-right router ( Assisted-by: LLM (Claude:Opus 5.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
USB4 on the three rear USB-C ports of the M6 Mac mini (J873g, T8152), through the Type-C stack. This is the last step of the order agreed above.
tipdowns the PD controllers,atc.cruns the ports' ATC PHYs in CIO mode, and the routers start from the Type-C state, as on the J813 (#2142). There is no private port monitor any more.Stacking. Stacked on #2486, which is on #1800, #1743 and #1797. It also carries these commits unchanged:
atc.ccomes from there;Review the top 16 commits.
Carried from the earlier version, unchanged
"apple,t8152-cio-mailbox", "apple,t8152-smc-mailbox", with the two interrupts of its ADTacio-cpuNnode.thunderbolt/appleT8152 support. The CIO power domains go through pmdomain: apple: T8152 PSD services as power domains #2459 and return to cold when unused.Reworked
usb4-portbinding is gone.New
phy: apple: atc: run the T8152 Type-C ports in CIO modeapple,fixed-usb3is a CIO-only Type-C port. It uses J873g: USB3 on the front ports (T8152 in the ATC PHY driver, M6 Mac mini) #1799's T8152 layout: power/reset block at 0x60000, sync reset at 0x60030, crossbar at 0x4c.phy_power_on/phy_power_off) instead of writing the PMGR/PSD registers itself, so genpd is the only power path.-ETIMEDOUT, which tipd retries. While CIO runs, the DP power-on returns-EBUSY.atc.c.thunderbolt: apple: stop the T8152 routers before a reboot: a running router is stopped before PCIe and DART shut down. The earlier port monitor showed this is needed.port@1to the PHY's mux and switch, andport@4to the router;apple-t8152-port.cand its config line are removed.Testing (M6, this tree)
The USB4 host-to-host and display rows, from one boot of this tree:
atc.cbrought the PHY up in CIO mode, and router ACIO0 started.401178080.mailbox-recvcounted 25 and-send0.atc.c. 6 of 6 DPMS off/on cycles pass.Checks:
--strictis clean on the new code.phy-apple-atc*: 45/45, including 4 new T8152 CIO cases.tools/asahi/run-host-tests.py: 427/427.apple-dt-check.shagainst J873g: rear USB-C PD controllers through tipd, DisplayPort alt mode from Type-C (M6 Mac mini) #2486: 0 new warnings, and all 9 changed bindings pass.USB4 NVMe enclosure (Samsung 980 PRO in a Ugreen enclosure, back-right, this head):
Not covered: system sleep (the J873g has none), DP tunnelling over USB4 and two enclosures at once.
cc @Acelogic @RyanTheTide @DjDeveloperr @LiamRay10
Assisted-by: LLM (Claude:Opus 5.5)