Repository navigation
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
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>
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>
…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>
…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>
…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 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 DCP driver use this name instead. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A T8152 Gen3 DART reports a fault as a v2 DART does: a bitmap of the streams with a pending exception at 0x4000, a record per stream at 0x8000 (status, address), acknowledged by writing the bitmap back. Request its interrupt and let apple_dart_t8110_v2_irq() report and acknowledge its faults instead of leaving them to the firmware. Only the unlock after a lock-on-error exception differs: a Gen3 DART's TLB command register serves translation queries, so it is not used to unlock. A Gen3 DART with lock-on-error set says that its stream stays stopped. The J873g's Gen3 DARTs have it clear. Tested on the J873g by clearing the AVD DART's SID 0 TTBR during an H.264 decode: one interrupt, "translation fault: SID:0 write TTBR invalid at 0x10fff000000 (status 0x00000100)", the bitmap acknowledged with no repeat, and the decoder retired by its recovery path. After the TTBR was restored and the decoder reloaded, the same file decoded bit-exact again. None of the other eight Gen3 DART fault lines fired, including those of the locked display DARTs with three displays running. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
afk_init() picks the AFKv2 wire for firmware 27 and for the T8122 external processor on 26.x, both recognised by their IOMFB interface. The T8152 DCP firmware speaks AFKv2 on every endpoint of its iBoot interface (the display service, the DPAV controller services and the DPTX port services), and drm/apple drives no IOMFB interface of it that a version could key on. Add hw.afk_v2, which selects AFKv2 for all endpoints of a processor. No match entry sets it yet. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 DCP does not acknowledge AP QUIESCED, and an IOP INIT while
its AP power is still on panics the firmware ("Invalid AP power: 32").
A session the bootloader leaves running can only be taken over as it
runs, with apple_rtkit_init_adopted(), without the HELLO/EPMAP
handshake: the endpoint map went to the bootloader, and
apple_rtkit_start_ep() refuses an endpoint RTKit does not know.
Add hw.afk_adopt_endpoints. With it afk_start() registers the endpoint
with apple_rtkit_adopt_ep() before it sends anything to it, so its
START_EP goes out and its replies are not taken for an unknown
endpoint's. No match entry sets it yet.
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A bootloader that drives the display through the DCP firmware can leave AFK endpoints running with its scanout when it hands over, as the T8152 loader does with the iBoot interface's endpoints. An AFK INIT on a live endpoint asserts in the firmware. Add dcp->afk_live_endpoints, bit N for endpoint 0x20 + N, which a processor's probe fills from such a hand-off (the T8152 loader's apple,afk-active-endpoints). afk_start() sends an endpoint whose bit is set a SHUTDOWN and waits for its acknowledgment before START_EP and INIT, after registering it with an adopted RTKit session so that the acknowledgment is not taken for an unknown endpoint's. The old session's ring stays the bootloader's, which keeps it reserved. The mask is zero on every processor that sets nothing, so their start is unchanged. The stop of the live endpoints is based on a change by Acelogic for the T8152 hand-off. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
afk_send_command() allocates a reply buffer of the output length and names it in the command, even for a length of zero. The AFKv2 setters of the T8152 DCP firmware's iBoot interface (SET_POWER, SET_MODE, SET_SURFACE) answer with a transport status alone. Given a reply buffer, the firmware copies an empty reply into it and asserts. Give a command without output no reply buffer: its descriptor carries address and length zero, which the AFKv2 codec already accepts and checks the reply against. Every current caller passes an output length, so none of them changes. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
afk_recv_handle_init() parses the properties that follow a service's announced name whenever there are any, and matches the service by the EPIC provider class found there. Which keys it accepts depends on the firmware interface version. The T8152 DCP firmware's iBoot service (disp0-service, dispext-service) is announced by name alone, and the properties of its DPTX and DPAV services are not needed to drive it: a property set the parser rejects would leave such a service unopened. Add hw.afk_announced_names. With it the properties are not parsed, the service is matched by its announced name, and that name is what its handler gets as the EPIC name. No match entry sets it yet. The startup host test's and the apple-dcp service rebind test's processors gain the flag, and the latter kstrdup(). The provider admission test looks for the announcement's OPEN in the first 7000 bytes of afk_recv_handle_init() instead of 6500, which no longer reach it. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
An announced service that no entry of its endpoint's ops table names is left unopened, apart from two firmware-specific exceptions that bind it to the endpoint's first entry. The T8152 DCP firmware's DPAV controller endpoint announces four services and expects all of them to be opened, among them dcpav-video-interface, whose opening starts the firmware's idle power off timer for the display. None of them takes commands from the host. Add ep->unmatched_ops, bound to every announced service that no entry of the endpoint's ops table matches, which is then opened and initialised like a matched one. It is NULL on every existing endpoint, whose unmatched services stay unopened as before. The startup host test's and the apple-dcp service rebind test's endpoints gain the field. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
AFK waits one second for an endpoint to start or stop and for a command or service call to be answered. The T8152 DCP firmware's iBoot display commands answer only once the DisplayPort work they start is done: SET_POWER and SET_MODE wait for the link training, during which the firmware calls into the AP for the PHY. The T8152 displays have been run on the hardware with three seconds for each of these. Add hw.afk_timeout_ms, the time afk_start(), afk_shutdown(), the inherited endpoint stop, afk_send_command(), afk_service_call() and afk_service_call_len() wait. Zero keeps one second, so every processor that sets nothing waits as before. Callers that pass their own timeout, and the legacy reply-length calls, are unchanged. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
ibootep.c sends the iBoot interface's display commands only for the T6030 external role's first-pixel diagnostic: the queries and setters are reachable from its sysfs file and pattern path alone, gated on dcp->external, and the surface is set through the swap operations 15/16/18/19. The T8152 DCP firmware is driven through this interface alone and sets its surface with operation 1, SET_SURFACE. - Add DCP_FIRMWARE_IBOOT, a DCP driven through the iBoot interface alone, and dcp_is_iboot(). No match entry selects it yet. - Build SET_SURFACE (operation 1, one 164-byte layer) and the three queries in iboot_build_pattern_request(). - Export ibootep_set_power(), ibootep_get_hpd(), ibootep_get_timing_modes(), ibootep_get_color_modes(), ibootep_set_mode() and ibootep_set_surface(), with the mode records in ibootep.h. On AFKv2 the setters go out without a reply buffer, as the firmware asserts on one, and a reply is checked against the length the transport reports, through the new afk_send_command_len(). SET_SURFACE scans out one linear BGRA plane in colour space 2, as the bootloader sets it on T8152. - Open the service for a DCP_FIRMWARE_IBOOT processor under either of its names (disp0-service on the main DCP, dispext-service on the external ones), without the manual query file: its display driver sends every command. The T6030 external role keeps its gate, its service name, its sysfs file and its pattern and frame commands as they were. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 (Mac mini J873g) DCPs drive their displays through hardware no subsystem driver covers yet: the rear USB-C ports' ATC PHYs have no DisplayPort mode in drivers/phy/apple/atc.c for T8152, the HDMI port's DisplayPort PHY has no T8152 type in drivers/phy/apple/dptx.c (its lanes are 0x2800 apart from 0x4500), the PS190 DisplayPort-to-HDMI converter behind it is powered through the SMC, the ports' ACE3 PD controllers do not report to the Type-C route layer, and the DCP firmware's iBoot interface does not hand out the sink's EDID. Add the T8152 code for them as separate files, each marked interim until atc.c's DisplayPort mode, tipd and the Type-C route layer take over. The bootloader trains the displays before Linux starts; the PHYs keep its setup and reprogram what a link training changes, as the DCP firmware calls into the AP for them. t8152_atc.c, the USB-C ports: - The three DCPs share the three rear ports through the one display crossbar. A DCP claims a free ATC under a mutex and gives it up on unplug; a monitor stays with its DCP while userspace blanks it. The crossbar's upstream reset, clock and enable fields are indexed by DCP endpoint * 2 + DPTX port, independently of the downstream DFP0 mux fields, which select that endpoint. - Each ATC has its own PMGR DP clock divider, at 0x300020044 + 8 * n. - The ATC's DP clock switch (PHY CFG block + 0x14 select, + 0x18 enable, + 0x1c status) chooses where each DP pixel clock comes from. PCLK1 is switched to PMGR DP clock 0 (select field 1, enable and status bit 1) after the divider for the link rate is written, and switched off the same way. With source 0 selected the stream clock never followed the divider: modes above about 165 MHz pixel clock, and 640x480, stayed black while the link trained and the firmware set the mode. - A monitor that also carries USB3 negotiates pin assignment D (data status bit 5): two DisplayPort lanes, and only the PMA that carries them is set up. GET_MAX_LANE_COUNT reports the route's lanes. - A cold start powers the ATC's dependencies (USB AON, the common PSD, both DP power states), the common block and AUX, and starts the lanes at HBR at once: from cold, AUX only works with the DP PLL and PMAs running. A power down undoes what it powered up. - The EDID is read through the AP AUX controller aux0, which the three DCPs share and take in turn; its output select for an ATC port is the ATC instance * 3 + its local DFP. t8152_hdmi.c, the HDMI port: - The bootloader wires the HDMI PHY (source select, APB 0x10) to the main DCP (0) when no USB-C display is attached at boot, and then never starts DCPEXT0; next to a USB-C display it wires DCPEXT0 (1). The source select is read only while the PHY's PMGR power state is requested and active: a USB-C-only boot leaves the PHY off, and a read of its registers then raises an SError. - When the bootloader left HDMI off (no monitor at boot leaves its PLL unlocked), the HDMI port becomes one of the shared ports. A DCP that drives no USB-C display takes it when the HPD line goes high, starts the PHY from cold (PMGR and PSD power, the PS190, source select, PLL, AUX and PHY power, the tunables, PLL and PHY activation, four lanes, impedance calibration), keeps the link up across display off, and gives the port back once the sink is gone. The source select takes every DCP's crossbar endpoint, DCPEXT1's 2 included, so DCPEXT1 takes the port while the other two drive USB-C monitors. The HPD line is requested once for all of them. - The PS190 is powered through the SMC when the port is set up, before anything reads HPD or an EDID: it drives the HPD line only while it is powered, and while it is off every AUX request on the USB-C ports ends with channel status 2 as well. Without the SMC bound yet, the setup is deferred. t8152_aux.c: the AUX controllers' request framing. Bits 21:8 of the retry register are a 14-bit reply timeout, set to 3200; read as a three-bit delay, the EDID through a USB-C to HDMI adapter timed out. A sink left in D3 is woken before DDC. t8152_pd.c: the ACE3 plug, orientation, DP alt mode and HPD state over SPMI, read through the logical register window under the SPMI device's lock, which the USB4 port monitor takes as well. A controller in power state 7 enters alt mode only after SSPS 0. A sink that stopped answering AUX after a monitor's deep sleep comes back after a reset (Gaid) and SSPS 0. t8152_dptx.c: the DPTX port service's calls into the AP apply link rate, lanes and drive settings to these PHYs and read the drive settings back as they were set; an unsupported GET_DRIVE_SETTINGS was followed by a firmware crash. The port's release is group 8 command 7, and its HPD call (group 8 command 8) carries a status in its reply's first word. dptxep.c serves the same calls for PHY framework PHYs, the crossbar mux and Thunderbolt tunnels; its connect and display request, its call numbers and its port records are used here. The HDMI PHY's power state check is based on a change by Acelogic. The files are built with the new DRM_APPLE_DCP_T8152, enabled in asahi.config, and nothing uses them yet. A MAINTAINERS entry for the T8152 display covers them and the binding. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A caller that needs an endpoint's services, or the state one of their init callbacks sets up, can only poll for them. Give each endpoint a wait queue that is woken once a service has opened and its init callback has run, on each path that opens one: compact, AFKv2 and a deferred AFKv2 open. The host-test fixtures that build those paths get the wait queue too. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8152 (Mac mini J873g) DCP firmware offers a small display service, disp0-service on the main DCP and dispext-service on the DCPEXTs, next to its IOMFB interface. The bootloader drives the J873g displays through it, with the DPTX port service that the firmware calls into the AP for the PHY and the DPAV controller services it expects to be opened, all over AFKv2. Add these DCPs to drm/apple as the DCP_FIRMWARE_IBOOT variant, matched by apple,t8152-dcp-iboot, with the shared AFK code and the iBoot commands of ibootep.c. The match data selects AFKv2 on every endpoint, endpoints registered with an RTKit session taken without its map, services matched by their announced name and a three-second AFK timeout. dcp_platform_probe() hands such a DCP to iomfb_iboot.c. Taking the session over: - A running session is adopted without the RTKit handshake (apple_rtkit_init_adopted(), apple_rtkit_adopt_running()): the DCP does not acknowledge AP QUIESCED, and an IOP INIT while its AP power is on panics it. A session the loader quiesced after a failed display setup (/chosen apple,dcp-rtkit-running = 0; the older J873 loader build v0.1.0-259-ga30a589a predates the property and is recognised by its 640x1136 placeholder framebuffer) is woken instead, and so is an unused DCPEXT the loader marks apple,rtkit-wake, once its PSD reads powered (a read of the coprocessor while it is gated hangs the machine) and its CPU runs. - The loader's AFK endpoint hand-off (apple,afk-active-endpoints) is required and fills dcp->afk_live_endpoints, so afk_start() stops each endpoint the loader left running: an AFK INIT on a live endpoint asserts in the firmware. Without the property there is no telling whether an endpoint is live, and the DCP is not taken over. - A woken DCPEXT'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, which only the firmware's retained DART tables map. With that buffer request failed, RTKit rejected the firmware's write counters as invalid instead of acknowledging them, which the firmware waits for before AP power transitions. The ring is taken as the firmware's, without a CPU mapping; the other buffers go through drm/apple's RTKit shared memory hooks. The surface log lines go to the debug level. - Once the session is taken it is retained until reboot like the other live sessions (dcp_retain_live_session(), split out of dcp_pin_live_session()). A failed start stops the endpoint work, detaches RTKit with its buffers kept and leaves the device bound, so nothing retries over a partly started session. Starting the display: - A new iBoot session has no surface, and a pipe that still runs then fetches from a null base (IOMFB axi_rd_err, firmware NMI): the display is powered off at once and powered on only after a SET_SURFACE. - The DPAV controller endpoint's four services are opened without a handler. Opening dcpav-video-interface starts the firmware's idle power off timer: a powered display without a following SET_MODE counts as idle, and the firmware takes the link down 30 s later, as it did with HDMI 30 s after boot while the compositor still had the output on. SET_MODE is sent again a second after that interface opens, from a work outside the AFK receive queues. - The DPTX port services are bound in the order they are announced. On USB-C the inherited DPTX link is released before the first connection. - The DCP fetches through dart-dcp and the display pipe scans out through dart-disp0; both are locked, with live roots of their own. One domain over both would publish dart-dcp's root into dart-disp0 and drop the bootloader's scanout mappings, so 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 below any range the firmware already maps there (a buffer mapped over one flickered). They are written through a write-combined mapping: the pipe does not snoop the CPU caches. - The bootloader's simple-framebuffer is taken over. KMS (iboot_drm.c), one DRM device per DCP: - Changing the surface between Linux buffers made later SET_MODEs crash the firmware. Three scanout buffers of at least 3840x2160 are allocated at probe; a frame's damage is copied by the CPU into one that is not on screen, which SET_SURFACE then shows, at most once per refresh by an hrtimer: there is no vblank interrupt, and several swaps within one refresh let an older frame stay on screen. The pitch is 64-byte aligned, as the firmware refuses an unaligned one. - The firmware takes a mode as width, height and a 16.16 refresh rate and picks the timing itself. The modes are the sink's EDID modes the firmware also lists, or the firmware's list with CVT timings. A DRM mode is matched to the firmware mode nearest by the exact refresh rate, within 1 Hz: next to an EIZO EV2780's 2560x1440@59.951 (241.5 MHz) the firmware lists a 60.000 Hz standard mode of its own (byte 0 bit 6), which it drives at 312.25 MHz and the monitor does not take. - The EDID is read through the AP's DisplayPort AUX controllers while the firmware does no AUX itself, since the iBoot interface does not hand it out. - A mode must fit the lanes the route may train, as GET_MAX_LANE_COUNT reports them, not those of the last training: a monitor that drops and reasserts HPD while the display is off is trained without a stream on a single lane, and 2560x1440@60 then failed the atomic check when the outputs came back on. - Right after power on the firmware still trains the link and fails SET_MODE; it takes the mode once the link is up, so SET_MODE is retried. The colour mode is the deepest valid one up to 32 bpp, as SET_MODE refuses the deeper ones the HDMI converter offers. - USB-C hotplug is polled from the PD controllers every 250 ms, HDMI from the converter's HPD line. An unplug releases DPTX and powers the PHY down, a sink that no longer answers after a monitor's deep sleep gets a fresh DP alt mode entry at most once a minute, and a quick reconnect restores a CRTC that was enabled. - drm/apple's per-DCP DRM device of dcpext_drm.c and dcpext_scanout.c does not fit: it is the T6030 external role's diagnostic, with one fixed 3840x2160 mode and the swap operations instead of SET_SURFACE. The DRM driver is named "apple-dcpib" (DCP iBoot interface), apart from the display subsystem's "apple"; appledrm.iboot_buffered=0 copies frames into the buffer on screen instead. Removal, shutdown and system sleep leave the firmware session alone. An unbind unplugs the DRM device, releases its committed state without touching the firmware, and detaches RTKit; the session stays retained, and a new bind is refused until reboot. The live endpoint hand-off and the retained failed start are based on changes by Acelogic. Tested on the J873g with HDMI and two rear USB-C monitors: all three come up, HDMI-A-1 at 2560x1440@59.951, DP-1 at 2560x1440@59.951 and DP-2 at 1920x1200@59.950. DPMS off and on works on each output, and so does HDMI at 1920x1080 and back. mpv runs fullscreen at 60 fps with no dropped frame after the first five. Unbinding DCPEXT1 removes its DRM device without a warning, and a new bind is refused with -EBUSY. Earlier runs of the same display code on the J873g: booted without HDMI, a monitor plugged in later is taken by a free DCP (DCPEXT0, and in another run DCPEXT1 with source select 2), which starts the PHY from cold and runs 2560x1440@60 at HBR3, DCPEXT0 within 0.6 s; with the bootloader's DCP start failing on purpose, HDMI and both USB-C monitors come up at their EDID modes; woken DCPEXTs log no buffer error. 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>
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>
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 the DCP driver can start HDMI without the bootloader. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The display coprocessor has a power state of its own, which its DARTs follow. Allow the node to name it. 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 six J873g display DARTs named none. Their engines are the display coprocessors, whose PMGR states are DISP_CPU (dcp), DISPEXT0_CPU (dcpext0) and DISPEXT1_CPU (dcpext1) in the 26A434 ADT. The AP does not switch those: a coprocessor is started through its PSD service (coproc-psd), and its firmware runs the state; Linux only reads DISPEXT0_CPU (coproc-ps). So they are described as firmware-owned: the OS keeps them on and never reads or writes them, which leaves the display hand-off and the HDMI cold start as they are. The coprocessor nodes name the same state as their DARTs. DISP_CPU sits at PMGR offset 0x14000 (it reads 0x0f0000ff on J873g, as DISPEXT0/1_CPU do), past the 0x14000 the PMGR node described, so the node now spans the ADT's 0x1c000 PMGR window. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The iBoot interface has no vblank interrupt, so the CRTC set no_vblank and the atomic helpers completed every page-flip event right after the commit. A compositor then gets its flips back as fast as it can commit and renders, and asks its clients to render, at whatever rate the commits complete instead of once per refresh. The plane update still shows at most one new frame per refresh (swaps are spaced one refresh apart), so the extra frames are drawn and copied for nothing and the animation advances unevenly. Use the DRM vblank timer (drm_vblank_helper): drm_vblank_init(), the timer-backed enable/disable/timestamp functions, and drm_crtc_vblank_atomic_flush() to arm each commit's event for the next tick at the mode's refresh rate. The CRTC switches the timer on at the end of atomic_enable and off at the start of atomic_disable. The timer is not locked to the firmware's swaps. The flip timestamps and the vblank sequence (and so the wp_presentation_feedback a compositor derives from them) are the timer's ticks at the mode's rate, not measured scanout times: they can be up to one refresh away from when the frame actually showed. That is enough for pacing; a reader of presentation feedback on this path should not take them as scanout times. A commit that leaves the CRTC off still sets no_vblank. The commit tail (commit_tail_rpm) does not flush an inactive CRTC, so nothing arms its event; with no_vblank, drm_atomic_helper_commit_hw_done() sends it. Without that, commit_hw_done warns that the event was not consumed. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
sithglan
force-pushed
the
thomas/j873-displays-vblank
branch
from
November 22, 2026 14:50
1e4e7d5 to
3366cb6
Compare
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.
Stacked on #1800 (J873g displays through the iBoot interface). Review the last commit.
The iBoot interface has no vblank interrupt. The CRTC therefore set
no_vblank, and the atomic helpers completed every page-flip event right after its commit. A compositor gets those flips back as fast as it can commit, so it renders, and has its clients render, at that rate instead of once per refresh. Plane updates are still shown at most once per refresh, since swaps are spaced one refresh apart. The extra frames are drawn and copied for nothing, and animations advance unevenly.This commit uses the DRM vblank timer (
drm_vblank_helper):drm_vblank_init(), theDRM_CRTC_VBLANK_TIMER_FUNCSenable/disable/timestamp hooks, anddrm_crtc_vblank_atomic_flush()arm each commit's event for the next tick at the mode's refresh rate.atomic_enableand stops at the start ofatomic_disable.no_vblank.commit_tail_rpmdoes not flush an inactive CRTC, sodrm_atomic_helper_commit_hw_done()sends that event as before. Without this,commit_hw_donewarns that the event was not consumed. A first version without it hit that warning, and DP-2 hitflip_done timed outafter a failedset_mode.Tests (M6 Mac mini, J873g).
3306da7cplus its stacked PRs), pmdomain: apple: T8152 PSD services as power domains #2459, arm64: errata: treat the T8152 vGIC SEIS as broken (KVM guests on the J873g, M6 Mac mini) #1794 and this commit. Kernel 7.3.0-aurora-j873-prs2459+, sway on DP-1 (2560x1440) and DP-2 (1920x1200).flip_doneorcommit waittimeout.wp_presentation_feedback, run mostly one refresh apart: 602 of 674. Before, Chromium's buffer intervals spread from 4 to 52 ms.flip_donetimeout.make W=1 drivers/gpu/drm/apple/iboot_drm.obuilds without warnings.cc @DjDeveloperr @RyanTheTide @Acelogic @LiamRay10
Assisted-by: LLM (Claude:Opus 5.5)