Skip to content

nfc: Apple Stockholm NFC/SE controller: identity and power-off on the AOP SPMI bus - #1042

Merged
RyanTheTide merged 14 commits into
integration/aurorafrom
surp/stockholm
Nov 7, 2026
Merged

RyanTheTide merged 14 commits into
integration/aurorafrom
surp/stockholm

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What

Linux support for "Stockholm", the NFC controller with an embedded Secure Element (NXP-built) that sits on its own SPMI bus on the M4-generation Macs and the MacBook Neo.

  • gpio: macsmc: templated SMC output lines, for enables written as an SMC key with a per-line command (the lowercase gp bank on T6040, pcIO lines on J700), with output-latch readback where the key supports it.
  • nfc: apple-stockholm: the controller is follower 9 on the AOP SPMI bus and carries NCI through non-incrementing FIFO registers (transmit and receive are separate registers; receive frames have no trailer). At probe the driver raises VEN, checks the follower ID and IRQ base (side-effect-free reads), does one CORE_RESET + CORE_INIT exchange, logs one line (NCI version, manufacturer, firmware identity, RF interface count), then disables standby and drives VEN low. The controller stays in that deepest power state for the life of the system. It sends no Secure Element commands.
  • DT: the AOP SPMI bus is driven by the application processor (no AOP ownership handoff), so it gets its interrupt controller properties on T604x and a T8140 node at its real address (0x310914000), plus the Stockholm node on J616s and J700. asahi.config builds the driver.

Model-specific transport constants live in the driver's match data; the DT carries only the bus address, interrupts and the VEN line.

Why no NFC device

On the hardware the controller answers CORE_RESET (NCI 1.0) and CORE_INIT, but CORE_INIT reports zero RF interfaces, a zero-size listen-mode routing table and no discovery features (decoded response in the test notes below). The NCI core then sends RF_DISCOVER_MAP with no mappings, which the controller rejects as a syntax error, so an nfc0 could never be powered. There is no NFC antenna on these Macs either: Apple Pay on a Mac is online-only and the controller only fronts the Secure Element. Registering an NFC device that can never come up would only confuse neard and other NFC users, so the driver does not register one. The Secure Element's card manager and applets are Apple's; nothing in it is usable for Linux keys (on-device keys belong to the SEP).

This also covers power: whatever state an earlier OS left, the controller is parked off at boot, so suspend, resume and runtime PM need no callbacks.

Testing

Hardware, one-shot only (aura-try trial Stage 2 = the live image with only these DT lines, plus a one-shot kernel; nothing committed, both Macs returned to their fleet kernel and Stage 2):

MacBook Neo (J700), this head's driver (kernel = this branch + a test-only commit that logs CORE_INIT and tries one RF discovery; 11-07 23:44):

  • follower ID 0x19 and IRQ base 0xe0 match (same model 96 values as the J616s); CORE_RESET/CORE_INIT complete with no transport errors: NCI 1.0 controller, manufacturer 0x04, firmware 37010160, 0 RF interfaces; parked off;
  • CORE_INIT_RSP 00 | 00 00 02 00 | 00 | 02 | 00 00 | ff | 02 00 | 04 | 60 01 01 37: no RF interfaces, routing table size 0, only the switched-off power state feature;
  • RF discovery attempt: RF_DISCOVER_MAP with one ISO-DEP mapping -> 0x01 (rejected), with no mappings -> 0x05 (syntax error), RF_DISCOVER for NFC-A passive poll -> 0x01 (rejected);
  • VEN (SMC pcIO line 10) low after probe; no NFC device; unbind/bind re-probes cleanly; s2idle x2 (rtcwake) fine with the controller off; SELinux enforcing, 0 AVC, 0 failed units, no new kernel warnings.

J616s (M4 Pro), earlier revision (11-07 05:55, same transport, NCI core registration still in): CORE_RESET/CORE_INIT OK, NCI 1.0, manufacturer 0x4, firmware 0x41010160, the same zero-RF CORE_INIT_RSP, and the NCI core's RF_DISCOVER_MAP refused (0x05); VEN low verified on the SMC output latch (gp0e). A J616s run of this head follows when the machine is free.

Built on the buildbox: W=1 clean (apple-stockholm.o, gpio-macsmc.o); dt-doc-validate + yamllint clean for the new binding and apple,smc-gpio.yaml; CHECK_DTBS on t6040-j616s and t8140-j700: no warnings on the new nodes (only the pre-existing atcphy ports lines on J616s). checkpatch --strict clean on the final driver.

Not covered

  • The other model-96 boards (J616c, J773s, J713/J773/J604, J813, J873/J873s) have the same controller per their ADTs; their nodes follow once someone can boot them.
  • M1-generation Macs use an older interface (gen1 AOP SPMI, follower 12, no model) and are not handled.

🤖 Generated with Claude Code

Some SMC-controlled enables are not plain gPxx GPIOs: they are written
as a key with a per-line command template (a lowercase gp bank on
T6040, pcIO lines on J700). Describe them with apple,output-templates
and drive them through the same gpio_chip, reading back the SMC
output latch where the key supports it.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The NFC controller with embedded secure element on Apple silicon Macs
sits on its own SPMI bus and carries NCI packets through a
non-incrementing data register. Add a transport that powers it through
its VEN line, checks the follower identity with side-effect-free
register reads, registers it with the NCI core and parks VEN low
whenever the device is closed, which is the controller's lowest power
state. The NCI core reads the controller identity on first open.

No secure element commands are implemented.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
…nd J700

aop-spmi0 is driven by the application processor (there is no AOP
ownership handoff), so give it its interrupt controller and parent
interrupt, add the T8140 node, and describe the Stockholm NFC/SE
controller at SID 9 with its VEN line on the J616s and J700.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Use the separate receive FIFO, drain its two-byte wire footer, and report the native diagnostic status registers on a transport error. Drop the unsupported CRC-CCITT transform.

Signed-off-by: Ryan Murray <[email protected]>

Assisted-by: LLM
The corrected wire transport drains its opaque footer without applying a CRC transform, so CRC_CCITT is no longer needed.

Signed-off-by: Ryan Murray <[email protected]>

Assisted-by: LLM
The follower identity register of a model 96 controller reads 0x19 and
its IRQ-offset register reads the base of the follower's interrupt
block, 0xe0; neither is the SPMI address. Check them against the model
data instead of the follower's SID.

Seen on the J616s with the controller powered.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
On the J616s a model 96 controller delivers each NCI packet as header
and payload only. Reading two more bytes runs into the next packet or
past the end of the FIFO, fails the SPMI frame parity check and raises
the transport error interrupt. Drain nothing after the payload.

Tested on J616s (trial device tree, fleet17 base): CORE_RESET and
CORE_INIT complete, the NCI core reports NCI 1.0 and the controller
identity, no parity or transport errors, VEN parked low on close.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Bring the Stockholm branch up to date with integration/aurora 43c790f.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
On the J616s the model 96 controller answers CORE_RESET (NCI 1.0) and
CORE_INIT, but CORE_INIT reports no RF interfaces, a zero-size listen
mode routing table and no discovery features. The NCI core then sends
RF_DISCOVER_MAP with no mappings, which the controller rejects with a
syntax error, so nfc0 can never be brought up. There is no NFC antenna
on these Macs either: the controller only fronts the embedded Secure
Element.

Registering an NFC device that can never be powered would only confuse
neard and other NFC users. Drop the NCI core registration and make the
driver what the hardware supports: check the follower ID and IRQ base,
do one CORE_RESET/CORE_INIT exchange to log the NCI version,
manufacturer, firmware identity and RF interface count, then disable
standby and drive VEN low. The controller stays in that deepest state
for the life of the system, so suspend, resume and runtime PM need no
callbacks; a failed identity read still parks it.

Also drop the unused CRC property from the binding, rename the binding
after its compatible, use the Aurora copyright line and add the files
to the Apple MAINTAINERS entry.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The driver holds the Stockholm NFC controller and Secure Element in its
deepest power state on the J616s and the J700 once their device trees
describe it.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
…616c

Use the smc_gpio_low label the J616c already uses for the same bank.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The ADT places aop-spmi0 at 0x100914000 in the arm-io space, which is
0x310914000 in the SoC address map like every other t8140 arm-io node
(nub-spmi0 0xf8714000 -> 0x308714000, smc 0xfc600000 -> 0x30c600000).
The node used the arm-io offset as an absolute address.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
No functional change.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Bring the Stockholm branch up to date with integration/aurora a20af80.
#1034 added the same T8140 aop_spmi0 node this branch carries; keep
integration's copy (identical node, plus its nub_spmi1 neighbour).

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide RyanTheTide changed the title nfc: Apple Stockholm NFC/SE controller over the AOP SPMI bus nfc: Apple Stockholm NFC/SE controller: identity and power-off on the AOP SPMI bus Nov 7, 2026
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 7, 2026 12:49
@RyanTheTide
RyanTheTide merged commit 535ecf3 into integration/aurora Nov 7, 2026
2 checks passed
@RyanTheTide
RyanTheTide deleted the surp/stockholm branch November 7, 2026 13:02
RyanTheTide added a commit that referenced this pull request Nov 7, 2026
Brings aurora-wip up to fleet25: DT descriptions (#1029, #1030, #1112),
the J715 board (#1129), Stockholm NFC (#1042, #1136), the AV1 tile check
(#1100), the M4 Max ANE profile and AVD quirk (#1088, #1091), boot-log
fixes (#1103, #1104) and the Neo ANE memory floor (#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 <[email protected]>
Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s confirmation on the fleet kernel (2026-11-08 04:53 AEDT): 7.3.0-aurora-fleet27 (integration/aurora 95e30d5) with the integration J616s Stage 2 DTB (e4292d96) committed.

apple-stockholm 5-09: NCI 1.0 controller, manufacturer 0x04, firmware 41010160, 0 RF interfaces; parked off
  • No apple-stockholm warnings or errors; gpio-14 (|enable) out lo in /sys/kernel/debug/gpio, so VEN stays low.
  • apple_stockholm loaded, no /sys/class/nfc device (as intended).
  • SELinux enforcing, 0 AVC, journalctl -k -b -p 3 empty.

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