Skip to content

n66: the loudspeaker plays (CS35L21 on MCA2) - #217

Merged
henrikklee merged 3 commits into
OrchardLinux:mainfrom
ricktav:n66/audio
Nov 23, 2026
Merged

henrikklee merged 3 commits into
OrchardLinux:mainfrom
ricktav:n66/audio

Conversation

@ricktav

@ricktav ricktav commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

The iPhone 6s Plus (n66, Samsung S8000): the loudspeaker plays.

Tested on a RAM boot, 2026-11-23:

  • Tone: a 440 Hz tone at -20 dB was heard.
  • Soak: 60 s of pink noise at the caps described below. The amp's INT_STATUS_1 and INT_STATUS_2 read 00 at every 2 s poll, and the driver logged no warnings.

Hardware. From the ADT and the 19H422 kernelcache:

  • Speaker amp: at i2c1 0x40, reset on AP GPIO 70. It reports ID 35 A2 10, rev b0, which makes it a CS35L21. iOS drives it with the same AppleCS35L19Amp driver and the CS35L33 register layout.
  • Audio link: MCA2 to pad 2, 8 slots of 16 bits, speaker in slot 1, 12 MHz MCLK. SmartIO endpoint 0x2c, NCO at 0x20e044000 from an 800 MHz reference.
  • Clock provider: in iOS the CS42L71 codec drives the pad-2 clocks. Here MCA2 provides them, as on J81 and J71b, and the codec is not touched.

Kernel

  • cs35l19, from Cascadia:
    • 16-bit TDM slots;
    • accepts the CS35L21;
    • turns the alive watchdog off when there is no keep-alive GPIO. Without that, INT_STATUS_1 bit 5 (ALIVE_ERR) muted the output while the DMA ran;
    • "Speaker Volume" is capped at 0 dB on every board;
    • a fault watch, described below.
  • MCA: apple,s8000-mca-tdm with its binding. MCA2 is the clock provider, and the output is capped at -12 dB.
  • NCO: S8000 NCO binding.
  • Device tree:
    • NCO, MCA2, SmartIO and I2C1 are okay in s800-0-3.dtsi, per AGENTS.md;
    • the amp and the simple-audio-card "iPhone Speaker" are in s800x-n66.dtsi, so N66m gets them too (untested there).
  • Config: CONFIG_SND_SOC_CS35L19=m.

Firmware. The n66's own SmartIO firmware is extracted from its kernelcache (devices/n66/firmware.json).

Speaker safety

There is no speaker protection (V/I sense) yet. What protects the speaker now:

  • -12 dB output cap. The MCA driver attenuates every sample. The cap is unconditional: no ALSA control or DT property changes it, and mmap is off.
  • Amp gain cap. "Speaker Volume" ends at 0 dB instead of +12 dB, on every CS35L19 board. The volume the driver restores after power-up is clamped as well.
  • Amp hardware protections. Over-temperature (OTE) and short (AMP_SHORT) shutdown stay active; the driver never releases them.
  • Fault watch. While playing, the driver polls INT_STATUS_1 every 500 ms. It warns on OTW, OTE or AMP_SHORT. On OTE or AMP_SHORT it also mutes and powers the amp stage down until the stream stops.

Still missing:

  • V/I sense capture and any limiter;
  • the amp interrupt (AP GPIO 68), which is polled instead;
  • a reset path after OTE or a short: the speaker then stays silent until reboot;
  • the CS42L71 codec, needed for the earpiece, headphones and microphones.

Catalog

  • n66 audio_output is working, with the note "speaker only; no speaker protection yet, output capped at -12 dB".
  • drivers.json lists audio_output for the A9 iPhones, because MCA2 binds there.
  • The matrix is regenerated.

Tests: 926 OK (2 skipped).

🤖 Generated with Claude Code

The loudspeaker path needs SmartIO DMA. Extract the n66's own SmartIO
firmware from the 19H422 kernelcache (AppleS8000SmartIO), as for the
j71t: 487488 bytes, measured with orchard.apple.smartio on the IPSW's
kernelcache.

Assisted-by: LLM
The iPhone 6s Plus's bottom speaker: a CS35L21 amplifier (the CS35L19
driver from Cascadia, which now accepts it) on I2C1, fed 16-bit TDM slots
by MCA2 with its bit clock from the S8000's NCO. With no keep-alive line
the amplifier's alive watchdog is turned off, as cs35l33 does, or it mutes
its output. The CS42L71 codec stays untouched.

There is no speaker protection (the V/I sense iOS reads back) yet, so the
output stays capped: MCA2 attenuates every sample by 12 dB, with no
control or property to lift it, and the amplifier's gain now stops at 0 dB
instead of +12 dB on every board with this driver. The amplifier's own
over-temperature and short protections stay on; the driver now watches
them while playing, warns, and mutes on a shutdown.

The NCO, MCA2, SmartIO and I2C1 are enabled in the S8000/S8003 device
tree for every board that has them; the 6s Plus's model file, shared by
the Samsung (N66) and TSMC (N66m) models, adds only the amplifier, the
card and its i2s-switch route. Exported from a branch on the n66 series;
applied in series order the patches reproduce it.

On a RAM boot a 440 Hz tone at -20 dB plays from the speaker.

Assisted-by: LLM
On RAM boots on 2026-11-23 a quiet 440 Hz tone played from the bottom
speaker through the CS35L21 amplifier, and 60 s of pink noise at the
output caps ran with the amplifier's status clean (no over-temperature
warning or shutdown, no short) at every 2 s poll. Speaker only: there is
no speaker protection (V/I sense) yet and the output is capped at -12 dB.
The TSMC model (N66m) shares the description and is marked untested.

The microphones, earpiece and headphone jack hang off the CS42L71 codec,
which has no driver yet, so audio input stays missing.

Assisted-by: LLM
@henrikklee
henrikklee merged commit 11caca9 into OrchardLinux:main Nov 23, 2026
10 of 12 checks passed
henrikklee added a commit that referenced this pull request Nov 23, 2026
…peakers on every iPad mini 2 and 3

#217 and #223 each brought a driver for the same amplifier. Keep the one
#217 carries (Project Cascadia's, which Orchard's iPad mini 1 build uses
too, with #217's 16-bit slots, CS35L21, watchdog, gain cap and fault
watch) and teach it what the iPad mini 2 needs from #223's: the first
amplifier drives the TDM frame when its endpoint says so (new
drivers/sound 0043). The binding (0042) describes one node per
amplifier; the speakers go into s5l8960x-mini2.dtsi with two amplifier
nodes and an audio-graph-card2 card, since the IPSW device trees of all
six iPad mini 2 and 3 models describe the same speakers.

#223's MCA, SmartIO and MCA1 patches are unchanged apart from numbers
(sound 0040-0041, soc-apple 0037, s5l8960x 0014-0015) and the context
of the MCA binding and driver after #217's S8000 link. CONFIG_SND_SOC_CS35L19
appears once per config, in Kconfig order. The J85's audio_output is
untested until the shared driver runs on it; the other five models are
untested with the same description.

Also: the Orchard note in the AOP patch names its source like the
others do.

Assisted-by: LLM
@henrikklee

Copy link
Copy Markdown
Contributor

Thanks! This is on main now.

Changes on top:

  • The speaker moved to s800x-6s.dtsi, so the iPhone 6s (N71, N71m) has it too. Its ADT has the same amplifier, link and route; it is untested there.
  • speaker-config now comes from the IPSW device tree. Your phone's live ADT had byte 12 = 0x8c, but the IPSW has 0x8a, the same in all four models. iBoot fills that byte in per unit, and a shared file carries the template, not one unit's value.
  • MCA2 stays disabled in s800-0-3.dtsi. Its compatible names the 6s link's setup, and the SE's link (other slots and SmartIO FIFO words) and the iPad 5 don't use it, so the 6s file enables it with the route.
  • Every A9 iPhone recipe now makes s8000-smartio.bin. The firmware is identical in all six 19H422 kernelcaches.
  • j85: speakers — MCA1 and a CS35L19 amplifier driver, on main's A7 audio support #223 brought a second CS35L19 driver. The one here stays as the only driver, and it gained frame-provider support for the iPad mini 2 (details in j85: speakers — MCA1 and a CS35L19 amplifier driver, on main's A7 audio support #223).

If you can, please play something on the n66 with main: it now uses the IPSW speaker-config byte.

One request: your kernel patches here carry Signed-off-by: ricktav <…@users.noreply.github.com>. Could you reply with your Signed-off-by in the form Signed-off-by: Your Name <your@email>? We will put it on the patches.

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