Skip to content

T8142 (M5) platform bring-up: PCIe, DAPF, DCP carveouts, CTRR, ATC PHY - #12

Closed
hishamMounir wants to merge 10 commits into
GravityLinux:mainfrom
hishamMounir:j704/t8142-bringup
Closed

hishamMounir wants to merge 10 commits into
GravityLinux:mainfrom
hishamMounir:j704/t8142-bringup

Conversation

@hishamMounir

@hishamMounir hishamMounir commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

This series brings the bootloader up on T8142 (Apple M5), as seen on the 14"
MacBook Pro (Mac17,2 / J704). With it the tree reaches a usable proxy on that
machine and chainloads Linux from the internal SSD.

This is #12 again, rebased onto current main (c22cd92).

What is here

  • pcie: support t8142: needed for the internal NVMe and WLAN.
  • kboot: raise WLAN_REG_ON (SMC gP13) before PCIe init: without it the
    WLAN device never appears on J704. Includes the small SMC write plumbing.
  • dapf: find the DAPF reg by its ADT instance name: on t8142 the reg
    index used on earlier SoCs lands on a page shared with PMGR and SErrors on
    access. The index path is kept for the SoCs that use it.
  • kboot: reserve the second CTRR range on t8142: main already reserves
    the first CTRR instance on t8142 through the apple_sysregs_unlocked check
    (64b8646), so this only adds the second instance. It covers the
    DeviceTree/TrustCache area below the bootloader. Its two registers are named
    next to the existing pair (3, 0, 11, 0, 2/3). The reservation is gated on
    t8142 and skipped when the instance reads back zero.
  • kboot: reserve the DCP carveouts and split DCP mapping runs, reserve unlisted iBoot DCP mappings, skip iommu-addresses without phandle: iBoot
    maps some regions (t8142 dcp_data) in several IOVA runs, and Linux replaces
    a locked DART's tables with exactly what iommu-addresses lists, so each run
    has to be described. A run with no mapping now fails rather than silently
    handing Linux a truncated list, once at least one run has been described.
  • kboot: match DT CPU nodes to running CPUs by MPIDR: index-based
    matching does not hold on this SoC.
  • kboot_atc: copy the atc-phy tunables on t8142: same tunable layout as
    t8122/t8132. It still applies cleanly on top of the 11-03 ATC rework.
  • pmgr_adt2dt: resolve no_ps parents to their nearest real ancestors.
  • smp: log once when a call target hasn't taken a call after 1 s: a
    secondary that never takes a cross-CPU call otherwise looks exactly like a
    dead board. Logs once, then waits as before.

Testing

J704 (Mac17,2, T8142, 16 GB), with the bootloader as the custom boot object of
a second macOS install. Linux boots from the internal SSD and the proxy runs
over USB-C from an M4 Mac mini. AIC3, pmgr (386 devices), framebuffer,
dockchannel UART, USB (3 DARTs, t8110), PCIe and NVMe all come up. It has been
this machine's default Linux boot path since 2026-10-19.

The limits of that testing:

  • The hardware testing was with the AsahiLinux-based build. This tree has not
    been booted with these patches.
    On the rebased branch a full m1n1.bin
    builds and links with clang and the Rust target, with no warnings in any
    touched file.
  • clang-format was not run.
  • The new DCP failure path has not been hit on hardware. It needs a region iBoot
    maps in several runs with a gap, which this machine has not produced.

Provenance

  • Clean room: every commit here is platform bring-up derived from the ADT,
    hypervisor traces and driver experiments. No Apple binary was disassembled for
    any of them.
  • My M5 GPU work (an asahi_neo G17G profile and its m1n1 DRM-shim
    experiments) is tainted. Apple GPU firmware was disassembled while
    diagnosing it. None of it is in this series, and I will not send it to any
    Gravity repo.
  • sh1ftmaker's m5-linux-research was a reference during this bring-up. Their
    T8142 GPU firmware memory handoff patch is not included. It is their work to
    send.

🤖 Generated with Claude Code

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
Instead of assuming the DT lists CPUs in the same order as the ADT, look
up the live CPU with the node's MPIDR. Same result for in-order trees;
lets a bring-up DT reorder CPUs (used to boot one specific E-core early
on t8142).

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
t8142 has a second CTRR instance, covering the DeviceTree/TrustCache area
below the bootloader. iBoot leaves it enabled on the secondary cores, so
Linux crashes when it hands those pages to a secondary CPU and writes to
them, the same way it does for the first instance.

The first instance is already reserved for t8142 through the
apple_sysregs_unlocked feature check. Name the second instance's two
registers (encodings 3, 0, 11, 0, 2/3, next to the existing pair) and
reserve that range too, gated on t8142 and skipped when the instance reads
back zero, so the M4 targets are untouched.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
Register layout and PHY init from macOS AppleT8142PCIe: 8 shared reg entries, the PHY-PHY block at reg[2] + 0x20000, the 100 MHz reference clock poll, the Gen4 PHY IP bit (_initializeGen4Phy) and PHY_CTRL bit 27 (_apcieGPInit). No fuse block.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
Built only with -DJ704_WLAN_PWR. Linux has no SMC driver for t8142 yet, so m1n1 sets SMC GPIO gP13 = 0x01000001 (CMD_OUTPUT | 1, as macsmc-gpio does) before pcie_init so the BCM4388 enumerates. Adds smc_read_u32 to log the old value.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
On t8142 the DAPF reg index used on earlier SoCs lands on a page shared with
PMGR, and touching it raises an SError. The reg this SoC wants is identified by
the ADT instance name instead, so look it up that way and keep the index path
for the SoCs that use it.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
Same region ids as t8112, all mapped in dart-dcp stream 23 on the M5.
No disp0/piodma nodes yet; a no-op unless the DT has a "dcp" alias.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
…ngs, skip iommu-addresses without phandle

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
t8142's atc-phy nodes carry the same tunable layout as t8122/t8132, so list the
compatible in the fuse table (reverse-chronological, ahead of t8132) and select
the t8122 tunable set for it.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
A secondary that never takes a cross-CPU call leaves smp_call4() spinning with
no output at all, which looks exactly like a dead board. Print the CPU, the
call and the target state once after a second, flush the console, and then keep
waiting as before, so the behaviour is unchanged apart from the message.

This was written to chase a first-secondary wedge on J704 (M5) that shows up
roughly one boot in three.

Assisted-By: LLM
Signed-off-by: Hisham Alkhudrawi <hisham.ma.mohammed@gmail.com>
@hishamMounir hishamMounir reopened this Nov 4, 2026
@hishamMounir
hishamMounir deleted the j704/t8142-bringup branch November 4, 2026 17:55
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.

1 participant