Skip to content

J813: train the N1 Wi-Fi/Bluetooth PCIe link before Linux - #79

Merged
Acelogic merged 1 commit into
aurora-silicon:mainfrom
sithglan:thomas/j813-rb-n1
Nov 6, 2026
Merged

Acelogic merged 1 commit into
aurora-silicon:mainfrom
sithglan:thomas/j813-rb-n1

Conversation

@sithglan

@sithglan sithglan commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Brings up apcie port 0 to the N1 (Wi-Fi/Bluetooth) on T8142 (MacBook Air M5, J813) before the Linux handoff, so Linux can use the root port as a generic ECAM host with apple_centauri and btcentauri.

Rebased onto main (077aabe, 2026-11-05). The J813 NVMe change it used to be stacked on is in main as f5831b2.

The sequence follows macOS 25G76 AppleT8142PCIe / APCIECoreRCGen4 (decompiled):

  • AUS5 PHY: apcie-phy-tunables, wait refpll_clk_good (PHY common reg0 bit 31), _initializeGen4Phy (sleep_b_sml/sleep_b_big handshakes on PHY-PHY reg0, PHY IP PLL/AUSPMA tunables, wait max_pclk_good), PHY enables, apcie-axi2af-tunables.
  • Root complex: RC 0x54 = 0x140, 0x50 |= 1, wait gtb_initialized (0x58).
  • N1 reset release via SMC gP13 (ADT pKW4('gP13', 0x800000): 0x800000 | level).
  • Port 0: _resetPortHardware writes, apcie-config-tunables, port enable, endpoint refclk buffer on the port PHY lane reg 0 (_initializeRefclkBuffer), PERST, lane PIPE reset, RUN, root port DBI tunables, LTSSM.

ADT reg map from AppleT8142PCIe::start: 0 ECAM, 1 APCIe common, 2 PHY (common block at +0x4000 — reg[2]+0 bus-errors), 3 PHY-PHY, 4 PHY IP, 5 AXI2AF, port 0 from 8 (10 = PHY glue). Without the refclk buffer the LTSSM never leaves detect.

It runs from kboot_prepare_dt only when the FDT has an enabled pci-host-ecam-generic node on T8142, and disables that node if any step fails (Linux would hang on its first config access to an untrained link).

Tested on a MacBook Air M5 through the ESP boot path, no host steps: j813-n1: link up (0x9a001001), endpoint 106b:1900, then Linux brings up Wi-Fi (WPA2-PSK, DHCPv4 + SLAAC, ~6 MB/s) and Bluetooth (hci0, LE discovery). The Linux side is aurora-silicon/linux#998 and #1001.

Rebased onto main 077aabe (2026-11-05): the image builds with USE_CLANG=1 RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 and make format-check / make rustfmt-check pass. A new Mach-O object from this rebase has not been enrolled on the J813 yet, so the runtime testing above is from the pre-rebase build.

cc @Acelogic @DjDeveloperr @RyanTheTide @LiamRay10

On T8142 (MacBook Air M5, J813) bring up apcie port 0 to the N1 when the
FDT describes a pci-host-ecam-generic host, so Linux can use the root
port as a generic ECAM host. The sequence follows macOS 25G76
AppleT8142PCIe / APCIECoreRCGen4: AUS5 PHY tunables and power-up
(sleep_b handshakes, PHY IP PLL/AUSPMA tunables, max_pclk_good), root
complex, N1 reset through SMC gP13 (pKW4, 0x800000 | level), port reset,
config tunables, the endpoint refclk buffer on the port PHY lane, PERST,
root port DBI tunables and the LTSSM.

The PHY common block sits at ADT reg[2] + 0x4000; reg[2] + 0 bus-errors.
Without the refclk buffer the LTSSM never leaves detect.

If any step fails, the ECAM host is disabled in the FDT: Linux would hang
on its first config access to an untrained link.

Tested on J813 through the ESP boot path: "link up, endpoint 106b:1900",
then Linux's apple_centauri brings up Wi-Fi (WPA2, DHCP) and btcentauri
Bluetooth.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@Acelogic
Acelogic merged commit 0ecabb1 into aurora-silicon:main Nov 6, 2026
7 of 8 checks passed
@DjDeveloperr DjDeveloperr mentioned this pull request Nov 7, 2026
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