Skip to content

ASoC: tas2764: J604 amplifier init writes as macOS does them - #2595

Closed
IronsideXXVI wants to merge 3 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-tas2764-init-writes
Closed

IronsideXXVI wants to merge 3 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-tas2764-init-writes

Conversation

@IronsideXXVI

Copy link
Copy Markdown
Contributor

The J604 (MacBook Pro 14" M4, T8132) has six SN012776 amplifiers. macOS 26B123 initialises each of them with three writes this driver does not make. I traced it at boot on the J604, recording the I2C3 controller from the hypervisor's entry. Every other write of that init matches the driver: the six enabled quirk sequences, the DC blockers and the brownout block from the boot loader's ADT copies, and the TDM setup. The three:

  • page 0 0x07 = 0x68
  • page 1 0x19 = 0x40
  • page 1 0x47 = 0x02

This series:

  1. dt-bindings: an optional apple,init-writes property, a list of (page, register, value) byte triples.
  2. tas2764: apply the triples after the built-in quirks at initialisation. Each is checked against the writeable-register list at probe, which gains page 1 0x19.
  3. t8132-j604: macOS's three on all six amplifiers.

Machines without the property are unchanged.

This is the init half of #1894, split out as I said there; #1894 keeps only the shutdown dance and stays a draft. @davishann15-commits ran this property alone on a second J604 (row 1 in #1894): the speakers play clean, 0x07 reads 0x68, and 0x02 reads 0x80 during playback, so V and I sense stay powered. No amp faults.

Checked on top of integration/aurora df62a8c:

  • checkpatch --strict: clean on each patch
  • tools/asahi/run-host-tests.py and scripts/dtc/apple-dt-check.sh, as the CI runs them: the same results as on the base (checkpatch clean; run-host-tests.py fails only the tests that also fail on the base on my arm64 host, no rustc 1.96 there; apple-dt-check.sh: binding ok, no new DT warnings; ADT coverage and DART power-domain checks pass)
  • the codec builds with W=1 and no warnings

The kernel my J604 runs today (linux-aurora 1.1125) carries the same init-writes code, together with the shutdown dance. Its log has no tas2764 errors after boot.

Tested on the J604 only.

Apple machines can initialise their SN012776 amplifiers with a few
register writes beyond the driver's own sequence. Add a property that
lists them as (page, register, value) byte triples.

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
macOS 26B123 initialises each of the J604's six SN012776 amplifiers
with three writes the driver does not make (traced at boot on the J604
with the I2C3 controller recorded from the hypervisor's entry): page 0
register 0x07 = 0x68, page 1 register 0x19 = 0x40 and page 1 register
0x47 = 0x02. Every other write of that init matches the driver: the six
enabled quirk sequences, the DC blockers and the brownout block from
the boot loader's copies of the ADT, and the TDM setup.

Apply the apple,init-writes triples after the built-in quirks at
initialisation, each checked against the writeable-register list (page 1
register 0x19 joins it).

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Set apple,init-writes on the J604's six SN012776 amplifiers to the three
writes macOS 26B123 makes at their initialisation and the driver does
not: page 0 register 0x07 = 0x68, page 1 register 0x19 = 0x40, page 1
register 0x47 = 0x02.

Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for splitting this out of #1894 and for the second J604 row; the probe-time check against the writeable-register list is a good guard.

One question on where the writes live. We select behaviour by a hardware property rather than by the machine it was traced on. The driver applies its built-in Apple quirks to every SN012776 (tas2764.c:1046), but these three macOS init writes reach only the J604, through a raw register list in its board file (t8132-j604.dts:122, repeated at 137-197, applied at tas2764.c:1056-1061).

If macOS writes the same three values on every SN012776 Mac, they belong with the built-in init quirks, so every Mac with this amplifier gets them, including the V/I sense staying powered during playback. If the values really differ per board, could the binding and the DT comment say what about the J604 makes them different?

Could you also name what page 1 0x19 and 0x47 control? We can run playback and sense rows on our M1 Pro, M2, M4 Pro and A18 Pro if this becomes the default.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks. What I know about the three:

  • I have traced them only on the J604 (macOS 26B123, at boot). I have no trace from another SN012776 Mac, so I can't say whether macOS makes the same writes there. I know of nothing that makes the J604 different. The board file is just as far as my evidence goes.
  • Page 1 0x47 = 0x02 is already in the driver: it is TAS2764_THERMAL_TH1_DISABLE (BIT(6) in tas2764-quirks.h), which is defined but left out of ENABLED_APPLE_QUIRKS (0x3f). macOS turns thermal threshold 1 off on the J604, and the driver has that quirk off on every Mac.
  • Page 0 0x07 is the register the shutdown-dance quirk sets to 0x60 for an immediate SDZ shutdown. macOS writes 0x68 there at init.
  • Page 1 0x19 = 0x40 is not in TI's public datasheet, and I don't know what it controls.

I agree with selecting by hardware. If your machines show the same writes under macOS, or your playback and sense rows come back clean with them as built-in quirks, they belong in the quirks and I'll drop apple,init-writes. If it helps your rows, I can put up that version as its own branch.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, that is very helpful. Since page 1 0x47 is the existing thermal-threshold quirk bit and page 0 0x07 is the register the shutdown quirk already uses, those two fit naturally with the built-in quirks, and yes please to the quirks version as its own branch.

For page 1 0x19, we would rather not apply a write with an unknown effect to every speaker amplifier. Could the quirks version leave it out, unless a J604 A/B with and without it shows what it changes? If it turns out to matter, a documented reason can come with it then.

We will run the playback and sense rows we offered once that branch is up.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Sounds good. I'll do the quirks version as its own branch: page 1 0x47 through the existing thermal-threshold quirk bit and page 0 0x07 alongside the shutdown quirk, applied to every SN012776, and page 1 0x19 left out. I'll run a J604 A/B with and without 0x19; it only comes back, with a written reason, if that shows a difference. I'll link the branch here when it's up.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide the quirks version is up as its own branch: https://github.com/IronsideXXVI/linux/tree/j604-tas2764-quirks (on integration/aurora df62a8c, the same base as this PR).

  • ASoC: tas2764: enable the thermal threshold 1 quirk on Apple amplifiers adds TAS2764_THERMAL_TH1_DISABLE to ENABLED_APPLE_QUIRKS (0x3f -> 0x7f), so page 1 0x47 = 0x02 goes to 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)), that 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.

No page 1 0x19, and no binding or DT change. Locally: checkpatch --strict clean on both commits, sound/soc/codecs/ builds with W=1 and no warnings, dt checks pass, and the host tests fail the same set as the base.

Next is the J604 A/B with and without 0x19: the amp registers read back during playback, level and THD+N of a 1 kHz tone recorded through the built-in mics at a fixed volume, and amp temperature and fault latches over a 60 s tone. I'll post the numbers here. If it shows no difference, 0x19 stays out.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the quirks branch. Both writes going through the built-in quirk mechanism, applied to every SN012776, with no binding or DT change and 0x19 left out, is the shape we hoped for.

Could this PR be moved to that branch (or a new PR opened from it), so CI runs on the exact commits? We'll run the playback and sense rows on it then, alongside your 0x19 A/B.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide opened #2615 from j604-tas2764-quirks (3188e53, on integration/aurora df62a8c), so CI runs on exactly those two commits. I left this PR as it is so the review history here stays readable.

I'll keep this one open only until the 0x19 A/B is in, post the numbers here, and then close it in favour of #2615. If you'd rather have it closed now and the A/B posted on #2615, say so and I'll close it.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Thanks for opening #2615. It carries the version we'll take: both writes through the built-in quirks for every SN012776, no binding or DT change, and page 1 0x19 left out. So we won't merge this one.

To your question: closing this now and posting the 0x19 A/B on #2615 keeps the discussion in one place, and the history here stays readable after it's closed. It's your call, though; leaving it open until the A/B is in is fine too.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr thanks. Agreed, keeping it in one place is better: I'll close this one in favour of #2615 and post the 0x19 A/B there.

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