Skip to content

arm64: dts: apple: t6050: Add the AOP ambient light sensor - #1542

Merged
DjDeveloperr merged 29 commits into
integration/aurorafrom
m5-parity/t6050-aop-als
Nov 11, 2026
Merged

DjDeveloperr merged 29 commits into
integration/aurorafrom
m5-parity/t6050-aop-als

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Ambient light sensor on the M5 Pro/Max (T6050). This adds the AOP's als service to the T6050 tree, so that aop_als binds and exposes in_illuminance_input. That's what keyboard backlight daemons and auto-brightness read.

Stacked on #1521 (T6050 AOP through its setup port), which is stacked on #1423. Only the last 3 commits are this PR's.

Change

  1. dt-bindings: iio: light: apple,aop-als: add apple,t6050-aop-als.
  2. dt-bindings: soc: apple: t8152-aop: allow the als child.
  3. arm64: dts: apple: t6050: the als node under the AOP.

No driver change. The firmware reports the part as a VD6286 ("Redbird"), which aop_als already handles as on the M4 Pro. As there, it reports only once it has the machine's calibration as apple/aop-als-cal.bin. Under macOS that is the CalibrationData of AppleSPUVD6286 (193 bytes, FDRCalibration = True), which the installer's ALS collector already saves.

Validation (MacBook Pro 14-inch M5 Pro, J714s)

Setup: the default kernel (7.3.0-m5-argb2) with #1521's aop.rs as a module, booted on a DT whose als node matches this PR's J714s DTB.

  • iio_aop_als binds by itself at boot and creates aop-sensors-als.
  • Without the calibration file: no apple/aop-als-cal.bin (ENOENT), and the channel reads ENODATA.
  • With this machine's calibration file from macOS: in_illuminance_input reads a live 0.96-1.02 lux in a dark room (six-ish in the morning, nobody at the machine). The value varies between reads, so the sensor is reporting rather than returning a constant.
  • in_colortemp_input stays ENODATA: the driver decodes a colour temperature only from the 122-byte Redbird report.
  • The T6050 DTs (j714s, j714c, j716s, j716c, j775d, j873s) build.

Not tested: a bright scene (nobody was there to light the room). Calibration data is per machine, so it isn't part of this PR.

🤖 Generated with Claude Code

Add the MacBook Air (M5, J813) and Mac mini (M6, J873) sound cards.
t8142-j813-audio.dtsi already names apple,j813-macaudio.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873 (Mac mini M6) AOP runs the same firmware generation as T8140
(EPIC v4, iBoot-loaded, started by the AP), but the T8140 "setup port"
is not reachable from the AP: mailbox 1 of the AOP's mailbox bank and the
ADT aop-exclave-mailbox both bus-error. The firmware boots without it:
RTKit protocol 12, then its "audio" EPIC service. Add apple,t8152-aop
with the T8140 configuration minus the setup port, starting every
advertised endpoint.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The Mac mini (M6, J873) speaker runs a 250-BCLK TDM frame, which the
SN012776's ratio auto-detection rejects. Describe the property that fixes
the ratio instead.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873 (Mac mini M6) AOP runs the speaker frame at 250 BCLKs of 12 MHz.
The SN012776 cannot auto-detect that ratio and mutes with "fault: bad
TDM clock". With TAS2764_CLK_CFG (register 0x60) set to 0x30 and
TDM_CFG0 bit 6 set it accepts the frame and plays. Do that when the new
ti,bclk-ratio property names the ratio; only this one ratio is supported.

Source of the value: the register write was first seen in the macOS
SN012776 driver; it is a single register value, and its effect (no fault,
correct playback) was verified on J873 hardware. No table or code was
taken from macOS.

The field is initialised in probe, so non-OF matches keep auto-detection.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The SDOUT1 mux offers the ASP receive channels as a source, but no DAPM
route connected them, so selecting "ASP RX CH1" or "ASP RX CH2" left the
capture path without an input. The J873 and J813 AOP audio services use
it to loop the playback stream back.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
On T8152 (J873, Mac mini M6) the AOP firmware owns the audio fabric, as
on T8140. Its "audio" EPIC service offers cout/cin (the CS42L84 jack,
base-ns ADMAC TX5/RX5, MCA4) and spkr (the SN012776 speaker, TX1, MCA0).

Each service is an ASoC back-end DAI: startup attaches it, requests pw0
(which raises the audio fabric) and powers the MCA leaves, all of which
are required. pwrd starts the serializer clocks at prepare, before ASoC
unmutes the codecs: the jack codec locks its PLL to the bit clock, and
the speaker amplifier reports "bad TDM clock" whenever it runs without
one. The jack restarts its clocks on every prepare so that a stream
restarted after an underrun begins on a frame boundary; the mono speaker
(one slot per frame) keeps them running. The front-ends are dmaengine
PCMs on the base-ns channels: the jack in stereo, the speaker in mono
(its serializer runs one 32-bit slot; stereo frames play at half pitch).

The firmware's serializer configuration (property 701) is byte-identical
to the one macOS publishes, so the driver leaves it alone.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J873 (Mac mini M6) uses the T8152 AOP audio driver as its CPU
component: the CS42L84 jack on "cout" (DSP_A | IB_NF, one-BCLK sync
pulse) and one SN012776 on "spkr" (I2S, NB_IF: data sampled on the rising
edge, as macOS programs the amp).

Each AOP front-end owns the DMA channel of one serializer, so the speaker
can only be fed from the secondary front-end; the new spk_secondary_only
sets the speaker mux accordingly, and spk_dai_fmt gives the speaker link
its own format.

There is no qualified speaker protection for J873 yet (no verified sense
path, thermal model or power budget) and no safe level, so
macaudio_speakers_allowed() keeps the speaker off. The jack is not
affected.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The T8142 AOP (MacBook Air J813) waits for the host on a setup port, as
the T8140 one does: the ADT's aop-exclave-mailbox at 0x3d067c000 (AOP
ASC + 0x4007c000, not behind the arm-io translation). Its EPMAP announces
other service endpoints than T8140's fixed set (0x4, 0x20, 0x23 and 0x32
on J813), so take the endpoints that must get buffers from the EPMAP when
the match data says so.

The firmware places its own crash log buffer in its firmware-mapped DART
slot; accept it as the firmware's, as for G17P.

After the setup boot all AFK endpoints start, and with the audio fabric
left to the firmware (see the J813 device tree) the firmware announces
its "audio" EPIC service.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Behind an AOP the serializer feeding a capture channel is the firmware's,
and it stops in the middle of a frame whenever it likes. A capture that
stays open across such stops (the speaker V/I sense, which a protection
daemon reads for as long as it runs) then carries the partial frame
forward: every later frame is off by its words, and the samples of one
amplifier are read as another's. On the MacBook Air J813 one restart in
three slipped by one 16-bit word.

Let a client pass the frame size in bytes as a u32 in
dma_slave_config.peripheral_config. A paused cyclic capture on such a
channel resumes at the next frame boundary of its current period: the
reports completed before the pause are accounted for, the rings are
reset and the rest of the period is submitted from the aligned address,
then whole periods as before. Without a frame size nothing changes.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The J813 speaker stream (ADT iop-audio-controller/audio-speaker) differs
from J873's: four SN012776 in 32-bit playback slots 0-3, and their voltage
and current sense back on the same stream's RX side (base-ns RX0) as eight
16-bit slots. Make the speaker and sense shapes per-SoC match data:
J873 keeps one playback channel; T8142 gets four, and an 8-channel S16_LE
"Speaker Sense" front-end.

The sense capture is the speaker serializer's RX, which the firmware
stops anywhere in a frame. Before every `pwrd` of the speaker, restart a
running sense capture at a frame boundary (apple-admac realignment, the
partial frame reads as zeros), so that a protection daemon that keeps it
open attributes each amplifier's voltage and current to the right one.

The sense back-end also attaches the speaker service and requests `pw0 `
at startup: its front-end requests the ADMAC channel next, and the ADMAC
only answers while the firmware holds the audio fabric up. Opening the
sense before any other stream since the AOP started (speakersafetyd at
boot) otherwise faults the bus.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
MacBook Air 13" M5 (T8142): as on J873 the AOP firmware owns the audio
fabric and the CPU component is the T8152-style AOP audio driver. The
jack is a CS42L84 on "cout", the speakers four SN012776 (one woofer and
one tweeter per side) on "spkr", with their V/I sense on the same stream.

As on the other SN012776 laptops the table has a safe level, so the
speakers are behind the speaker protection interfaces from the bind:
under "Speaker Volume Unlock" their volumes stay at the lock's ceiling
until a protection daemon (speakersafetyd) holds them, and under "Speaker
Protection" they stay at the floor and no speaker start is admitted until
an owner is granted. Each amp's level is its apple,speaker-config from
the boot loader.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The MacBook Air J813's three microphones are the AOP's "hpai" service
(ADT iop-audio-controller/audio-hp-mic): the firmware runs the PDM part
and delivers 48 kHz float32 frames of three channels (the ADT's
audio-hp-mic-proxy description: 12 bytes per frame) on leap-s ADMAC RX0.
There is no codec, so it gets a card of its own with one capture PCM,
named like the other AOP microphone cards (AppleJ813HPAI, "MacBook Air
J813 High-Power Audio Interface", driver aop_audio) so that the existing
UCM and DSP configurations for those apply.

As on T8140: open attaches the service and requests pw0 (which raises
the LEAP fabric), powers the LEAP leaves (leap-s ADMAC, RX0, LEAP MCA),
and only then requests the channel, whose registers fault without them.
The trigger starts the DMA and queues pwrd behind it; started earlier,
the LEAP produces into a channel nobody services. Close releases the
channel, then pw0 and the leaves.

The card exists only where the DT gives the LEAP power domains (all
three); J873 is unchanged. The dmaengine substream setup moves into a
helper shared with the ASoC front-ends.

Tested on J813: a tone from the speakers reads -44 to -49 dBFS on all
three channels, 70 dB over the quiet floor, exactly while it plays;
PipeWire picks up the card with asahi-audio's J613 beamformer graph.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The MacBook Air (M5, J813) gets its jack, speakers and microphones from
the T8152 AOP audio driver. Build it beside the T8140 one.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
ti,bclk-ratio is only on the AOP-fed amplifiers (J813, J873). Test that
an amp without it, as on every MCA machine, keeps the ratio
auto-detection and that its probe writes neither TAS2764_CLK_CFG nor
TDM_CFG0's fixed-ratio bit, through a register map that records every
write; that 250 BCLKs programs code 0x30 and sets only that bit; and
that a ratio without a known code fails the probe.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The paused-capture restart at a frame boundary is the T8152 AOP audio
driver's alone: it passes a u32 frame size in the peripheral config for
its speaker sense capture. Test that a slave config as mca_hw_params()
builds it (zeroed, no peripheral config) and one with a peripheral config
of another size give no frame size, and that a resume realigns only a
capture channel with a frame size and a transfer, never a playback one,
so the MCA machines' channels resume as before.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Cover the AOP-fed machines in the speaker KUnit suites:

- apple-speaker-admission: J813 is admitted (it has a safe level), J873
  is not (it has none).
- apple-speaker-amp-level: neither carries an SN012776 gain; each amp's
  level is its apple,speaker-config from the boot loader.
- apple-speaker-interface: on the J813 table the four SN012776 volumes
  start at the volume lock's ceiling, go up only once a daemon holds the
  lock and pings, and under "Speaker Protection" sit at the floor with no
  speaker start admitted until an owner is granted.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
DjDeveloperr and others added 13 commits November 11, 2026 10:22
The driver also runs the J813 (T8142, MacBook Air M5) speakers and
its microphone array card. Say so in the Kconfig help and the module
description, which still named only the Mac mini jack and speaker.

Signed-off-by: Diljit Singh <hey@djdev.me>
TAS2764_CLK_CFG went in between TAS2764_INT_CLK_CFG and its
TAS2764_INT_CLK_CFG_IRQZ_CLR field. Put the field back under its
register. No functional change.

Signed-off-by: Diljit Singh <hey@djdev.me>
Flush queued HPAI startup before releasing its dmaengine runtime, and
provide sync_stop so ALSA waits for asynchronous DMA termination before
reusing or freeing the capture buffer. This carries the microphone
lifetime handling already present in the J815 extension into the common
J813/T8152 foundation.

No speaker admission, gain, protection or device-tree behavior changes.

Signed-off-by: Diljit Singh <hey@djdev.me>
Pair the dmaengine front-end asynchronous STOP with sync_stop before
ALSA reuses or releases its buffer. Skip ASoC back-ends, which have no
dmaengine runtime, just as the T8140 AOP component does.

Signed-off-by: Diljit Singh <hey@djdev.me>
…tion

Retain the reviewed DMA/work and FE/BE sync-stop lifetime fix, and combine
T8142 dynamic setup endpoints with current main AOP source/bound rings,
LPAI and other interfaces. Carry the reviewed policy-window test-only
correction, including unsafe-call negative controls.

The audio driver source is unchanged; actual object compilation follows.

Assisted-by: LLM
integration/aurora now has the agreed fix for the policy-window test,
#1561 (ea10c4d). The earlier merge into this branch had carried a
different version of the same test change, and combining the two leaves
#1561's deferred-call count at zero, which fails the source check. Take
integration/aurora's test file as it is: this pull request is J813
audio and changes nothing under tools/aurora-sep.

Signed-off-by: Diljit Singh <hey@djdev.me>
The T6050 (M5 Pro and Max) AOP boots through a setup port, as the T8142
one does. Its endpoint map names system endpoint 4 besides the service
endpoints 0x20, 0x23 and 0x32, but endpoint 4 never asks for a buffer.
With the T8142 configuration the boot therefore times out with 3 of 4
endpoints, and the AFK endpoints never start.

Add a T6050 configuration that doesn't wait for system endpoints. A
buffer request from one is still answered.

On a J714s the AOP then opens its AFK endpoints and announces its
services, among them accel, gyro, las, als, als-temp, devmotion6,
aop-audio and aop-voicetrigger.

Signed-off-by: Diljit Singh <hey@djdev.me>
Both use the T8140 setup-port register layout. T8142 already names its
own compatible in the J813 device tree.

Signed-off-by: Diljit Singh <hey@djdev.me>
The ADT reg of aop-exclave-mailbox is not behind the arm-io translation.
As on T8140 and T8142 it is the AOP ASC + 0x4007c000, 0x2d067c000. The
0x4d067c000 this tree used takes an SError, which is why the AOP was
described as booting without its setup port. At 0x2d067c000 the port's
control words read back and the AOP firmware runs its setup handshake
on it.

Describe it as the setup-port mailbox, with T8142's interrupt names and
dart-aop stream 1 (ADT vm-base-1 0x20000000000, vm-size-1 0x2000000000),
and give the AOP both mailboxes. The J716s and J873s ADT coverage
manifests carried the old address; they now name the real one.

Signed-off-by: Diljit Singh <hey@djdev.me>
Boot the AOP through its setup port: its RTKit mailbox, the setup port,
dart-aop and the AOP itself.

Signed-off-by: Diljit Singh <hey@djdev.me>
The T6050 (M5 Pro and Max) AOP firmware announces an "als" ambient
light sensor service, a VD6286, as on T6020 and T8112.

Signed-off-by: Diljit Singh <hey@djdev.me>
Allow the AOP's "als" child, the ambient light sensor service, on the
T8152-generation AOP.

Signed-off-by: Diljit Singh <hey@djdev.me>
The T6050 AOP firmware announces an "als" service. Under macOS it is an
AppleSPUVD6286 whose CalibrationData is the 193-byte factory record the
installer saves as apple/aop-als-cal.bin; aop_als sends it to the sensor
as on the M4 Pro. Describe the service so that the driver binds.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the m5-parity/t6050-aop-als branch from daa5797 to 19636c7 Compare November 11, 2026 17:30
@DjDeveloperr
DjDeveloperr merged commit 93a6c9a into integration/aurora Nov 11, 2026
5 checks passed
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