Skip to content

ASoC: tas2764: J604 amplifier init writes through the built-in quirks - #2615

Open
IronsideXXVI wants to merge 4 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-tas2764-quirks
Open

IronsideXXVI wants to merge 4 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-tas2764-quirks

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The J604 (MacBook Pro 14" M4, T8132) has six SN012776 amplifiers, and macOS 26B123 initialises each of them with writes this driver does not make (traced at boot on the J604 from the hypervisor, see #2595). This is the quirks version asked for in #2595: two of those writes go through the driver's built-in Apple quirks, applied to every SN012776, with no binding or DT change.

  • ASoC: tas2764: enable the thermal threshold 1 quirk on Apple amplifiers adds the existing TAS2764_THERMAL_TH1_DISABLE to ENABLED_APPLE_QUIRKS (0x3f -> 0x7f), so page 1 0x47 = 0x02 is written on every SN012776.
  • ASoC: tas2764: write the SDZ mode register as macOS does at init adds an init quirk next to the shutdown dance, TAS2764_SDZ_MODE_INIT (BIT(8)), which writes 0x68 to page 0 0x07, enabled for every SN012776 (mask 0x17f). The dance itself stays off; when it is on, this runs after its 0x60 write, so the register ends at 0x68 either way.

Left out: the page 1 0x19 = 0x40 write. Its effect is unknown, so it is not applied to every amplifier. I'm running a J604 A/B with and without it (amp registers read back during playback, level and THD+N of a 1 kHz tone through the built-in mics at a fixed volume, amp temperature and fault latches over a 60 s tone) and will post the numbers in #2595. If it shows no difference, 0x19 stays out; if it does, it comes as a separate change with the reason written down.

Checked on top of integration/aurora df62a8c, the same base as #2595:

  • checkpatch --strict: clean on both commits
  • sound/soc/codecs/ builds with W=1, no warnings, no errors
  • scripts/dtc/apple-dt-check.sh and the ADT coverage and DART checks: pass (no DT change)
  • tools/asahi/run-host-tests.py: on my arm64 host it fails the same tests as the base (no rustc 1.96 there), plus cio-native-tests and dart-cio-owner-tests, which failed in the full run and pass when I rerun them alone. Neither touches this code; CI here is the real check.

#2595 stays open until the 0x19 A/B is in; after that I'll close it in favour of this one.

Assisted-by: LLM (Claude:Opus 5.5, Claude:Fable 5.2)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the quirks version. Two concerns before this becomes the default for every SN012776:

  • tas2764-quirks.h:10: adding TAS2764_THERMAL_TH1_DISABLE to ENABLED_APPLE_QUIRKS switches off thermal threshold 1 on every SN012776 the driver binds, which is about 26 board files (M1 Pro/Max through M5), on the strength of one J604 trace. The original quirks commit (f33b01e) enabled "all of them to be safe" and still left bit 6 out, so this reverses a deliberate choice. Could the commit say what threshold 1 gates? If it feeds the over-temperature latch in INT_LTCH0, the SDZ group fail-closed path (tas2764.c:114-145) would see that fault later or not at all. If the effect can't be named from the datasheet, it needs a measurement that exercises it: a sustained stream at the protected level on one amp with speaker protection running, TAS2764_TEMP and INT_LTCH0..4 read back, with and without this bit. Playback and sense rows alone don't exercise a thermal threshold. Until then I'd keep bit 6 out of the default mask.
  • tas2764-quirks.h (TAS2764_SDZ_MODE_INIT): please name bit 3 of page 0 0x07, or say it is undocumented. This also makes immediate SDZ shutdown the default without the 0xfd pre/post writes that the shutdown-dance comment says it is meant to run under, and only the J604 has run that. A stream stop/start loop on another Mac, with the fault latches read afterwards, would cover the over-current-on-stop case.
  • Both commits are missing a Signed-off-by: line.

Leaving page 1 0x19 out until the A/B is in sounds right.

Assisted-by: LLM (Claude:Opus 5.5)

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks Ryan. Agreed, bit 6 stays out of ENABLED_APPLE_QUIRKS until I can either say what threshold 1 gates or show it with a measurement: a sustained stream at the protected level with speaker protection on, logging TAS2764_TEMP and INT_LTCH0..4 with and without bit 6. I'll also name page 0 0x07 bit 3 or say plainly that it's undocumented, and answer the SDZ point with the next push.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide pushed two commits on top (head 1b127df):

  • bea4b8c takes TAS2764_THERMAL_TH1_DISABLE back out of ENABLED_APPLE_QUIRKS (0x17f -> 0x13f), as f33b01e had it. The TAS2764 data sheet (SLOS998A, 8.9.113) calls page 1 0x47 TG_EN, reset 0xab: bit 0 enables thermal threshold 1, bit 1 thermal threshold 2. So the quirk's 0x02 keeps threshold 2 only. The data sheet doesn't say which temperature threshold 1 is or what the amp does when it's crossed, so that isn't an explanation yet. The register is now written by name (TAS2764_TG_EN, TAS2764_TG_EN_TH2), and bit 6 only comes back with the TAS2764_TEMP / INT_LTCH0..4 measurement.
  • 1b127df names page 0 0x07. It's MISC_CFG2 (8.9.11, reset 0x20): SDZ_MODE in bits 7:6, SDZ_TIMEOUT in 5:4, DVC_RAMP_RATE in 3:2. Bit 3 is the high bit of the ramp rate, so macOS's 0x68 is immediate SDZ, the 6 ms timeout (the reset value), and DVC_RAMP_RATE=10b, which ramps the digital volume 0.5 dB per 8 samples instead of per sample. The dance's 0x60 is the same thing without the ramp rate.

On the SDZ point: I have no other Mac to run the stop/start loop on, so I took immediate SDZ out of the default. The init quirk is now TAS2764_DVC_RAMP_INIT and only updates the ramp rate field. SDZ_MODE stays at its reset value unless the shutdown dance is on, and with the dance on the register ends at 0x68, the same as macOS. If you'd rather keep the ramp rate out of the default too until a trace from another Mac shows the same write, I'll drop it.

These are the TAS2764's names. I'm assuming the SN012776 follows them, as the driver already does for the other registers.

The J604 rows (bit 6 with the temperature and latches logged, and a stream stop/start loop with the latches read) will come here with the 0x19 A/B.

The missing Signed-off-by: lines are mine to add, and I'll add them myself before this is ready.

Checkpatch --strict is clean on both, a W=1 build of sound/soc/codecs has no warnings, and the host tests and DT checks give the same results as on the base.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Checked 1b127df. Both points are addressed. ENABLED_APPLE_QUIRKS is 0x13f, so threshold 1 stays enabled. 0x07 is now named from the data sheet (MISC_CFG2: SDZ_MODE, SDZ_TIMEOUT, DVC_RAMP_RATE), and the default writes only the ramp-rate field through regmap_update_bits(), so immediate SDZ stays with the shutdown dance. A ramp of 0.5 dB per 8 samples is still about 3,000 dB/s at 48 kHz, so a volume cut lands within a few ms.

Still open: none of the four commits carries a Signed-off-by: line.

Assisted-by: LLM (Claude:Opus 5.5)

The driver defines TAS2764_THERMAL_TH1_DISABLE (page 1 register 0x47 =
0x02) but leaves it out of ENABLED_APPLE_QUIRKS. macOS 26B123 makes this
write when it initialises each SN012776 on the J604 (traced at boot from
the hypervisor), so enable the quirk for every SN012776.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
macOS 26B123 writes 0x68 to page 0 register 0x07 when it initialises
each SN012776 on the J604 (traced at boot from the hypervisor). The
shutdown-dance quirk writes 0x60 to the same register for an immediate
SDZ shutdown, but that quirk is off by default.

Add an init quirk next to the dance that writes 0x68, and enable it for
every SN012776. It runs after the dance's own init write, so the
register ends at 0x68 when the dance is enabled too.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Page 1 register 0x47 is TG_EN in the TAS2764 data sheet (SLOS998A,
8.9.113, reset 0xab): bit 0 enables thermal threshold 1, bit 1 thermal
threshold 2. The quirk writes 0x02, which leaves threshold 2 only. The
data sheet does not say which temperature threshold 1 is or what the
amplifier does when it is crossed, and one J604 boot trace is not enough
to turn it off on every SN012776.

Take TAS2764_THERMAL_TH1_DISABLE back out of ENABLED_APPLE_QUIRKS, as
the original quirks commit had it, and write the register by its name.
It can come back with a measurement of what threshold 1 does.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…efault

Page 0 register 0x07 is MISC_CFG2 in the TAS2764 data sheet (SLOS998A,
8.9.11, reset 0x20): SDZ_MODE in bits 7:6, SDZ_TIMEOUT in bits 5:4,
DVC_RAMP_RATE in bits 3:2. macOS's 0x68 is immediate SDZ, the 6 ms
timeout (the reset value) and DVC_RAMP_RATE=10b, which ramps the digital
volume by 0.5 dB per 8 samples instead of per sample. Bit 3 is the high
bit of that ramp rate. The shutdown dance's 0x60 is the same without the
ramp rate.

Immediate SDZ without the dance's page 0xfd writes around shutdown has
only run on the J604, so it should not become the default for every
SN012776. Rename the init quirk to TAS2764_DVC_RAMP_INIT and have it
update only the ramp rate field. SDZ_MODE stays at its reset value
unless the shutdown dance is enabled; with the dance enabled the
register ends at 0x68, as macOS leaves it.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Force-pushed d96df02: the same four commits with my Signed-off-by added. No code change (same tree as 1b127df), so the review of the last two commits still applies.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR checklist review at a12eae78a916 (CI: host-tests passing).

The final tree at a12eae78a916 looks solid: ENABLED_APPLE_QUIRKS is 0x13f (leaving TAS2764_THERMAL_TH1_DISABLE and TAS2764_SHUTDOWN_DANCE off by default), TAS2764_MISC_CFG2 and TAS2764_TG_EN fields are properly named from the datasheet, and tas2764_apply_init_quirks() updates only DVC_RAMP_RATE via regmap_update_bits() (verified against tas2764_i2c_regmap cache/resume sync). Commit attribution (§4) is clean: all commits carry human author/committer and Signed-off-by: only, and the PR body carries Assisted-by:.

Blockers:

  1. §3 Safety / bisectability — unsafe intermediate commits in branch history: integration/aurora merges PRs with merge commits rather than squashing, so commits 1 and 2 (8cdfd6dee8 and 1c1039d186) would enter mainline history with TAS2764_THERMAL_TH1_DISABLE enabled (0x3f -> 0x7f) and immediate SDZ enabled without the shutdown dance (0x68, 0x17f) across all ~26 SN012776 boards before commits 3 and 4 (897c89adf1, a12eae78a9) revert both. A git bisect landing on commits 1–2 would disable thermal threshold 1 on speaker amps. Please fold/squash the branch into clean commit(s) that never introduce those intermediate states.
  2. Stale PR description: The PR body still describes the old 2-commit series (0x3f -> 0x7f enabling TAS2764_THERMAL_TH1_DISABLE, and TAS2764_SDZ_MODE_INIT / 0x17f), contradicting the live head (0x13f, TAS2764_DVC_RAMP_INIT).

Still needed (§5 Evidence):

  • No hardware test row on a12eae78a916 yet. Because ENABLED_APPLE_QUIRKS applies to every SN012776 Mac (~26 boards), please post a J604 run on the squashed head (and request a row on a second SN012776 Mac): MISC_CFG2 readback after init/resume, playback + stream stop/start fault-latch check (INT_LTCH0..4), and the §5 regression line (0 SELinux denials, 0 failed units, 0 new kernel errors).

Minor nits (non-blocking):

  • sound/soc/codecs/tas2764-quirks.h:174 still lists DVC ramp rate under Other setup TODOs.
  • sound/soc/codecs/tas2764.c:1483 can use the new TAS2764_TG_EN macro instead of raw TAS2764_REG(0x1, 0x47).

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked a12eae7: same tree as 1b127df, the head reviewed last, and all four commits now carry your Signed-off-by, which was the only open item. Approving: threshold 1 stays enabled (0x13f), and the MISC_CFG2 default only touches the ramp-rate field, so no protection setting moves. No speaker playback was needed for this check; the init is register-level.

Assisted-by: LLM (Claude:Opus 5.5)

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.

3 participants