Skip to content

iPhone 7 and 7 Plus: the loudspeakers and the earpiece - #76

Merged
henrikklee merged 20 commits into
OrchardLinux:mainfrom
paulscalise1:iphone7-speakers
Dec 2, 2026
Merged

henrikklee merged 20 commits into
OrchardLinux:mainfrom
paulscalise1:iphone7-speakers

Conversation

@paulscalise1

@paulscalise1 paulscalise1 commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

The iPhone 7's two loudspeakers and its earpiece. This builds on #73 (the
microphones), whose 8 commits come first here. The 18 after them are this
pull request.

The loudspeakers are fed over MCA1 through Maggie, a Lattice iCE5LP4K FPGA on
SPI1. It clocks the link, passes the bottom speaker's slot to an amplifier the
AOP firmware drives and the top speaker's slot to a CS35L26 on I2C2. The
earpiece is the top speaker too: its CS35L26 also takes the codec's receiver
output as PDM.

What changes

  • AOP: the iPhone 7's firmware gets its bbOn boot argument from
    apple,has-baseband. Without it the firmware logs "ARC service not found"
    and "BTMSPK service not found", and every amplifier request fails. Only
    apple,d10-aop changes. Two small helpers: a service's node is also found
    by its lowercase name ("SPUApp" is the spuapp node), and
    apple_aop_call_status() returns a service's own return code, since the
    amplifier service answers "busy" while an amplifier ramps.
  • soc: apple: Add the iPhone 7's AOP SPUApp service: the MCLK and enable of
    the loudspeaker path as two clocks, and the AOP's amplifiers, configured from
    the ADT's SPUApp node.
  • ASoC: codecs: Add the Cirrus Logic CS35L26, the top speaker's and
    earpiece's amplifier, with its PDM and TDM inputs.
  • ASoC: apple: Add the iPhone 7's Maggie FPGA: loads the bitstream, then
    runs the loudspeaker frame. Its register port is read at 4 MHz, since above
    6 MHz reads come back one to three bits late on the A10's SPI.
  • ASoC: apple: s8000-mca: Add the iPhone 7's loudspeaker link (MCA1, a
    clock consumer of Maggie), and SmartIO endpoint 0x2a. As on the iPhone 6s,
    the output is capped at -12 dB until there is speaker protection.
  • ASoC: cs42l71: Add the iPhone 7's receiver output, the PDM path to the
    top amplifier. Its PDMOUT pin is disabled unless a board routes it, so
    nothing changes for the iPhone 6s.
  • Device tree: MCA1 in t8010.dtsi. The SPUApp node, the CS35L26, Maggie,
    MCA1 and the sound card's second link in t8010-7.dtsi.
  • defconfig: APPLE_AOP_SPUAPP, SND_SOC_CS35L26 and
    SND_SOC_APPLE_MAGGIE as modules.

Firmware

Maggie has no flash. Its bitstream is the payload of
Firmware/Maggie/AppleMaggieFirmwareImage.im4p, the same file in the iPhone 7
and 7 Plus restore images. That payload ends with the CRC check and wake-up
commands. The driver sends those itself, with a read back of the CRC in
between, so it leaves them out of the image and takes the CRC from them. The
orchard pull request that installs the file is OrchardLinux/orchard#410.

Testing

iPhone 7 (D10) booted from RAM, this branch on main at 218ceb9, with the
firmware layer from the recipe in OrchardLinux/orchard#410 (no files of my own). A tone on
each output, recorded by two of the phone's microphones and by a webcam
across the desk. The level is the tone's, and the quiet parts of each
recording sit 45 to 60 dB lower.

Output Front mic (Mic 4) Bottom mic (Mic 1) Webcam
Bottom speaker, 1 kHz in slot 0 16 dB 34 dB 52 dB
Top speaker, 1.5 kHz in slot 1 42 dB 7 dB 45 dB
Earpiece, 700 Hz on the codec's PCM 37 dB -9 dB -6 dB
  • Each speaker is loudest at the microphone next to it, at the frequency it
    was given. The earpiece is loud at the front microphone and faint across the
    desk.
  • All drivers load at boot, the FPGA configures, and its CRC reads back right.
  • After a suspend to idle, woken by the power button, the three outputs measure
    the same.
  • The AOP firmware logs spu.cpp:854: AssertMacros: error: 0 once at startup.
    Nothing fails after it.

Other devices

  • iPhone 7 Plus (D11, D111): its ADT has the same wiring and its restore image
    the same FPGA image, so the nodes are in the shared t8010-7.dtsi.
    Untested.
  • iPhone 6s: only the codec's new, disabled PDMOUT pin reaches it.
  • Other AOP boards: unchanged.

🤖 Generated with Claude Code

…n too

apple,has-baseband now also reaches the iPhone 7's AOP firmware, as its
bbOn boot argument. That firmware serves the loudspeaker amplifiers only
when it is set.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The iPhone 7's AOP firmware (aopfw-t8010aop) serves the loudspeaker
amplifiers it drives only when its bbOn boot argument says the phone has
a baseband, as iBoot passes it from the ADT's iop-aop-nub. Without it,
the firmware logs "ARC service not found" and "BTMSPK service not found"
at startup, and every later request for those amplifiers fails with
kIOReturnUnsupported.

Pass bbOn from apple,has-baseband on the iPhone 7, next to its AOP
target. The other boards' images are unchanged.

Tested on an iPhone 7 (D10) booted from RAM: the AOP no longer reports
missing amplifier services, and the bottom speaker plays.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The ADT's iop-aop-nub of the iPhone 7 has has-baseband, which iBoot
passes to the AOP firmware as its bbOn boot argument.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
Device tree node names are lowercase, while firmware service names may
have capitals, like the iPhone 7's "SPUApp". Try the name in lowercase,
with '-' for '_', when no node has the service's own name.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
apple_aop_call() turns every return code above INT_MAX into -EIO. The
iPhone 7's SPUApp service answers a request it accepted but has not
finished with 0xe00002d5 (busy), and its caller then has to poll. Add
apple_aop_call_status(), which returns the code as it came, and build
apple_aop_call() on it.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The iPhone 7's AOP firmware has a loudspeaker service, "SPUApp". It
switches the MCLK and the enable of the loudspeaker path, which the
binding makes its two clocks, and drives two amplifiers on the AOP's
own I2C bus. Their configurations come from the ADT's SPUApp node.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
On the iPhone 7 the AOP firmware owns two lines of the loudspeaker path,
the 12 MHz MCLK of the top amplifier and the Maggie FPGA (property 0xd0)
and the FPGA's enable (0xd1). It also drives the bottom speaker's and
the Taptic Engine's CS35L25 amplifiers, which sit on its own I2C bus:
0xd3 configures one by name, and 0xd2 sets its power state.

The firmware stops on an "off" for a line that is not on, so both lines
are clocks here, and the clock framework keeps the counts. An amplifier
gets its configuration from the device tree before its first state
change. A state change answers 0xe00002d5 (busy) while the amplifier
ramps, and reading the property back gives the result.

Tested on an iPhone 7 (D10) booted from RAM: with the FPGA's clocks
from this driver, the bottom speaker's amplifier turns on and off for
each stream, and a 1 kHz tone on it reaches the phone's bottom
microphone about 80 dB above the noise floor.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The CS35L26 is the boosted amplifier of the iPhone 7's top speaker,
which is also its earpiece. It has a PDM and a TDM input and no DAI of
its own. Its MCLK comes from the Always-On Processor.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The iPhone 7's top speaker, also its earpiece, has a CS35L26 on the AP's
I2C bus. There is no public datasheet. The register map has 8-bit
addresses and data, and this driver writes the sequences iOS writes:
one for the PDM input, which carries the codec's receiver output, and
one for the TDM input, which carries the top speaker's slot of the
loudspeaker frame. The amplifier comes out of reset set up for the
board's buses. As in iOS it stays in reset while it does not play, and
the speaker monitor next to it (an AD81006 at 0x21) goes to standby
whenever it powers up.

Tested on an iPhone 7 (D10) booted from RAM: a tone through either input
reaches the microphone next to the top speaker 85 to 90 dB above the
noise floor.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
Maggie is a Lattice iCE5LP4K FPGA on SPI between the iPhone 7's
loudspeaker link and its amplifiers. It clocks the link and passes each
speaker's slot to its amplifier, and it is loaded with Apple's bitstream
at boot.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The iPhone 7's loudspeakers sit behind a Lattice iCE5LP4K FPGA on SPI1.
It provides MCA1's TDM clocks, fifteen 16-bit slots and ten idle bit
clocks per frame at 48 kHz, and passes the bottom speaker's slot to an
amplifier the AOP drives and the top speaker's to the CS35L26.

The bitstream is the payload of the restore image's
Firmware/Maggie/AppleMaggieFirmwareImage.im4p, which ends with the CRC
check and wake-up commands. The driver loads it the way iOS does, which
sends those commands itself with a read back of the CRC in between, so
they stay out of the image and the CRC comes from them. The driver then
takes the FPGA's MCLK and enable from the AOP while the frame runs and
turns the bottom amplifier on through the AOP's SPUApp service. The
FPGA's register port returns reads one to three bits late above 6 MHz on
the A10's SPI, so registers are accessed at 4 MHz, where its ID reads
back exactly.

Tested on an iPhone 7 (D10) booted from RAM, with the image's payload
as the firmware: the FPGA configures and its CRC reads back right, and
tones in slot 0 and slot 1 come out of the bottom and the top speaker.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
apple,t8010-mca-maggie is the A10's MCA1 link to the iPhone 7's
loudspeakers, playback only and a consumer of the Maggie FPGA's clocks,
with fifteen 16-bit slots and ten idle bit clocks per frame.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The D10 ADT's audio-speaker-top iisConfig under MCA1 gives a clock
consumer with format flags 0x12, fifteen 16-bit slots in a fixed 250-bit
frame, a one-bit sync pulse, and the bottom and top speakers in slots 0
and 1. The Maggie FPGA provides the clocks. The SmartIO shim words are
virtual-mca1a's for endpoint 0x2a (FIFO 0x120, trigger 0x90). As on the
iPhone 6s, the output is capped at -12 dB until there is speaker
protection.

Tested on an iPhone 7 (D10) booted from RAM: each speaker plays its slot.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The D10 ADT gives SmartIO DMA endpoint 0x2a to MCA1, the loudspeaker
link, for transmit. Add it to the A10's range table.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The iPhone 7 has no headphone jack. Its earpiece is the top speaker,
whose amplifier takes the codec's receiver output as PDM. Add that output
as a DAPM path from the XSP's playback to a "PDMOUT" pin, with the
values iOS writes: the PDM output and the DAC up, the headphone driver
down, the level from DAC-A and the PDM path's gain ("Receiver Playback
Volume"), and DAC-B at -62 dB. The headphones stay off while the
receiver plays.

PDMOUT is disabled as a pin, so it counts only where a board routes it
on to an amplifier's input. Nothing changes for the iPhone 6s, which
does not route it.

Tested on an iPhone 7 (D10) booted from RAM: a tone on the codec's PCM
reaches the front microphone about 90 dB above the noise floor, and is
faint at the webcam across the desk, as an earpiece should be.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
MCA1 is the iPhone 7's loudspeaker link, with SmartIO endpoints 0x2a and
0x2b. It is disabled here, for the boards to enable.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
The AOP's SPUApp service gives the MCLK and enable of the loudspeaker
path and drives the bottom speaker's amplifier, with the configurations
from the ADT's SPUApp node. The CS35L26 on I2C2 drives the top speaker,
which is also the earpiece. The Maggie FPGA on SPI1 chip select 1 clocks
MCA1, which reaches it through the i2s-switch (aud1 to pin2, from the
ADT's function-i2s_route), and takes the codec's ASP data line as a
peripheral pin.

The sound card gets a second link, MCA1 to Maggie. The codec's PDM
output feeds the top amplifier's PDM input, Maggie's frame its TDM
input, and the bottom amplifier is Maggie's.

The iPhone 7 Plus's ADT has the same wiring and its own FPGA bitstream,
which its firmware recipe installs under the same name.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
Build CONFIG_APPLE_AOP_SPUAPP (the AOP's loudspeaker service),
CONFIG_SND_SOC_CS35L26 (the top speaker's and earpiece's amplifier) and
CONFIG_SND_SOC_APPLE_MAGGIE (the loudspeaker FPGA) as modules, which the
iPhone 7's loudspeakers and earpiece need. Only the 16K platform has
these boards, as with the CS42L71 and the A10's AOP.

Assisted-by: LLM
Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
paulscalise1 and others added 2 commits December 2, 2026 01:20
Main took the iPhone XR's speakers (OrchardLinux#75), whose Kconfig, Makefile and
defconfig lines sit next to these. Keep both sides.

Signed-off-by: Paul Scalise <paulscalise1@users.noreply.github.com>
Brings in the iPhone 7 microphones (OrchardLinux#73), the iPhone 7 cameras (OrchardLinux#86)
and the A12 AOP work (OrchardLinux#107). The AOP's d10 baseband flag stays separate
from the A12's board boot arguments; MCA1 and the loudspeaker nodes sit
next to the cameras' and microphones' nodes unchanged.

Assisted-by: LLM
Signed-off-by: Henrik Klee <henrik@goat-code.com>
@henrikklee
henrikklee merged commit c34f273 into OrchardLinux:main Dec 2, 2026
4 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