Skip to content

arm64: apple: T8140/J700 platform prerequisites (reworked) - #10

Merged
RyanTheTide merged 35 commits into
aurora-wipfrom
series/neo-prerequisites-20260924
Sep 25, 2026
Merged

RyanTheTide merged 35 commits into
aurora-wipfrom
series/neo-prerequisites-20260924

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Shared T8140/J700 platform prerequisites for the audio, AOP and ISP drivers, reworked after the 2026-09-25 maintainer audit and rebased onto aurora-wip (which now carries the reworked RTKit series from #20).

What changed since the audited head (021cafc)

  • Four generic fixes are now standalone patches with Fixes: tags instead of being buried in feature commits: the tipd Makefile descent, the mailbox send-empty IRQ enable balance, the PMGR power-state timeout message, and the DART devm_memremap() error-pointer check.
  • The five core bindings (apple.yaml, apple,pmgr, apple,pmgr-pwrstate, apple,aic2, apple,wdt) are Yureka Lilian's A18 Pro v2 patches applied from lore with their Acked-by/Reviewed-by, instead of our re-typed copies. Every other binding is its own patch and precedes its driver.
  • pinctrl: the apple,no-regcache DT property is gone; the T8140 behaviour is match data on apple,t8140-pinctrl.
  • admac: no apple,admac fallback compatible (the T8140 register layout is not compatible).
  • pmgr: the apple_pmgr.no_auto_probe boot knob and the sync_state override are dropped; the driver behaves as upstream on every SoC.
  • DART: TLB range commands use ilog2(dart->pgsize) instead of a hard-coded 14.
  • The Rust mailbox wrapper's fixes are a separate patch from the C driver's T8140 variants; the RTKit C-side duplicate of soc: apple: rtkit: retained ownership and adoption of a running co-processor (J700 ANS groundwork) #20 is gone.
  • DTS: comments reworded; the Documentation/arch/arm64/*.rst memo is dropped; a dedicated APPLE T8140 SOC AND J700 (MACBOOK NEO) SUPPORT MAINTAINERS entry replaces additions to the Asahi block.
  • Every commit: author is Ryan Murray [email protected] (matching the Signed-off-by), contiguous trailer block, wrapped bodies with the hardware facts.

Checks on every commit: W=1 C=1 (upstream sparse) compile of the touched objects, checkpatch --strict --codespell, dt_binding_check on all changed schemas, CHECK_DTBS=y apple/t8140-j700.dtb. The only remaining dtbs_check complaints are the five CS42L83 supplies (VA, VP, VCP, VD_FILT, VL) whose board rails are still unidentified; as before, no regulator phandles were guessed, and this stays an explicit downstream exception.

Not booted on the J700 in this form. A boot test of the merged aurora-wip is planned once #21 and #22 land.

Dependent PRs: #11 (AOP/ALS), #12 (ISP) and #23 (DT) are based on this branch; retarget them to aurora-wip once this merges. Their review findings are not addressed here.

🤖 Generated with Claude Code

RyanTheTide and others added 21 commits September 26, 2026 00:24
The TPS6598x core (CONFIG_TYPEC_TPS6598X_CORE) is a separate tristate
that both bus transports select: the I2C one (CONFIG_TYPEC_TPS6598X)
and, since commit 550afd1 ("usb: typec: tipd: Add sn201202x
support"), the SPMI one (CONFIG_TYPEC_SN201202X). tipd/Makefile builds
the core and each transport from its own symbol, but
drivers/usb/typec/Makefile still descends into tipd/ only for
CONFIG_TYPEC_TPS6598X.

With CONFIG_TYPEC_SN201202X=y and CONFIG_TYPEC_TPS6598X=m the core is
built in, but tipd/ is entered only as a module directory: the built-in
core and SPMI transport never reach vmlinux, and modpost fails on the
tps6598x module's references to tipd_init() and the other symbols the
core exports. With CONFIG_TYPEC_TPS6598X=n the SPMI transport is not
built at all.

Descend into tipd/ on CONFIG_TYPEC_TPS6598X_CORE, which is set whenever
either transport is enabled.

Fixes: da16cc9 ("usb: typec: tipd: Factor out i2c specifics")
Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The send-empty interrupt is requested with IRQF_NO_AUTOEN.
apple_mbox_send() enables it when the A2I FIFO is full and it has to
wait, and the interrupt handler disables it again when it fires. When
the wait times out or is interrupted by a signal, apple_mbox_send()
returns with the interrupt still enabled, so the next send that has to
wait calls enable_irq() on a line that is already enabled. The IRQ core
warns about the unbalanced enable, and from then on the enable state no
longer tracks whether a sender is waiting. On T8140 this shows up as
"Unbalanced enable for IRQ" warnings from the SEP hwrng thread, whose
sends can wait longer than the 500 ms timeout.

Track whether the interrupt is unmasked in struct apple_mbox, protected
by tx_lock. The sender enables it only while it is masked, the handler
disables it only while it is unmasked, and a sender whose wait failed
disables it unless a late interrupt already has. Disabling it
unconditionally on the error path would not work: the handler may
already be waiting for tx_lock and would then disable it a second time.

Fixes: 6e1457f ("soc: apple: mailbox: Add ASC/M3 mailbox driver")
Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Commit c300d1b ("soc: apple: pmgr: Add force-disable/force-reset")
changed the transition poll in apple_pmgr_ps_set() to read into cur,
but left the timeout message printing reg, which now holds the value
that was written. Since then the "now:" field shows what was requested
rather than the state the domain is stuck in.

Print both the value written and the last value read back. On T8140,
audio_leap_mca occasionally misses the 100 us poll window, and the
read-back value (0xa4f: BUSY set, ACTUAL clock-gated, TARGET active) is
what tells a slow transition from a failed one.

Fixes: c300d1b ("soc: apple: pmgr: Add force-disable/force-reset")
Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
apple_dart_hw_map_locked_ttbr() maps the L1 table of a locked DART
stream with devm_memremap() and checks the result for NULL, but
devm_memremap() never returns NULL: it returns ERR_PTR(-ENOMEM) or
ERR_PTR(-ENXIO) on failure. A failed mapping was therefore stored as
the table pointer, and apple_dart_hw_sync_locked() then wrote the
page-table entries through it and apple_dart_hw_unmap_locked_ttbr()
passed it to memset().

The NULL check was added together with the locked-DART page-table code
by commit 0d4ec07 ("iommu/dart: Add iommu_ops for locked DARTs"),
and became reachable once locked DARTs were allowed to probe.

Check the result with IS_ERR() and return the error, so that no error
pointer is ever stored.

Fixes: 85322eb ("iommu/dart: Support locked DARTs")
Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The PMGR blocks on the Apple silicon A18 Pro SoC (t8140) is compatible
with the M1-M4 SoCs. Add "apple,t8140-pmgr" as A18 Pro specific
compatible.

Signed-off-by: Yureka Lilian <[email protected]>
Acked-by: Rob Herring (Arm) <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The device power state management of the PMGR blocks on the Apple
silicon A18 Pro SoC (t8140) is compatible with the M1-M4 SoCs.
Add "apple,t8140-pmgr-pwrstate" as A18 Pro specific compatible.

Signed-off-by: Yureka Lilian <[email protected]>
Acked-by: Rob Herring (Arm) <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The Apple t8140 (A18 Pro) SoC uses an AIC3 as interrupt controller, same as
the M1-M4 SoCs.

Signed-off-by: Yureka Lilian <[email protected]>
Acked-by: Rob Herring (Arm) <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The watchdog on the Apple t8140 (A18 Pro) SoC is compatible with the
M1-M4 SoCs. Add "apple,t8140-wdt" as SoC specific compatible.

Signed-off-by: Yureka Lilian <[email protected]>
Acked-by: Rob Herring (Arm) <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The MacBook Neo is the first MacBook to use an A-Series Apple Silicon
SoC. The MacBook Neo is overall similar to the M4 series devices.

The iPhone 16 Pro is based on the same SoC, but Apple does not allow
users running a custom OS on this device.

Signed-off-by: Yureka Lilian <[email protected]>
Acked-by: Rob Herring (Arm) <[email protected]>
Reviewed-by: Sven Peter <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The I2C controllers of the A18 Pro (T8140) are compatible with the
T8103 ones; on the MacBook Neo the headset codec sits on i2c0. Add
"apple,t8140-i2c" with the "apple,t8103-i2c" fallback.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Add "apple,t8140-pinctrl" for the pin controller of the A18 Pro
(T8140), in the list of SoC compatibles that use the
"apple,t8103-pinctrl" fallback.

Some T8140 pins are reserved for other agents: Apple's device tree
lists them in no-restore-gpio-pins (pins 50 and 134 on the MacBook
Neo), and reading their registers from the application processor
raises an SError. Allow the standard gpio-reserved-ranges property so
that the device tree can describe them. gpiolib then refuses to hand
out those lines, and the driver keeps its T8140 register map away from
them.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The DARTs of the A18 Pro (T8140) are T8110-family instances. Add
"apple,t8140-dart" with the "apple,t8110-dart" fallback, and correct
the description: depending on the generation, a DART handles up to 256
streams, not 16.

A T8110-family stream can be remapped: its TCR selects another stream
(a 4-bit REMAP field plus an enable bit) whose translation and
filtering state it then uses, without a page-table root of its own.
Apple's device tree describes this with a "remap" property; on T8140
the ISP DARTs remap streams 1, 2, 6, 7, 10 and 11 onto stream 0. Add
apple,remap-streams, a list of <source destination> pairs. A source may
be listed only once, a destination is limited to 15 by the width of
the REMAP field and may not itself be remapped, and source and
destination must differ.

Also state that apple,dma-range must have a nonzero size, and that a
consumer binding may specify a window of its own, as the T8140 AOP, AOP
audio, AOP setup mailbox and ADMAC bindings do.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Add two compatibles for the A18 Pro (T8140):

 - "apple,t8140-asc-mailbox" joins the ASC v4 list. Its registers
   follow the v4 layout, but the application processor has to set an
   enable bit in the I2A control register before the mailbox is used,
   which the driver keys on this compatible.
 - "apple,t8140-aop-setup-mailbox" is the second mailbox of the
   Always-On Processor (AOP), its "setup port". It has a compact
   register layout of its own and only two interrupts, send-empty and
   recv-not-empty, so it has no fallback.

The setup port carries messages that refer to buffers mapped through
stream 1 of the AOP DART, whose root is owned by the AOP firmware.
Allow iommus and apple,dma-range, the host's allocation window within
that root, on the setup mailbox and require them there. The other
variants keep their four interrupts and take neither property.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The ADMACs of the A18 Pro (T8140) audio fabric keep the register layout
within each channel block but move the RX blocks: TX channel blocks sit
at 0x8000 + n * 0x200 and RX channel blocks at 0xc000 + n * 0x200,
where the earlier ADMACs interleave all channels from 0x8000. A driver
that only knows apple,admac or apple,t8122-admac would program the RX
channels at the wrong offsets, so add "apple,t8140-admac" without a
fallback.

The T8140 ADMACs sit behind the AOP DART, whose stream roots are owned
by the AOP firmware. Add an optional apple,dma-range property (base and
nonzero size) giving the host's allocation window for the controller's
stream; without it, the DART's aperture applies.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
On the A18 Pro (T8140) the ambient light sensor is read by the
Always-On Processor (AOP) firmware and exposed to the host as an AOP
service. Describe it as a child of the AOP node without resources of
its own: it has no MMIO window or interrupt, and its calibration is
loaded separately through the firmware loader rather than stored in
the device tree.

The "apple,aop-als" fallback is the compatible that the ALS nodes of
the other Apple SoCs (T8103, T8112, T600x, T602x, T603x and T8122)
already use. Those nodes have no schema, so a select keeps this T8140
schema from being applied to them through the shared fallback.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
isp-common.dtsi reserves the firmware heap of the Apple ISPs with an
"apple,asc-mem" node whose address and size are left zero for the
bootloader to fill in, but the compatible has no binding.

Document it: a no-map region holding memory that the bootloader set
aside for a co-processor it loaded, such as the ISP firmware heap. The
bootloader supplies the address and size, and records any IOVA mappings
the firmware relies on in iommu-addresses. The region is not a general
DMA pool, and the binding fixes no address or size.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Add a binding for the image signal processor of the A18 Pro (T8140),
which drives the MacBook Neo camera through firmware loaded by the
bootloader. The node describes:

 - four register windows: the co-processor block, the interrupt and
   doorbell registers ("mbox"), the firmware handshake registers
   ("gpio") and the capture watchdog ("wdt"), which the host has to
   service while streaming, or the frames carry a diagnostic fill
   instead of sensor pixels;
 - one interrupt, three DART streams and 14 power domains;
 - the bootloader-filled firmware heap (memory-region "heap");
 - apple,dart-vm-size, apple,platform-id, apple,temporal-filter and the
   sensor-presets node, which the existing Apple ISP nodes and the
   isp-*.dtsi sensor includes already use.

The "apple,isp" fallback is the compatible of the ISP nodes on T8103,
T8112, T600x and T602x, none of which has a schema; a select keeps this
T8140 schema from being applied to them.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Apple machines use the CS42L83, which this schema covers, as their
headset codec. Their device trees reference it as a DAI, with
"#sound-dai-cells = <0>", and prefix its controls with
sound-name-prefix = "Jack", but the schema has additionalProperties:
false and allows neither property, so dtbs_check rejects those nodes
(the T8103 Mac mini, MacBook and iMac boards, and now the MacBook
Neo). Allow both.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The MacBook Neo (J700) sound card links the audio DAIs of the Always-On
Processor to a CS42L83 headset codec and a MAX98360A speaker amplifier.
Add "apple,j700-macaudio" with the "apple,macaudio" fallback.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
On the A18 Pro (T8140) the Always-On Processor (AOP) firmware owns the
audio paths: the internal speaker, the headset jack in both directions,
a serial monitor tap on the speaker output, the high-quality microphone
array and the low-power microphone. Add a binding for the audio child
of the AOP node, which gives the host:

 - five ADMAC channels (spkr, cout, cin, spkr-tap and hpai), used while
   the matching AOP service is active;
 - the power domains of the LEAP transmit and receive channels and of
   the serializers (tx0, mca, mca1, mca0 and rx0);
 - the AOP DART stream and IOVA window of the low-power microphone,
   which the firmware fills through a shared ring instead of an ADMAC
   channel;
 - one DAI cell selecting the AOP audio DAI (on the MacBook Neo, 0 is
   the headset link and 4 the speaker link);
 - apple,chassis-name and apple,machine-kind, which name the sound card
   as on the existing AOP audio nodes.

There is no "apple,aop-audio" fallback: the T8140 capture path, a
16 kHz source ring on the setup port, is not compatible with the
existing AOP audio driver.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The Always-On Processor (AOP) of the A18 Pro (T8140) runs firmware
loaded by the bootloader and provides the machine's audio and sensor
services. The application processor talks to it over two mailboxes:
the primary ASC mailbox and a separate setup-port mailbox.

Describe the AOP register window and the ASC wrapper registers, the
two mailboxes, the AOP's DART stream together with the host allocation
window in that stream's firmware-owned root (apple,dma-range), its
power domain, and the ALS and audio child nodes.

The AOP nodes of the other Apple SoCs have no schema. The T8140 AOP
differs from them in its setup-port mailbox and its firmware-owned DART
roots, so it gets a schema of its own.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide and others added 14 commits September 26, 2026 00:27
DockChannel is a FIFO-based transport on Apple SoCs. One of its
channels carries a UART-compatible byte stream, which a host can reach
through the USB-C debug interface; on the MacBook Neo it is the serial
console.

A channel has a data window with its TX and RX FIFO ports and fill
levels, and a configuration window with the FIFO interrupt thresholds.
Its interrupts are masked and acknowledged in an interrupt window that
is shared with the other DockChannel functions. Describe the three
windows by name and the channel's interrupt.

The binding lists Ryan Murray as its maintainer; the driver derives
from Yureka Lilian's DockChannel UART work, credited in the driver
commit.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Yureka Lilian's T8140 device tree series notes that the secondary CPUs
of the Apple A18 Pro (T8140) lose architectural state when they execute
WFI or WFIT, so an SMP boot has to keep WFI out of the idle loop and
WFIT out of the delay loop.

The kernel executes WFIT and WFET in __delay() whenever ARM64_HAS_WFXT
is detected, so udelay() on a secondary CPU can corrupt it. Add a
"wfxt" field to the id_aa64isar2 override and an arm64.nowfxt alias for
id_aa64isar2.wfxt=0. ID_AA64ISAR2_EL1.WFxT is FTR_LOWER_SAFE, so the
override clears the sanitised field: ARM64_HAS_WFXT is not detected,
__delay() falls back to its event-stream WFE loop (or a cpu_relax()
loop), and HWCAP2_WFXT is not advertised to userspace. WFE and WFI are
not affected; keeping WFI out of the idle loop is a separate matter.

Document the parameter in kernel-parameters.txt.

Link: https://lkml.iu.edu/2609.1/11238.html

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Add a driver for the UART that Apple SoCs expose over DockChannel, a
FIFO-based transport that a host reaches through the USB-C debug
interface. On the MacBook Neo (T8140) it is the serial console.

Each channel has a data window with 8- and 32-bit TX and RX FIFO
ports, a TX free-space count (DATA_TX_FREE) and an RX fill count
(DATA_RX_COUNT), and a configuration window with the TX and RX
interrupt thresholds. The FIFOs are 2 KiB deep, and the 8-bit RX port
returns the received byte in bits 15:8. Interrupts are masked in
IRQ_MASK and acknowledged in IRQ_FLAG (write 1 to clear), in a window
shared with the other DockChannel functions.

The driver registers ttyDC ports and a console:

 - Receive is interrupt driven: the RX threshold is one byte, and the
   handler drains DATA_RX_COUNT bytes per pass.
 - Transmit polls DATA_TX_FREE before writing each byte to DATA_TX8.
   The poll is bounded to 10000 cpu_relax() iterations per byte; when
   it runs out, the byte is dropped rather than spinning forever with
   the port lock held. The bound is an iteration count, not a time.
 - set_termios reports a fixed 115200 baud 8N1 link with CLOCAL, since
   DockChannel has no baud rate, parity or modem lines. The port uses
   PORT_GENERIC rather than a new port type.
 - Probe fails cleanly when a register window or the interrupt is
   missing.

A separate early console (earlycon=dockchannel,<addr>, or earlycon with
stdout-path pointing at the node, whose first reg entry must be the
data window) writes to the data window with the same bounded polling.

Known limitations, to be addressed in follow-ups:

 - start_tx() writes out the whole transmit buffer by polling, with the
   port lock held and interrupts disabled. It ignores a stopped
   transmitter and x_char and never calls uart_write_wakeup(). It
   should use the TX interrupt and threshold with
   uart_port_tx_limited().
 - tx_empty() reports TIOCSER_TEMT as soon as one FIFO slot is free
   instead of when DATA_TX_FREE equals the FIFO size, so
   uart_wait_until_sent() can return with data still queued.
 - Probe masks and acknowledges every source in the shared interrupt
   window and uses fixed channel-0 bit positions, so only one port can
   work and other DockChannel users would be disturbed. The UART should
   become a child of an apple,dockchannel node handled by
   drivers/soc/apple/dockchannel.c.
 - Both Kconfig options are bool; the driver should be tristate, with
   a separate console option.

The driver is based on the DockChannel UART driver that Yureka Lilian
wrote for the Asahi Linux A18 Pro bring-up. This version bounds the TX
polling, propagates resource and interrupt errors from probe, uses
PORT_GENERIC instead of a new port type, and is adapted to the serial
core of this tree.
Her authorship is recorded here rather than as From:/Signed-off-by:
because her sign-off has not yet been obtained; it is to be added, with
a public Link: to the original commit, once it is.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The driver's regmap uses a flat cache with 512 raw defaults, so
creating it reads all 512 pin register slots back from the hardware,
whatever apple,npins says. On T8140 some pins belong to other agents:
Apple's device tree lists them in no-restore-gpio-pins (pins 50 and 134
on the MacBook Neo), and reading their registers from the application
processor raises an asynchronous SError. A regmap debugfs dump that
reached pin 134 (0x31a000218) took the machine down that way.

Match apple,t8140-pinctrl with match data that makes the driver create
its regmap without a cache and with read and write access tables that
allow only the registers of the apple,npins pins, minus the pins listed
in the standard gpio-reserved-ranges property. Regmap then refuses
accesses to reserved pins from every path, including debugfs, which
does not go through gpiolib's reserved-line checks. The ranges are
validated against apple,npins before use.

The interrupt registers above the pin registers are accessed directly,
as before, and the other SoCs keep the cached map.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
apple_pmgr_ps_set() builds the words it writes from a read of the power
state register. It clears the WAS_CLKGATED and WAS_PWRGATED flags but
not BUSY (bit 11), which the hardware reports while a transition is
still in progress: on T8140 audio_leap_mca reads back 0xa4f, with BUSY
set, after missing the 100 us poll window. A value read in that state
was written back with BUSY set. Clear BUSY in the DEV_DISABLE/PS_RESET
write that precedes a power-down and in the target state write, which
the auto-enable write reuses. This changes the value written on every
SoC that uses this driver.
No failure attributable to writing BUSY back was observed; the change
is precautionary, as the bit is hardware-owned.

The error messages in apple_pmgr_ps_set() and in the reset assert and
deassert paths are printed from genpd and reset callbacks that
consumers retry, so a domain that keeps missing its poll window, as
audio_leap_mca does on T8140, repeats the same message on every
attempt. Ratelimit them; their text is unchanged.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The DARTs of the A18 Pro (T8140) are T8110-family instances that report
version 2.2 or later in PARAMS3. At least the AOP DART is locked by the
bootloader (PROTECT reads back 0x1e7), and its stream roots already
hold the co-processor firmware's own mappings when Linux takes over.
The driver handled neither:

 - Attaching a domain to a locked stream copied Linux's whole L1 table
   over the firmware's root table, and releasing it zeroed the table,
   destroying the firmware's mappings.
 - From version 2.2 on, per-stream TLB flush commands take an extra
   command bit, faults are reported through per-stream exception
   records instead of the legacy error registers, and exceptions latched
   before Linux took over are still pending at probe.

Handle both, and add the device tree inputs the T8140 device tree
needs:

 - Locked roots: publish Linux's L1 entries only into slots that are
   vacant or that Linux itself filled, keep a shadow copy of what was
   published, and on release clear only entries that still hold
   Linux's value. A slot whose owner has changed fails the operation
   with -EBUSY instead of being overwritten. Publishing is done under
   the DART lock, and errors now propagate out of the attach path.
 - TLB maintenance: wait for the busy bit before and after every T8110
   TLB command, for up to 2 ms instead of 100 us. From version 2.2 on,
   set bit 15 in per-stream flush commands, and after a map or unmap
   flush a locked stream by range instead of invalidating it whole;
   TLB_START and TLB_END take the first and last page number, derived
   from the DART page size, shifted left by two.
 - Faults from version 2.2 on: decode the pending-exception bitmap at
   0x4000 (one bit per stream, write 1 to clear) and the per-stream
   records at 0x8000 + 0x40 * sid (status, access type and fault
   address), plus the block-level summary at 0x704 on version 2.3.
   Drain exceptions left over from before probe, logging them at debug
   level. If the DART is set to lock on error (DIAG_LOCK bit 1), unlock
   it with TLB command 4 once its exceptions have been acknowledged.
 - apple,remap-streams: validate the property at probe and program the
   remaps into the source streams' TCRs when the DART is reset.
 - apple,dma-range on a consumer node: use that window as the domain's
   aperture instead of the DART's, so that each consumer's IOVAs land
   in root slots that are free for it. Consumer and DART windows must
   have a nonzero size, must not overflow or cross the DART's input
   address width, and must be aligned to the DART page size.
 - Power the DART with pm_runtime_resume_and_get() and handle failure
   instead of warning, both when flushing and when releasing a consumer
   of a locked DART. When a locked DART's domain is freed, its entries
   are retired and the stream invalidated first; if the DART cannot be
   powered or the invalidation fails, the page tables are intentionally
   leaked rather than freed while the hardware may still cache them.
 - Return -EINVAL instead of warning when a locked DART is attached with
   anything other than a single stream.

The probe banner and the DMA range and IAS messages move to debug
level.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The ADMACs of the A18 Pro (T8140) audio fabric (admac-evolution = 1 in
Apple's device tree) move the per-channel register blocks. Up to T8122
every channel, with TX (even) and RX (odd) channels interleaved, has a
0x200-byte block at 0x8000 + ch * 0x200. On T8140 the TX blocks are at
0x8000 + (ch / 2) * 0x200 and the RX blocks at 0xc000 + (ch / 2) *
0x200; on the MacBook Neo the block of TX channel 2 (channel 4) answers
at 0x8400, not 0x8800. The offsets within a block, the descriptor and
report FIFO ports and the start and stop registers are unchanged.

Compute the per-channel register addresses from a per-variant layout
flag and add apple,t8140-admac, which also sets the REG_UNK_28 bit like
T8122.

The T8140 ADMACs sit behind the AOP DART, whose windows for them lie
above 4 GiB (apple,dma-range). Descriptors carry full 64-bit addresses,
so set a 42-bit DMA mask at probe; with the default 32-bit mask the PCM
buffers cannot be allocated. The mask applies to every variant. All
ADMAC nodes in the tree sit behind a DART, so on the other SoCs the
IOVAs handed out remain bounded by the DART's aperture.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The A18 Pro (T8140) needs two new mailbox variants:

 - apple,t8140-asc-mailbox: the ASC mailboxes use the v4 register
   layout, but the application processor has to set bit 0 of the I2A
   (co-processor to AP) control register before that FIFO is used. Set
   it in apple_mbox_start() for this variant.
 - apple,t8140-aop-setup-mailbox: the Always-On Processor's second
   mailbox, its setup port, has a compact layout of its own. The A2I
   and I2A control registers are at 0x0 and 0x4, with the full and
   empty flags at bits 16 and 17 as on ASC, A2I send is at 0x180/0x188
   and I2A receive at 0x1b0/0x1b8. It has only the send-empty and
   recv-not-empty interrupts, which is all the driver uses.

Also check at probe that the register window covers the variant's last
receive register. The setup port's window is much smaller than the ASC
one, and a device tree mistake would otherwise make the driver access
memory outside its mapping.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Mailbox::new_byname() installs the receive callback and its cookie in
struct apple_mbox before starting the mailbox. If apple_mbox_start()
fails, the scope guard frees the cookie but leaves both pointers
installed, and Drop likewise frees the cookie after stopping the
mailbox without clearing them. Anything that reaches the provider's
receive path afterwards, such as apple_mbox_poll(), then calls into
freed memory. Clear the callback and the cookie on the error path, and
in Drop before the cookie is freed; apple_mbox_poll() returns without
touching the FIFO while no receiver is attached.

Add Mailbox::device(), which returns the mailbox provider's device. A
consumer uses it to allocate DMA buffers against the provider's own
IOMMU stream, as the T8140 AOP driver does for the setup-port mailbox,
whose node carries that stream.

Also point the module documentation at
include/linux/soc/apple/mailbox.h instead of
include/linux/gpio/driver.h.

Fixes: 0de2ff3 ("rust: soc: apple: Add Apple mailbox abstractions")
Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
CondVar has an uninterruptible wait without a timeout (wait()) and
interruptible waits with and without one, but no uninterruptible wait
with a timeout. A driver that waits a bounded time for a co-processor
reply, and must not have that wait cut short by a signal, has no
suitable primitive.

Add wait_timeout(), which sleeps in TASK_UNINTERRUPTIBLE for at most
the given number of jiffies and returns CondVarTimeoutResult::Timeout,
or CondVarTimeoutResult::Woken with the remaining jiffies. It never
returns CondVarTimeoutResult::Signal. Like the other waits it can wake
up spuriously, so callers have to check their condition again.

The T8140 AOP driver, submitted separately, uses it for its bounded
firmware waits.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
The T8140 AOP drivers, submitted separately, need a few C interfaces
that Rust cannot reach through bindgen alone:

 - pm_runtime_get_sync(), pm_runtime_put_sync() and
   pm_runtime_put_noidle() are static inlines. Add helpers for them in
   a new rust/helpers/pm_domain.c, and generate bindings for
   linux/pm_domain.h and linux/pm_runtime.h, which the audio driver
   needs for its named power domains.
 - The ASoC core and DPCM interfaces (sound/soc.h and
   sound/soc-dpcm.h). SNDRV_PCM_FMTBIT_S32_LE, SNDRV_PCM_FMTBIT_S24_LE
   and SNDRV_PCM_SUBFMTBIT_STD are macros that bindgen cannot evaluate,
   so export them as constants, as SNDRV_PCM_FMTBIT_FLOAT_LE already
   is.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
A Rust RTKit client has no way to shut its co-processor down, and when
a shutdown cannot be confirmed, dropping the RtKit still calls
apple_rtkit_free(), which returns the shared buffers to their allocator
while the firmware may still DMA into them.

Add RtKit::shutdown(), which calls apple_rtkit_shutdown(). The C core
bounds its waits and drains the RTKit workqueue, so the caller must not
hold a lock that its receive callbacks take. Add
RtKit::retain_shared_buffers_on_drop(), after which Drop calls
apple_rtkit_free_retaining_buffers() instead of apple_rtkit_free(): the
callbacks and the workqueue are still torn down, but the shared buffers
and their shmem_setup contexts stay allocated until reboot. The owner
must keep its own DMA buffers as well and must not re-probe the device.

The shmem_setup callback hands the buffer's virtual address to the C
core, which accesses it as ordinary memory. Reject an IoSysMap that
refers to I/O memory instead of passing an __iomem address off as a
normal pointer.

Implement Unpin for RtKit regardless of T. The wrapper holds only raw
pointers and a PhantomData<T>, and neither the C instance nor the
callback context points back into it, so moving it is sound; without
this, RtKit<T> is !Unpin whenever T is.

Assisted-by: LLM checkpatch sparse
Signed-off-by: Ryan Murray <[email protected]>
Add device trees for the A18 Pro (T8140) and the MacBook Neo (J700).

t8140.dtsi describes the SoC as far as this series uses it:

 - six CPUs in two clusters, four efficiency and two performance cores,
   started through spin tables, with their L2 caches, the architected
   timer on AIC FIQs and the 24 MHz reference clock;
 - the two PMGR blocks, the AIC3 and the watchdog;
 - the GPIO and pin controller with its seven interrupt groups and the
   reserved pins 50 and 134 in gpio-reserved-ranges, I2C bus 0 and the
   DockChannel UART;
 - the Always-On Processor: its ASC mailbox, its setup-port mailbox, its
   DART, and the AOP node with its ALS and audio children, each DMA
   consumer with its DART stream and host DMA window;
 - the three audio ADMACs (base-ns, leap-ns and leap-s), without resets
   because the AOP firmware owns the audio fabric. leap-s is reached
   through its proxy aperture at 0x353200000: through the direct window
   at 0x313200000, the first write to a per-channel register raises an
   asynchronous SError;
 - the ISP with its three DARTs, which remap streams 1, 2, 6, 7, 10 and
   11 onto stream 0.

t8140-pmgr.dtsi adds the power domains those devices use: aic, gpio,
i2c0, isp_sys and the thirteen ISP-local domains in the main PMGR
block, and the AOP and audio fabric domains, with their parents, in the
second one. The AOP firmware is already running at boot, so the AOP
domains and the audio fabric parents it relies on are always-on
(letting genpd switch audio_p off left the firmware unable to answer
power requests); the leaf domains are runtime managed.

t8140-j700.dts enables the serial console and adds the framebuffer,
memory and reserved-memory placeholders that the bootloader fills in,
the IMX558 camera presets and ISP heap from isp-imx558.dtsi together
with the ISP platform ID and temporal filter, the CS42L83 headset codec
on i2c0, the MAX98360A speaker amplifier, and an apple,j700-macaudio
sound card with a headset link and a speaker link to the AOP audio
DAIs.

The five CS42L83 supplies (VA, VP, VCP, VD_FILT and VL) are left
unwired, as on the T8103 boards such as j313. Their board-level rails
are not known, and fixed regulators invented for them would describe
hardware that has not been established; without them the regulator
core substitutes dummy supplies. dtbs_check reports the supplies as
missing, as it does for those boards.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Add a MAINTAINERS entry, with myself as maintainer, for the files this
series adds for the A18 Pro (T8140) and the MacBook Neo (J700) that no
existing entry covers: the T8140 device trees, the T8140 AOP, AOP
audio, AOP ALS and ISP bindings, the apple,asc-mem reserved-memory
binding, and the DockChannel UART binding and driver.

The T8140 device trees also remain covered by ARM/APPLE MACHINE
SUPPORT through arch/arm64/boot/dts/apple/, and changes to the shared
Apple drivers (DART, ADMAC, mailbox, pinctrl and PMGR) stay under that
entry.

Assisted-by: LLM checkpatch sparse
Co-authored-by: Claude Fable 5.1 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide force-pushed the series/neo-prerequisites-20260924 branch from 021cafc to 2903144 Compare September 25, 2026 14:54
@RyanTheTide RyanTheTide changed the title arm64: apple: prepare T8140/J700 AV prerequisites arm64: apple: T8140/J700 platform prerequisites (reworked) Sep 25, 2026
@RyanTheTide
RyanTheTide merged commit 566b521 into aurora-wip Sep 25, 2026
@RyanTheTide
RyanTheTide deleted the series/neo-prerequisites-20260924 branch September 26, 2026 12:44
cb2206 pushed a commit to cb2206/linux that referenced this pull request Oct 5, 2026
…age-history

drm/apple: repair idle scanout using two frames of damage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants