Skip to content

j85: speakers — MCA1 and a CS35L19 amplifier driver, on main's A7 audio support - #223

Merged
henrikklee merged 1 commit into
OrchardLinux:mainfrom
ricktav:j85/speakers
Nov 23, 2026
Merged

henrikklee merged 1 commit into
OrchardLinux:mainfrom
ricktav:j85/speakers

Conversation

@ricktav

@ricktav ricktav commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The iPad mini 2 (Wi-Fi, J85, A7) has no sound on main: its device.toml says the speakers are "two CS35L19 amplifiers on I2C2 + MCA1, which have no driver". This PR adds the missing parts on top of the A7 audio support that 0.3.3 brought for the iPad Air (thisiscamk's work, merged by Henrik Klee): SmartIO (apple,s5l8960x-sio), the MCA driver's version 1 support, the i2s-switch and the SmartIO firmware step.

It replaces my earlier J85 audio branch, which had its own SmartIO, MCA and i2s-switch patches and now conflicts with main. This version uses main's as they are and only adds what the J85 needs.

Reused from main, unchanged:

  • the SmartIO driver and node (apple,s5l8960x-sio), enabled for every A7 board;
  • the i2s-switch node and compatible;
  • the version 1 MCA code in s8000-mca, including the A7 TX/RX_CTL word (MCA_V1_XX_CTL_A7);
  • the SmartIO firmware already in devices/j85/firmware.json (smartio-from-kernelcache@2); no recipe change is needed.

The values come from the J85's Apple device tree (iOS 12.5.8 16H88) and from static analysis of iOS 12.5.8's AppleCS35L19Amp.

Changes

  • SmartIO (drivers/soc-apple 0035): the A7 table gains MCA1's transmit endpoint, 0x2a (ADT /arm-io/mca1 dma-channels), next to MCA0's 0x28/0x29.
  • MCA (drivers/sound 0031–0032): apple,s5l8960x-mca-tdm, MCA1's speaker link:
    • a consumer of the frame the primary amplifier drives, DSP A, 8 × 16-bit slots, TX in slots 0–1, and the 12 MHz MCLK the amplifiers run from;
    • output bounded to −12 dB, as on the J71b and J81, since Linux has no speaker protection;
    • a new no_irq flag, set only on this variant. On the J85, MCA1's interrupt line stayed asserted during the first prepare with no cause in the status register ("irq 60: nobody cared"), and the storm starved the touchscreen's SPI firmware upload. main's MCA requests the interrupt on every variant, so this is still needed.
    • apple,s5l8960x-mca (the iPad Air's I2S link on MCA0) and the other variants are unchanged.
  • CS35L19 (drivers/sound 0033–0034): a new codec driver and binding. The CS35L19 uses the CS35L33's register map. The node describes the pair at the primary's address, as Apple's device tree does, and the driver reaches the secondary as an ancillary I2C device.
    • The ID is read one register at a time. The part does not auto-increment, so a 3-byte read returned 0x35 three times.
    • Power-up and power-down follow AppleCS35L19Amp for a link without speaker sense data, with the ADT's speaker-config records.
    • "Amp Volume" sets the digital volume, register 0x10, in 0.5 dB steps: 0..204 is −102..0 dB (0x34..0x00). It starts at 0 dB. 0x19 is mute, as in iOS.
    • The alive watchdog stays off (0x0a bits 3:2, 0x0c bit 3). iOS feeds it by toggling the ADT's alive GPIO (161) from a timer; unfed, it set ALIVE_ERR (INT_STATUS_1 0x15 = 0x20).
    • Only 48 kHz S16 is offered.
  • Device tree (devices/s5l8960x 0012–0013):
    • s5l8960x.dtsi: MCA1, disabled (AIC 148, MCLK word at 0x20a002004, SmartIO 0x2a, i2s-switch aud1 to pin1).
    • s5l8960x-j85.dts: MCA1 on, the amplifiers at I2C2 0x40/0x41 (reset on GPIO 114) and a "J85 Speakers" simple-audio-card.
  • Kernel config: CONFIG_SND_SOC_CS35L19=m for apple-4k and apple-16k. The apple-armv7 config already has a SND_SOC_CS35L19 from the Cascadia import (the iPad mini 1). That is a different driver in a different series; the two never share a tree.
  • J85: audio_output is working. audio_input stays missing. Includes the regenerated matrix and a CHANGELOG entry under Unreleased.

Testing

iPad mini 2 Wi-Fi (J85, iPad4,4), on installed Omarchy, with my earlier tree (2026-11-22/23), which combined this code with the J85's touch, Wi-Fi, charging and sleep work:

  • SmartIO boots its firmware, both amplifiers identify, and the card appears.
  • Browser playback comes out of both speakers at Amp Volume 0 dB, under the MCA's −12 dB bound.
  • −3 dBFS tones on one channel at a time: the left channel plays on the left speaker and the right channel on the right.
  • The card survives suspend and resume (s2idle).
  • Problems found along the way, all fixed in this series:
    • "unknown device 35 35 35" from the burst ID read;
    • the MCA1 interrupt storm;
    • silence: the old gain control covered only the mute range, and the alive watchdog was on;
    • sound too quiet at −20 dB on top of the −12 dB bound, so the volume now starts at 0 dB.

This exact series has not run on the iPad. How it differs from what I tested:

  • cs35l19.c is the tested file, except one comment line ("A7 iPads" became "A7 iPad minis"). The Kconfig help says the same.
  • The J85 MCA variant has the tested register values. It is renamed from apple,s5l8960x-mca to apple,s5l8960x-mca-tdm, because main uses the first name for the iPad Air's I2S link. It uses main's v1_ctl field (0xf on the A7).
  • My tree had no_irq on both A7 MCA variants. Here only MCA1 has it, so the iPad Air's MCA0 behaves as it does on main.
  • SmartIO is main's driver. My tree exposed endpoints 0x28–0x2f; this exposes 0x28, 0x29 and 0x2a.
  • The MCA1 and amplifier nodes are the tested ones. The J85 file no longer enables SmartIO, the i2s-switch or MCA0, because main already does. It also drops the CS42L81 headset codec on SPI2, which had no card and isn't needed for the speakers.

Checks:

  • bin/orchard build --device j85 and --device j81 (with examples/minimal-boot) both build. cs35l19.c, s8000-mca.c and apple-sio-core.c build without warnings. The J85 DTB has the amplifiers, MCA1 and the card.
  • kernel/audit-patches.py passes for j85, j81, j71b and j71t.
  • tools/catalog/generate matrix --check passes.
  • python -m unittest discover -s tests: 926 tests, the same count as on unmodified main. The 5 in test_ram and test_cascadia_loader fail on this host on both. main's checkout also failed test_n61_data's touch recipe test, which passes on this branch, so that one looks like a quirk of that checkout.

Overlaps

Open questions

  • Compatible name: apple,s5l8960x-mca-tdm, following apple,t8010-mca / apple,t8010-mca-i2s, where the suffix names the link. Happy to rename it.
  • Where the speakers live: only in s5l8960x-j85.dts. main's air1 commit says the iPad mini 2 and 3 all use two CS35L19s on I2C2 and MCA1, but I only have the J85's device tree. If the J86/J87 (and mini 3) trees match, the nodes could move to s5l8960x-mini2.dtsi (and mini3).
  • MCA0 on the J85: main enables MCA0, with its interrupt, on every A7 board. On the J85 nothing uses it after probe, so its interrupt is only on briefly while probe reads the version, with every cause masked. My tested tree had MCA0's interrupt off, so this combination hasn't run with the speakers playing.

Not included

  • The headphone jack (CS42L81 on SPI2) and the microphones.
  • Speaker protection: none in Linux, hence the −12 dB bound in the MCA.
  • Sample rates other than 48 kHz, which is what iOS uses for the speakers.
  • A UCM profile. PipeWire plays through the card's default profile, and "Amp Volume" starts at 0 dB, so nothing has to be set.

🤖 Generated with Claude Code

The iPad mini 2's two speakers play, in stereo. They are two CS35L19
amplifiers on I2C2, fed over TDM by the A7's MCA1. The A7 SmartIO, MCA
and i2s-switch support, and the SmartIO firmware in the J85 recipe, are
main's; this adds what the J85 needs on top:

- SmartIO exposes MCA1's transmit endpoint, 0x2a;
- apple,s5l8960x-mca-tdm, MCA1's speaker link in the S8000 MCA driver:
  a consumer of the amplifiers' frame, 8 x 16-bit DSP A slots, the 12 MHz
  MCLK, the -12 dB bound, and no interrupt (MCA1's line stormed);
- a driver and binding for the CS35L19, which uses the CS35L33's register
  map: per-register ID reads, the digital volume at 0x10 ("Amp Volume",
  -102..0 dB, starting at 0 dB), the alive watchdog kept off;
- MCA1 in the A7 tree, and the amplifiers and a "J85 Speakers" card in
  the J85's;
- CONFIG_SND_SOC_CS35L19=m for apple-4k and apple-16k.

The headphone jack (CS42L81) and the microphones are not part of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@henrikklee
henrikklee merged commit bd08856 into OrchardLinux:main Nov 23, 2026
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, reworked so that one CS35L19 driver serves every board:

  • n66: the loudspeaker plays (CS35L21 on MCA2) #217 brought a CS35L19 driver too (Project Cascadia's, with your 16-bit slots, CS35L21, watchdog, 0 dB cap and fault watch). That one stays. It now drives the frame when its graph endpoint is the clock provider (ADSP_CTL 0x43, as your driver found), new patch sound 0043.
  • The binding (sound 0042, still yours) describes one node per amplifier, with apple,speaker-config.
  • The speakers are in s5l8960x-mini2.dtsi as two amplifier nodes and an audio-graph-card2 card, "iPad mini Speakers". The first amplifier's endpoint carries bitclock-master and frame-master. The IPSW device trees of all six iPad mini 2 and 3 models (J85, J86, J87, J85m, J86m, J87m) describe the same speakers, so all of them have them now.
  • Your MCA (no_irq included), SmartIO and MCA1 patches are unchanged apart from numbers (sound 0040-0041, soc-apple 0037, s5l8960x 0014) and context. CONFIG_SND_SOC_CS35L19 is on once in both configs.

The power-up order is now the Cascadia driver's, so the J85's audio_output is untested until the speakers play on main. Could you try main on your J85 and tell us how it sounds? The amp volumes are "Left Speaker Volume" and "Right Speaker Volume".

One request: your kernel patches here have no Signed-off-by. Could you reply with yours in the form Signed-off-by: Your Name <your@email>? We will add it to 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