Skip to content

Complete M4 Max and A18 Pro Support - #29

Merged
ADevWithAnIdea merged 30 commits into
mainfrom
PR_max_neo_ship
Dec 1, 2026
Merged

ADevWithAnIdea merged 30 commits into
mainfrom
PR_max_neo_ship

Conversation

@ADevWithAnIdea

@ADevWithAnIdea ADevWithAnIdea commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Shipping is fun :D

Missing: ABSOLUTELY NOTHING

  • Some ISP stuff because the Linux driver needs to be deslopped
  • Some stuff on the Neo involving pmgr because idk if it's necessary
  • GPU FDT handoff because a nice upstreamable solution is a pain :(

jannau and others added 22 commits November 30, 2026 01:44
Adds new rust dependency sha1_smol.

Signed-off-by: Janne Grunau <[email protected]>
`__always_unused` and `__maybe_unused` look nicer than the plain
`__attribute__((unused))`. Copy the defines from Linux's
include/linux/compiler_attributes.h and convert the two in tree uses of
`__attribute__((unused))` to `__maybe_unused`.

Signed-off-by: Janne Grunau <[email protected]>
This survived longer than expected.

Signed-off-by: Janne Grunau <[email protected]>
New "/aliases" properties should not have been added. In addition this
one was undocumented.

Signed-off-by: Janne Grunau <[email protected]>
The use of "/aliases" to match FDT nodes to ADT nodes for copying device
specific data like tuneables is not desired in upstream devicetrees. One
alternative is to iterate over all FDT nodes and find matching ADT nodes
by comparing addresses. dt_disable_missing_devs() already does the same
so factor common functionality out for re-use.
No functional changes intended.

Signed-off-by: Janne Grunau <[email protected]>
New "/aliases" properties should not have been added. In addition these
were not documented in the apple,atcphy dt-bindings.
Instead of using the aliases iterate over all "/soc*" child device nodes
and match FDT and ADT atc-phy device nodes by their "core" MMIO address.

Signed-off-by: Janne Grunau <[email protected]>
Add function to check if a FDT node is compatible with any compatibles
from a list. This function return a bool and not libfdt's confusing
scheme of `0`: match , `1`: no match and negative for errors.

Signed-off-by: Janne Grunau <[email protected]>
atcphy is one of many device classes which need to lookup information
from their matching ADT nodes. Factor the mostly generic iterate over
all nodes and match ADT and FDT nodes out to a utility function.

Signed-off-by: Janne Grunau <[email protected]>
The upstream USB4 support will come without aliases for "acio" and "nhi"
device nodes. Use the common MMIO address matching machinery to find
ADT and FDT "acio" device nodes and do the runtime setup of the FDT
nodes.

Signed-off-by: Janne Grunau <[email protected]>
When the platform loses architectural state across WFI, advertise
idle=nop / arm64.nowfxt to Linux instead of permitting bare WFI/WFIT.

Signed-off-by: Yureka <[email protected]>
Signed-off-by: Cody Ho <[email protected]>
J700 reports mBoot-18000.161.9 rather than the existing .10 build.
Resolve that build to the existing 26.6.2 record, retaining the actual
build string for consumers. No change to other firmware versions.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
The address-based cache maintenance used by the proxy loader must also
cover the automatic boot path. Clean chainload source images and their
updated ADT, decompressed executable payloads, the prepared FDT, and the
next-stage descriptor to PoC. Complete the copy-stub writes before
invalidating the instruction cache and branching.

This avoids relying on a set/way sweep when CLIDR reports no cache levels.

Assisted-By: LLM
Signed-off-by: Cody Ho <[email protected]>
Align the first cache operation down while keeping the end relative to
the original address, and return immediately for an empty range.

Previously an unaligned address plus a length extending into another
cache line could leave the final line untouched. This affects the C
chainload stub (44 bytes at an observed offset of 48 within a 64-byte
line) and the final arguments in an unaligned next_stage descriptor.
Those buffers are consumed after caches are disabled, so partial clean
coverage can leave stale instructions or arguments in RAM.

Assisted-By: LLM
Signed-off-by: Cody Ho <[email protected]>
…ntries

Add fallback DAPF entries for dart-ane0, dart-ave0, and dart-ave1, and
reserve ANE and AVE/AVE0/AVE1 ASC firmware regions in kboot_prepare_dt()
when their FDT aliases are present.

Also return early when segment-ranges is absent or empty, fix the error
return on dt_get_or_add_reserved_mem() failure, and name ANE segments
"text" and "data".

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Move the atc-phy,t8130 (T8140 / A18 Pro) tunable table into src/atc.c
alongside t8103 and t8122, register atc-phy,t8130 in atc_fuses[] with
no fuses, add "apple,t8130-atcphy" to atcphy_compatibles[], and dispatch
purely on the ADT compatible string instead of chip_id. Clean up the
error path to delete properties from the selected tunable table.

Includes tunable_CIO_SHIM and optional CLKMON_CFG /
LN{0,1}_RX_TOP_USB_EQA entries matching upstream Asahi m1n1 commit
7621bede.

Co-Authored-By: Yureka <[email protected]>
Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
On platforms where firmware such as AOP runs under Exclaves, the ADT
omits the standard segment-ranges property that m1n1 normally uses to
reserve preloaded coprocessor memory and pass its IOVA mappings to Linux.
To recover those mappings without hardcoding addresses, walk the live
hardware DART page tables directly.

Port the read-only DART page-table walking logic from
proxyclient/m1n1/hw/dart.py into src/dart.c as dart_walk_fdt_mappings()
(supporting T8020, T6000, and 3-/4-level T8110 DARTs), and add a generic
dt_reserve_dart_mappings() helper in src/kboot.c that reads the
consumer's iommus specifiers and publishes the discovered ranges as
/reserved-memory apple,asc-mem nodes. Wire it up for the optional "aop"
and "aop1" aliases.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Reserve /chosen/memory-map TrustCache unconditionally when it lies within
usable RAM. On chips where these pages remain write-protected on
secondary cores after iBoot handoff (like T8140), leaving them in the
Linux page allocator causes permission faults.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Newer laptops, starting from the Neo (J700), carry power-lut-* properties
in /arm-io/disp0. These are large panel calibration blobs (several KB on
newer MacBooks) that vary per device, so forward any present power-lut-*
properties to Linux under dcp/apple,provider-properties instead of
hardcoding them in Linux.

A final solution for the Linux devicetree handoff still needs to be
agreed upon with upstream.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
dockchannel_uart_iodev_can_write() returns true whenever DATA_TX_FREE > 0,
even if the FIFO has less space remaining than the full console string.
Calling blocking dockchannel_uart_iodev_write() from iodev_console_write()
then spins forever once the 4 KB FIFO fills with no debug receiver
attached.

Add an optional write_nonblock callback to struct iodev_ops used by
console writes (falling back to write when unset), and implement it for
dockchannel_uart so unwritten bytes remain in the console ringbuffer.
This leaves iodev_queue() semantics intact for uartproxy and USB console
output, and avoids dropping bytes on standard serial UARTs.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Cherry-picked from AsahiLinux/m1n1 PR #589 (commit a7857af8bb6a).

Signed-off-by: Yureka <[email protected]>
Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
isp_init() previously powered on the ISP PMGR domain just to read
ISP_ASC_VERSION and immediately powered it back off, even though it
already switched on chip_id to find the PMGR offset and every ISP
revision maps 1:1 to a chip_id.

Drop the PMGR power-cycling, ISP_ASC_VERSION probe, and T8132 bypass
shortcut in favor of switching directly on chip_id (and firmware version
where heap_top varies across macOS versions), and add T6040/T6041
(0x2000000) and T8140 (0x2200000, high IOVA base).

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Match CIO v2 ACIO nodes ("acio,v2", RC at ADT reg[1] vs FDT reg[0]) and
CIO4 ATC PHY nodes ("apple,t6040-atcphy", core at ADT reg[2] vs FDT
reg[0]) using kboot_setup_matching_nodes(), without devicetree aliases:

- For "acio,v2", copy the merge-fabric and interrupt-management NHI
  tunables into "apple,tunable-nhi" on child "apple,t8103-usb4-nhi" nodes.
- For "apple,t6040-atcphy" ("atc-phy,t6040"), copy the fabric, common,
  and fused analog/PLL calibration tables into "apple,tunable-cio4-fabric",
  "apple,tunable-cio4-common", and "apple,tunable-cio4-analog".

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
@ADevWithAnIdea

Copy link
Copy Markdown
Member Author

@niklassheth can you make sure this doesn't regress the ISP? there is absolutely 0 reason why but figured it's worth checking

Newer laptops (starting from MacBook Neo) include per-unit fuse_aciphy_0
and fuse_aciphy_1 calibration fuses. Forward them generically to Linux
as apple,aciphy-fuses.

Assisted-By: LLM
Signed-off-by: Cody Ho <[email protected]>
@ADevWithAnIdea
ADevWithAnIdea force-pushed the PR_max_neo_ship branch 2 times, most recently from 8ce75f7 to 0c7fe42 Compare December 1, 2026 04:57
Cody Ho and others added 4 commits November 30, 2026 22:23
Replace the T8132-specific raw ADT property forwarding, hardcoded board
power tables, and SGX MMIO core-mask probing in src/kboot_gpu.c with a
single generic GPU DT handoff for modern Apple Silicon GPUs (G16+ with
resident firmware carveouts, dispatched for any non-G13/G14 chip whose
/arm-io/sgx node exposes gfx-data-base).

Forward only genuinely boot-time or per-unit fused ADT state:
- Reserved memory carveouts resolved via memory-region-names (ttbs,
  pagetables, l2, handoff, firmware, and optional firmware-secondary
  for dual-ASC GPUs).
- Silicon-fused core GPU OPPs grouped by voltage into operating-points-v2
  (opp-hz, apple,alternate-opp-hz, opp-microvolt, apple,sram-microvolt,
  apple,perf-index), supporting both pre-populated and empty OPP tables.
- Optional silicon-fused CS OPPs (apple,cs-opp) and trailing minimum SRAM
  voltage (apple,csafr-min-sram-microvolt) when present in both ADT and DT.
- Optional per-SKU active MCC mask (apple,active-mcc-mask from
  active-mcc-bit-vector).
- Runtime firmware version metadata (apple,firmware-version,
  apple,firmware-compat, apple,firmware-build).

Static SoC constants (RTKit private VM aperture, AIC SW interrupt address,
sampling period, GPC enable, relative power curves, board power limits)
and live SGX MMIO reads (silicon revision, shader core fuse mask) belong
in the Linux driver rather than the bootloader.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
On Exclave-split DCP generations (T8140, T6050, T8152), iBoot places the
coprocessor's __SHARED_DATA_RW segment at the tail of DCP data carveouts
(such as region-id-50/73/88), mapped at a separate DART IOVA from the
preceding data prefix.

Inspect the coprocessor's ADT segment-ranges in
dt_carveout_reserved_regions() and trim any carveout whose tail matches
a firmware segment. This is a NOP on arlier SoCs where a segment covers
the entire carveout (phys == paddr).

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Signed-off-by: Cody Ho <[email protected]>
Signed-off-by: Tom Morford <[email protected]>
Assisted-By: LLM
Cody Ho added 2 commits November 30, 2026 22:23
iBoot loads the coprocessor's __OS_LOG format-string metadata table into
normal host RAM for macOS unified logging. Linux RTKit never reads this
segment, so skip it by name in dt_reserve_asc_firmware() instead of
reserving it in /reserved-memory.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
On T8140 (MacBook Neo), the single USB controller ADT node is named
/arm-io/usb-drd without a numeric suffix. adt_device_prefix_addrs()
previously required a trailing digit ('0'..'9'), causing
dt_disable_missing_devs() to find zero usb-drd nodes and disable
/soc/usb@40a280000 along with its DARTs and ATC PHY (which in turn
blocked dcpext from getting dp-phy).

Accept an exact unnumbered prefix match as port 0 in addition to
numbered nodes.

Signed-off-by: Cody Ho <[email protected]>
Assisted-By: LLM
@ADevWithAnIdea ADevWithAnIdea changed the title (Mostly) Complete M4 Max and A18 Pro Support Complete M4 Max and A18 Pro Support Dec 1, 2026
@ADevWithAnIdea
ADevWithAnIdea merged commit 96e1e99 into main Dec 1, 2026
1 of 5 checks passed
@ADevWithAnIdea
ADevWithAnIdea deleted the PR_max_neo_ship branch December 1, 2026 06:56
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.

3 participants