Skip to content

J873g: two USB-C displays and HDMI at once, USB-C at 2560x1440@60 (apple_dcpib, M6 Mac mini) - #2176

Open
sithglan wants to merge 114 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j873-three-displays
Open

sithglan wants to merge 114 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/j873-three-displays

Conversation

@sithglan

@sithglan sithglan commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1800 (thomas/j873-dcp, 4be1858). Only the top ten commits are new:

  • dt-bindings: display: apple,t8152-dcp-iboot: describe DCPEXT1 and shared USB-C ports
  • drm/apple_dcpib: drive the rear USB-C ports from all three DCPs
  • arm64: dts: apple: j873: add DCPEXT1 and share the USB-C ports
  • drm/apple_dcpib: match the firmware mode on the exact refresh rate
  • drm/apple_dcpib: clock USB-C DisplayPort from the ATC's PMGR DP clock
  • drm/apple_dcpib: check modes against the route's lanes
  • drm/apple_dcpib: take a woken DCPEXT's oslog ring as the firmware's
  • dt-bindings: display: apple,t8152-dcp-iboot: describe the HDMI cold start
  • drm/apple_dcpib: start an HDMI port the bootloader left off
  • arm64: dts: apple: j873: describe the HDMI cold start

The J873g (M6 Mac mini) has three display controllers, three rear USB-C ports and HDMI. With #1800, one USB-C display ran from the main DCP and HDMI from DCPEXT0. It worked only on ATC3, and only up to 140 Mpixel/s (2560x1440 at 30 Hz). With this PR, each controller claims any free rear port, so two USB-C displays and HDMI run at once. USB-C runs at the monitor's native mode.

USB-C above ~165 MHz. The ATC's DP clock switch (ATCPHY_DP_CLKSWITCH_SELECT/ENABLE/STATUS, CFG + 0x14/0x18/0x1c) selected source 0. AppleT8152TypeCPhy::aciophy_configure_dp_clkswitch_control selects PMGR DP clock n - 1 for pixel clock n, after setATCDPClkSrcSel has set the link-rate divider. With that, 2560x1440@59.951 (241.5 MHz) and 640x480 work, and the pixel-rate cap and floor are gone.

Firmware mode lookup. The firmware takes width, height and a 16.16 refresh rate and picks the timing itself. For the USB-C EV2780 it lists the sink's 2560x1440@59.951 (241.5 MHz) and, before it, a 60.000 Hz standard mode of its own (byte 0 bit 6) that it drives with CVT at 312.25 MHz (89.5 kHz line rate). The driver compared whole Hz and sent the standard mode; the monitor showed an error instead of a picture. It now matches on the exact rate.

oslog ring of a woken DCPEXT. A DCPEXT woken with apple,rtkit-wake offers the oslog ring of its own firmware segment (0x100033cc000, the coprocessor's DRAM tag in bit 40), which only the firmware's retained DART tables map. The shmem setup failed (failed buffer request ep=0x8 ... (-12) on every boot) and RTKit then rejected the firmware's oslog write counters instead of acknowledging them. The ring is now taken as firmware-owned without a CPU mapping (Linux never reads it; aura does not answer the request either).

HDMI without the bootloader. HDMI used to work only if the bootloader had brought it up: after a boot without an HDMI monitor, a monitor plugged in later stayed dark. Such an HDMI port is now one of the shared ports. The main DCP or DCPEXT0, whichever drives no USB-C display, takes it on HPD and starts the dptx-phy and the PS190 from cold, as aura's dptx_t8152_activate does: PMGR/PSD power, PS190 power through the SMC (pcIO), source select, the ADT tunables (new DT properties), PLL/phy activation and the impedance calibration. It gives the port back on unplug. A boot with HDMI connected keeps the bootloader's HDMI as before. The driver now depends on MFD_MACSMC.

Mode check after a replug in power save. Modes were checked against the lane count of the last link training. An EV2780 that drops and reasserts HPD while the display is off gets a stream-less one-lane training, after which 2560x1440@60 no longer fit and the output stayed dark on wake. Modes are now checked against the lanes the firmware may train (GET_MAX_LANE_COUNT, the USB-C route's).

Multi-controller and hotplug. Per-endpoint crossbar upstream fields, per-ATC PMGR DP dividers, the AUX output selector per port, Apple's 14-bit AUX reply timeout (EDID through a USB-C to HDMI adapter), two-lane pin D, SSPS 0 for a sleeping PD controller, a quiesced RTKit session woken instead of adopted, and a 250 ms hotplug worker that owns all USB-C links. The commit messages have the details.

Loader contract. The board DTS does not hard-code runtime handoff state:

On the test machine the ESP DTB carries apple,rtkit-wake and apple,afk-active-endpoints (fdtput) until the installed loader has aura#300 (now installed on the test machine, the DTB properties removed); the internal DCP's AFK report is aura#89.

Tested on the J873g with aurora-wip 7.3.0 plus this stack:

  • Three displays at once: HDMI EIZO EV2780 at 2560x1440@59.951 (main DCP); EV2780 on rear-left USB-C, two lanes HBR2, at 2560x1440@59.951 (DCPEXT1); EIZO S2431W through a USB-C to HDMI adapter on rear-right at 1920x1200@59.95 (DCPEXT0). Cold reboots come up the same way.
  • Picture: 2560x1440@59.951 on the USB-C EV2780 checked by eye (firmware programs 241.5 MHz, htotal 2720, vtotal 1481). The sink CRC below counts frames the DP receiver gets, even when the monitor rejects the timing, so it is not a picture check on its own.
  • Sink CRC: the sink's DP test CRC, with AUX borrowed through the DFP's AUX mux field only so the stream keeps running. TEST_CRC_COUNT advances once per frame at 60 Hz. The CRC is stable for a still picture and follows content changes; blue, red, green and back to blue gives the first CRC again. 640x480@60, 640x480@59.94 and 720x480 were checked the same way. Before the clock fix, 2560x1440@30 gave 30 frames/s and 60 Hz modes were not offered.
  • Hotplug: physical unplug and replug of all three displays (both USB-C and HDMI) with the final stack, each coming back. PD disconnect/reconnect (DISC after the board-key LOCK) on each USB-C display, and on both at once, with all three displays running. Each time: HPD removed, ATC powered down, cold PHY start, EDID re-read, modeset back to the native 60 Hz mode, CRC advancing at 60 Hz, HDMI undisturbed. The day before, during bring-up, the display was moved physically between all three rear ports and both orientations.
  • Boot with the loader handoff: with aura#300's loader installed and the DTB without hand-added DCPEXT properties, both DCPEXTs wake with no buffer error or invalid oslog notification; all three outputs up.
  • HDMI plugged after boot: booted without HDMI (the loader's HDMI setup fails), the main DCP and DCPEXT1 drive the two USB-C EIZOs. HDMI plugged in later: DCPEXT0 takes the port, phy up from cold, HBR3, 2560x1440@60 on the EV2780 within 0.6 s. Unplugged, the port is given back; plugged again, it is taken and the mode set without a cold start. Checked by eye.
  • Display sleep (swayidle power off/on): all three outputs come back, checked by eye after an idle sleep. A forced PD disconnect/reconnect of the EV2780 during the off phase also comes back (the first SET_MODE fails, the driver re-enters DP alt mode, 2560x1440@60 follows about 4 s later).
  • wdisplays: opening it with all three outputs, the scanout buffers carry each output's overlay box.
  • Build checks: the module builds with W=1 and no warnings; dt_binding_check and the DTB check pass for apple,t8152-dcp-iboot.yaml; checkpatch shows 0 errors and 0 warnings (8 --strict style checks in the driver commit).

Booting from HDMI alone and plugging USB-C displays in later works with a loader that hands over DCPEXT0/1 for an RTKit wake (aurora-silicon/aura#300, installed on the test machine and tested). Not covered: HDMI taken by DCPEXT1 (source select 2), which aura does not use.

sithglan and others added 30 commits November 6, 2026 11:23
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
sithglan and others added 29 commits November 19, 2026 19:23
A co-processor adopted from the bootloader has already sent its endpoint
map, to the bootloader, so the application endpoints a client starts on
it by hand are not in rtk->endpoints. Every message on them is then
logged as one to an undiscovered endpoint. The T8152 DCP driver would get
one per SET_SURFACE, about 60 lines a second during video.

Add apple_rtkit_adopt_ep() for a client to register an application
endpoint of such a session.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The DARTs in front of the T8152 display coprocessors (DCP, DCPEXT) and
their display pipes (ADT "dart,gen3", version 0x300) use the T8110
register layout, but they belong to the SPTM, and the bootloader hands
them over locked. Their TLB command register at 0x80 answers translation
queries instead of flushing. A stream is invalidated the way iBoot does
it: a payload naming the DART and the stream is written to the SoC's TLB
invalidation aperture, which these DARTs share, and a broadcast TLBI
follows.

Add apple,t8152-dart-gen3 for them, without the apple,t8110-dart
fallback, since a T8110 driver would flush through the wrong register,
and a "tlbi" register entry for the DART's window in the aperture.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 display DARTs (ADT "dart,gen3", version 0x300) use the T8110
register layout but belong to the SPTM: their TLB command register at 0x80
answers translation queries instead of flushing. A stream is invalidated
the way iBoot does it, by writing a 128-bit payload (valid, route, SID)
to the SoC's shared TLBI aperture and broadcasting a TLBI, which the DART
snoops. The route is the DART's 0x4604 register.

Admit a Gen3 DART only when the bootloader hands it over locked (its
streams cannot be set up cold yet), map the aperture from a second "tlbi"
reg entry without claiming it, since every Gen3 DART shares it, flush the
whole stream where a range flush would go through 0x80, and do not claim
the fault interrupt or drain stale exceptions, whose handling acknowledges
through that register as well.

The range flush test fixture gains the new hw flag.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The Gen3 DART snoops the broadcast TLBI that follows the aperture write.
iBoot and the aura bootloader issue TLBI VALE1OS at EL2 without VHE,
which targets the EL1&0 regime. On a VHE kernel the same instruction
targets EL2&0 while HCR_EL2.TGE is set, so clear TGE around it, as KVM
does to reach the EL1&0 regime.

The J873g display works with this in place; the effect of the change on
its own has not been isolated on hardware.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The display coprocessor (DCP) of the Apple T8152 runs RTKit firmware that
offers a small display service, "disp0-service", next to the full
IOMobileFramebuffer protocol; iBoot drives the displays through it. The
DCP fetches through its own DART, and the display pipe scans out through
another one that is locked with a root of its own, so the scanout stream
is a child node.

The DCP's DPTX port drives either the ATC PHY of a USB-C port, whose PD
controller reports the DisplayPort alt mode and the plug orientation, or,
on the Mac mini (J873g), the dedicated DisplayPort PHY that feeds the HDMI
port through a DisplayPort-to-HDMI converter. The sink's EDID is read
through the AP's DisplayPort AUX controller.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 DCP firmware (AppleDCP-1317) offers a small "disp0-service"
next to the full IOMobileFramebuffer protocol that drm/apple speaks.
iBoot and the aura bootloader drive the Mac mini (J873g) displays through
it. This driver uses only that service, the DPTX port service the
firmware calls back into for the PHY, and the DPAV controller services it
expects to be opened, all over AFKEPV2 rings. It is a port of aura's
afk.c, dcp_iboot.c, dcp/dptx_port_ep.c, dcp/atc_phy.c and dcp/dptx_phy.c.

The driver takes over the displays the bootloader brought up:

- The DCP does not acknowledge AP QUIESCED, and an IOP INIT while its AP
  power is still ON panics it ("Invalid AP power: 32"). The RTKit session
  is adopted as it runs, and the application endpoints are started with
  explicit START_EP messages. The bootloader stops its AFK endpoints
  first: an AFK INIT on a live endpoint asserts in the firmware.
- A new iBoot session has no surface, and a pipe still running then
  fetches from a null base (IOMFB axi_rd_err, firmware NMI). The display
  is powered off until a surface is set.
- The DCP fetches through dart-dcp, the display pipe scans out through
  dart-disp0, and both are locked with live roots of their own. The
  scanout stream is a child device with a domain of its own. Scanout
  buffers are mapped there at their DCP address, cacheable, since the
  pipe faults on entries with the DART's no-cache bit, and away from the
  firmware's own mappings.
- Changing the surface between buffers made later SET_MODEs crash the
  firmware. Three scanout buffers are allocated at probe, large enough
  for the largest mode; a frame is copied into one that is not on screen
  and swapped in with SET_SURFACE, at most once per refresh, since there
  is no vblank interrupt.
- The firmware takes only width, height and refresh rate for a mode and
  picks the timing itself. It does not hand out the EDID on this
  interface, so the EDID is read through the AP's DisplayPort AUX
  controllers.

On USB-C, the DCP drives the ATC PHY of the rear port that has a
DisplayPort sink, which the port's ACE3 PD controller reports over SPMI
together with the plug orientation. The J873g HDMI port has a dedicated
DisplayPort PHY behind a PS190 DP-to-HDMI converter. Both PHYs keep the
bootloader's setup and reprogram what a link training changes. With a
USB-C display at boot, the bootloader drives HDMI from DCPEXT0; without
one, it drives HDMI from the main DCP and never starts DCPEXT0. The driver
follows the source select it finds in the HDMI PHY.

HDMI hotplug is polled from the converter's HPD line, USB-C hotplug from
the PD controller, and display power follows the CRTC.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The DCPAV service starts its idle power off timer when its video interface
starts; a powered-on display without a following SET_MODE counts as idle
and the firmware takes the link down 30 s later. At boot the probe's
SET_MODE comes before the interface is (re)announced, so HDMI went dark
30 s after boot while sway still reported the output active.

Re-send SET_MODE for the current mode a second after a
dcpav-video-interface opens, from a delayed work on system_percpu_wq:
dcp->wq is ordered and runs the AFK receive work that completes the
SET_MODE reply.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Use the current non-devm RTKit adoption API. Gate incoming endpoint work,
drain senders, and detach RTKit while preserving live DMA buffers after a
startup failure. Keep the failed device bound to prevent a retry over
that session.

The driver has no safe firmware shutdown yet, so omit module exit and
retain the existing suppressed bind attributes. Initialize and drain the
PD reset worker together with the flip workers, and defer AV mode repair
until DRM registration.

Signed-off-by: Acelogic <miguelc4600@gmail.com>
[Thomas: on this tree the RTKit session was freed by a devm action
 rather than devm_apple_rtkit_init_adopted(); drop that action instead]
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A USB-C-only J873 boot leaves DPTX_PHY off, and reading the HDMI PHY
then raises an SError. Describe the read-only PMGR power states of the
HDMI PHY (DPTX_PHY) and of the DCPEXT CPU (DISPEXT0_CPU) with the HDMI
PHY's register layout, so that the driver can check them before it
touches the PHY.

Signed-off-by: Acelogic <miguelc4600@gmail.com>
[Thomas: split out of the driver change]
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A USB-C-only J873 boot leaves DPTX_PHY off. Reading its PLL register
while discovering the HDMI source raises an SError before the main DCP
can probe. Check the always-on PMGR requested and actual states before
touching the PHY, and only adopt DCPEXT when a powered HDMI link selects
it. Missing state resources fail closed.

Signed-off-by: Acelogic <miguelc4600@gmail.com>
[Thomas: the binding and device tree parts are separate changes]
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…points

The bootloader may hand the DCP over with AFK endpoints still running,
and an AFK INIT on a live endpoint asserts in the firmware. Add a
property the bootloader fills in at boot with the endpoints it left
running, so that the operating system can stop them before it starts a
session of its own.

Signed-off-by: Acelogic <miguelc4600@gmail.com>
[Thomas: split out of the driver change, added the description]
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The bootloader may leave the DCP's AFK endpoints running with its
scanout, and an AFK INIT on a live endpoint asserts in the firmware.
Read the endpoints it left running from apple,afk-active-endpoints, and
send each of them a SHUTDOWN and wait for its acknowledgment before the
INIT; the old session's buffers stay reserved by the bootloader. Without
the property there is no telling whether an endpoint is live, so the
driver refuses to take the DCP over. The endpoint is registered with
RTKit before the SHUTDOWN, so that its reply is not reported as one to
an undiscovered endpoint.

Signed-off-by: Acelogic <miguelc4600@gmail.com>
[Thomas: the binding is a separate change, added the description]
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The DARTs of the main DCP and of DCPEXT0, and those of their display
pipes (ADT dart-dcp, dart-disp0, dart-dcpext0 and dart-dispext0), belong
to the SPTM, and the bootloader hands them over locked. Their TLB is
invalidated through the SoC's TLB invalidation aperture
(dart-tlbi-aperture), not through the T8110 TLB command register.

Describe them as apple,t8152-dart-gen3 with their windows in the
aperture (ADT tlbi-aperture-offset 0x400 and 0x480). The second register
window of the display pipe DARTs, their SMMU instance, is not used and
is dropped. The other display DARTs keep their description until
something uses them.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The bootloader trains the J873g displays through the DCP firmware's iBoot
interface and hands both DCPs over with their RTKit sessions running:
the main DCP drives a USB-C display on one of the rear ports, or HDMI
when no USB-C display is attached at boot, and DCPEXT0 drives the HDMI
port next to a USB-C display.

Add both DCPs with their post-office mailboxes and enable their Gen3
DARTs, with the DMA window in the upper half of the firmware's 64 GiB
window, above the firmware's and the bootloader's mappings. The main DCP
lists the three rear USB-C ports with their ATC PHY, PMGR power states,
tunables and PD controllers on nub-spmi-a0. DCPEXT0 has the HDMI PHY,
the read-only PMGR power states of the PHY and of its CPU, and the HPD
line of the DP-to-HDMI converter on the AOP's GPIO controller, which is
polled since its interrupts belong to the AOP. Each DCP has the AP
DisplayPort AUX controller that reads the sink's EDID.

Resources are from the 26A434 ADT.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The Mac mini (M6, J873g) drives its HDMI and USB-C displays through
apple_dcpib, the DCP driver on the iBoot interface. Build it beside the
DCP driver, as the shared defaults require of every native driver.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…red USB-C ports

All three T8152 display controllers can drive the rear USB-C ports
through the one display crossbar. Describe what a controller needs for
that:

- apple,dp-source: its crossbar UFP endpoint (0 DCP, 1 DCPEXT0,
  2 DCPEXT1);
- apple,usb-c-ports: the node holding the shared usb-c port children,
  the DP clock dividers and the AUX controller;
- coproc-psd: the read-only PMGR2 PSD admission state of a DCPEXT,
  checked before its coprocessor is touched (a read while it is gated
  hangs the machine), and the coproc + coproc-psd layout of an extra
  controller without PHY resources of its own;
- apple,rtkit-wake: set by the loader for an unused DCPEXT whose
  firmware iBoot loaded and powered and which waits for an RTKit wake.

The dp-clock resource now spans the PMGR ATC DP clock dividers of all
ATCs (one every eight bytes from ATC0) instead of ATC3's alone.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The driver drove one USB-C display from the main DCP, and HDMI from
DCPEXT0 or the main DCP. The J873g mini has three display controllers
and three rear USB-C ports. Let every controller drive any free port,
so two USB-C displays and HDMI run at the same time, and fix what kept
ports other than ATC3 and sinks other than one EIZO from working:

- Shared ports: each DCP claims a free ATC under a mutex and releases
  it on unplug. The crossbar's upstream reset, clock and enable fields
  are indexed by DCP endpoint * 2 + DPTX port
  (AppleT8142ATCDPXBAR::bringConnectionUp); they were fixed to DCP0.
  The DFP0 mux selects that endpoint.
- Each ATC has its own PMGR DP clock divider at 0x300020044 + 8 * n;
  every port wrote ATC3's.
- AUX: the AP AUX controller's output select is instance * 3 + local
  DFP (AppleAUXDPTX::getAuxSelValue), not ATC3's 9 for every port.
  The reply timeout is a 14-bit field at bits 21:8
  (AppleDPTXController::initAuxReplyTimeout, 3200), not Analogix's
  three-bit delay: the old value timed out EDID reads through a USB-C
  to HDMI adapter. All DCPs share aux0, so reads are serialized.
- Two-lane DisplayPort: a monitor with USB3 negotiates pin D
  (DATA_STATUS bit 5). Report two lanes to the firmware and set up only
  the PMA that carries DP.
- PD: a controller in power state 7 enters alt mode only after
  SSPS 0, not after an SPMI wakeup alone. Its select/data window is
  held under the SPMI device's lock for the whole exchange, which the
  USB4 port monitor takes as well.
- Startup: wake a quiesced RTKit session instead of adopting it as
  running. That is an unused DCPEXT the loader marks apple,rtkit-wake,
  after its PSD admission check, or a main DCP the loader quiesced
  after a failed display setup (apple,dcp-rtkit-quiesced; the J873
  aura build v0.1.0-259-ga30a589a predates that property and is
  recognized by its 640x1136 placeholder framebuffer). Release the
  inherited DPTX link before the first connection.
- Hotplug: register a USB-C connector idle; a 250 ms worker owns all
  USB-C links. A PD reset releases DPTX and powers the PHY down first,
  and a quick reconnect restores a CRTC that was enabled.
- KMS: scan out the checked, clipped source rectangle with damage made
  output-relative, and a 64-byte aligned pitch. The firmware rejected
  an unaligned bytesPerRow (verify_surfaces). Restore the requested
  mode's surface geometry before power on; cancel pending swaps on
  disable, unplug and PD reset; stop submitting while the controller
  is off, disconnected or crashed; send no AFK messages after a crash.
  Scanout buffers are sized for 3840x2160 so a monitor plugged in
  later fits.
- The ATC path's pixel-rate cap is 140 Mpixel/s, which lets
  1920x1200@60 through a USB-C to HDMI adapter (154 MHz) work.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Describe DCPEXT1 (ADT dcpext1: ASC at 0x502e00000, post-office
mailbox 7, IRQs 306/266, DARTs dart-dcpext1 SID 23 and dart-dispext1
SID 0) with its PMGR2 PSD admission register. Give each controller its
crossbar source, let DCPEXT0 and DCPEXT1 use the main DCP's USB-C port
children, and widen dp-clock to the PMGR ATC DP clock dividers of all
ATCs.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The firmware takes a mode as width, height and a 16.16 refresh rate and
picks the timing itself. For the EIZO EV2780 on a J873g rear USB-C port
it lists 2560x1440 twice near 60 Hz: the sink's detailed timing at
59.951 Hz (241.5 MHz, CVT reduced blanking) and a 60.000 Hz standard
mode it adds on its own (byte 0 bit 6), which it drives with CVT at
312.25 MHz (htotal 3488, vtotal 1493, an 89.5 kHz line rate).
dcpib_find_mode() compared whole Hz, so both matched the EDID's
2560x1440@59.951 and the first, the standard mode, won. The EV2780 does
not take that line rate and shows an error instead of a picture, while
the link trains and the sink's DP test CRC still counts frames.

Compare the DRM mode's exact rate, computed as drm_mode_vrefresh() does,
with the firmware's, and take the nearest within 1 Hz.

Tested on the J873g together with the following USB-C clock fix (before
it, USB-C does not offer 2560x1440@60): the EV2780 gets 2560x1440 at
241.5 MHz (htotal 2720, vtotal 1481) instead of 312.25 MHz and shows
the picture.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
USB-C modes above about 165 MHz pixel clock stayed black with no error:
the link trained, the firmware set the mode, and the monitor showed
nothing. So did 640x480 (25.2 MHz). The driver capped the ATC path at
140 and floored it at 20 Mpixel/s, which left 2560x1440 at 30 Hz.

The ATC's DP clock switch (ATCPHY_DP_CLKSWITCH_SELECT/ENABLE/STATUS at
the PHY's CFG block + 0x14/0x18/0x1c) chooses where each DP pixel clock
comes from. AppleT8152TypeCPhy::aciophy_configure_dp_clks programs the
PMGR DP clock divider for the link rate (setATCDPClkSrcSel), then
aciophy_configure_dp_clkswitch_control(pclk, rate) sets
SWITCHn_CLK_SELECT to n (PMGR DP clock n - 1), DPTX_OUT_CLKn_MODE to 0,
and the switch's PMGR enable (bit 1 + 7 * (n - 1)), and waits for the
matching status bit. The driver selected source 0 with enable bit 0
instead, so the stream clock never followed the divider. That is also
why changing the divider moved nothing but the link.

Select PCLK1 from PMGR DP0 after the divider is written, and stop it
the same way. Drop the pixel-rate cap and floor.

Tested on the J873g with an EIZO EV2780 on a rear USB-C port (two
lanes at HBR2): 2560x1440@59.951 (241.5 MHz) shows. For 640x480@60,
@59.94 and 720x480 the link trains and the sink's DP test CRC (DPCD
0x246 TEST_CRC_COUNT) advances once per frame, stable for a still
picture and changing with the content. A USB-C to HDMI adapter
(1920x1200@59.95) and HDMI are unchanged.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
dcpib_mode_fits() measured a mode against the lane count of the last
link training. That is not the link's capability: when an EIZO EV2780
on a rear USB-C port drops and reasserts HPD while the display is off
(it does so a few seconds into its power save), the firmware trains the
link without a stream, with a single lane. 2560x1440@60 then no longer
fits one HBR2 lane, the atomic check refuses it, and the display stays
off when the compositor powers the outputs back on.

Use the lane count the firmware may train, which GET_MAX_LANE_COUNT
already reports: the USB-C route's from the DP alt mode pin assignment,
four for the other phys. The link rate in the same check is already the
PHY's maximum rather than the trained one.

Tested on the J873g: the stuck state had trained_lanes 1 on DCPEXT0
with the EV2780 at 2560x1440@59.951; with the fix, a display-off cycle
with a PD disconnect and reconnect of that monitor in between brings all
three outputs (two USB-C, HDMI) back at their modes.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
When the driver wakes an unused DCPEXT (apple,rtkit-wake), the firmware's
oslog endpoint offers a 0x5ff8-byte ring at 0x100033cc000: the log
segment of its own firmware, addressed with the coprocessor's DRAM tag
in bit 40. Only the firmware's retained DART tables map it, not the
domain Linux has for the controller, so iommu_iova_to_phys() found
nothing, the shmem setup failed with -ENOMEM and RTKit logged a failed
buffer request on every boot. With the request failed, the oslog buffer
stayed unset and RTKit rejected the firmware's write counters as invalid
instead of acknowledging them, which AppleDCP waits for before AP power
transitions.

Linux never reads that ring. Through the endpoint-aware shmem hook, take
an oslog ring the domain cannot translate as the firmware's, without a
CPU mapping; RTKit sends no reply for a mapped buffer, and aura sends
none for this request either. Other endpoints still fail without a
mapping. The destroy hook skips the unmap for such a buffer.

Tested on the J873g: both DCPEXTs wake without the buffer error or an
invalid oslog notification, and a display off/on cycle brings both USB-C
outputs and HDMI back.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…tart

The J873g HDMI port works only if the bootloader brought it up. For the
driver to start it itself, the HDMI node needs the PMGR2 PSD service of
the dptx-phy (phy-psd), the phy tunables from the ADT (apple,tunable-phy),
and the SMC writes that power the PS190 DisplayPort-to-HDMI converter
(apple,smc, apple,pcon-power). The phy's PMGR power state is no longer
only read.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The driver only drove HDMI that the bootloader had powered up, tuned and
trained, and gave it to the DCP the bootloader had wired to the phy.
After a boot without an HDMI monitor (the bootloader's HDMI setup fails
and leaves the PLL unlocked) or with a USB-C display on the main DCP, no
DCP took HDMI, and a monitor plugged in later stayed dark.

Make such an HDMI port one of the shared ports. A DCP that may feed the
phy (the main DCP or DCPEXT0, the source selects aura uses) and drives
no USB-C display takes it when its HPD line goes high: it gives up its
claim on a powered-down USB-C port, switches its phy operations, crossbar
endpoint and HPD source to HDMI, and runs the existing plug path. The
phy starts from cold the way aura's dptx_t8152_activate does: PMGR and
PSD power, the PS190 powered through the SMC, source select, PLL, AUX
and phy power, the ADT tunables, PLL and phy activation, four lanes and
the impedance calibration. As with the bootloader's HDMI, the link is
then kept up across display off. Once the sink is gone and the plug path
has released the link, the DCP gives the port back and polls its USB-C
ports again. The HPD line is requested once and shared by the DCPs that
may take the port. The connector stays a DisplayPort one.

Tested on the J873g with two USB-C EIZOs and an HDMI EV2780: booted
without HDMI, the main DCP and DCPEXT1 drive the USB-C monitors; HDMI
plugged in later, DCPEXT0 takes the port, starts the phy from cold and
runs 2560x1440@60 at HBR3 within 0.6 s. Unplugged, the port is given
back; plugged again, it is taken and the mode set without a cold start.
A boot with HDMI connected keeps the bootloader's HDMI as before.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Give the HDMI node the dptx-phy's PSD service (5), the SMC writes that
power the PS190 (ADT dp2hdmi-gpio0 function-dp2hdmi_pwr_en and
function-hdmi_pwr_en, SMC key pcIO) and the dptx-phy tunables from the
ADT, so that apple_dcpib can start HDMI without the bootloader.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The driver powered the PS190 DisplayPort-to-HDMI converter through the
SMC only when a DCP took the shared HDMI port, and a DCP takes the port
once the HDMI HPD line goes high. The PS190 drives that line only while
it is powered. The AP AUX controller that reads the USB-C monitors' EDID
also gets no reply from any USB-C port while the PS190 is off: every
request ends with AUX channel status 2, a timeout. Both only worked
because the bootloader's HDMI setup had already powered the PS190.

When the bootloader's display setup failed before that point, Linux
never saw the HDMI monitor, and the USB-C monitors came up without an
EDID, at 1920x1080 and 1680x1050 instead of 2560x1440 and 1920x1200.

Power the PS190 when the shared HDMI port is set up in probe, before the
DCP is started. If the SMC is not bound yet, defer the probe.

Tested on the J873g with the bootloader's internal DCP start failing on
purpose (AFK init after the RTKit boot), with HDMI and two USB-C EIZOs
connected. Before this change: HDMI HPD low, and the EDID reads failed
on both USB-C ports. Writing the SMC values by hand made HPD go high
within 200 ms, and DPCD and EDID then read fine on both ports. With
this change the same boot brings up HDMI at 2560x1440@60 on the main
DCP, and the USB-C monitors at 2560x1440@60 and 1920x1200@60, each from
its EDID.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Only the main DCP and DCPEXT0, the two source selects aura uses, took
the shared HDMI port. After a boot without the bootloader's HDMI, a
monitor plugged into HDMI later stayed dark whenever the main DCP and
DCPEXT0 held the two USB-C monitors. Which DCPs end up with those
depends on which one polls first when the slower monitor shows up.
DCPEXT1 was then free but could not take the port.

The phy's source select also takes DCPEXT1's crossbar endpoint, 2.
Share the port with every DCP.

Tested on the J873g, booted without HDMI, with a test build in which
only DCPEXT1 takes the HDMI port and DCPEXT1 stays off the USB-C ports.
The main DCP and DCPEXT0 drove the two USB-C EIZOs. With HDMI plugged
in, DCPEXT1 took the port, started the phy from cold with source select
2, trained four lanes at HBR3, read the EDID and ran 2560x1440@60. The
monitor showed the desktop.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The loader reports whether the internal DCP's RTKit was running at the
hand-off (1) or whether it quiesced the coprocessor after a failed
display setup (0). apple,dcp-rtkit-quiesced carries the same values
under a name that reads the other way round, so the T8152 loader and
apple_dcpib use this name instead.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…ning

The loader now publishes the internal DCP's RTKit state at the hand-off
as apple,dcp-rtkit-running, 1 running and 0 quiesced, the values that
apple,dcp-rtkit-quiesced carried under a name that read backwards.
Read the new name. A loader that publishes neither falls back to the
existing check for the older J873 loader build.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan force-pushed the thomas/j873-three-displays branch from 6f320f0 to 3207499 Compare November 19, 2026 18:24
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.

5 participants