Skip to content

ASoC: cs42l84: ring-sense plug detection for the J604 - #1895

Merged
RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-cs42l84-init
Nov 21, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-cs42l84-init

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

On the J604 (MacBook Pro 14-inch, M4) the headset jack reports the plug on ring sense. With the tip-sense scheme this driver uses, tip sense keeps re-asserting with nothing plugged in: about 1000 interrupts a second at idle, each costing two I2C reads.

A new boolean, cirrus,ring-sense-detect, selects ring-sense detection. With it the driver:

  • writes the detect block setup: TIP_SENSE_CTL2 mode only, bit 5 set in 0x1471, 0x1478 = 0x8f, 0x1480 = 0x80,
  • masks tip sense (TSRS_PLUG_INT_MASK = 0xfc) and takes plug and unplug from the ring-sense state in TSRS_PLUG_STATUS,
  • reads REMOTE_BUTTON_STATUS1 (0x1484) once after the setup and on every codec interrupt. The 0x1480 write unmasks two more sources whose status is latched from power-up; unread, it holds the interrupt line asserted. The polled button bits are not affected.

Probe holds irq_lock from the detect setup until the masks are written and the first ring state is read, and runs the headset detection itself when a plug is already in. The resume after a deep sleep gets the same setup as probe.

Where the values come from. Only from an I2C trace I took on this J604: macOS booted under the hypervisor with the I2C controller's MMIO window traced, codec at 0x4b, nothing plugged in. The addresses, the values and their order are the ones in that trace. Apart from TIP_SENSE_CTL2, the detect block registers have no public description, so they are written by address with a comment that says where the values were measured, that what the single bits do is not known, and that no other machine has been measured.

What this no longer does. The earlier heads also added chip setup for every machine (a soft reset, the 0x31xx block, 0x3065, the pad slew rates, a DAC_CTL1 change). That is gone. Machines without the property get no new register writes and keep the tip-sense scheme as before. cs42l84.h is unchanged from the base.

This series:

  1. dt-bindings: add cirrus,ring-sense-detect.
  2. cs42l84: ring-sense plug detection when the property is set.
  3. t8132-j604: set cirrus,ring-sense-detect on the headset codec.

Checked on integration/aurora 5b596e6:

  • checkpatch --strict: 0 errors, 0 warnings, 0 checks on each of the three commits
  • cs42l84.o builds with W=1 under clang 18.1.3 and gcc 13.3 with no warnings
  • t8132-j604.dtb builds with W=1; the three warnings it prints are in t8132.dtsi, t8132-dcp.dtsi and t8132-gpu.dtsi, none from this series
  • scripts/dtc/apple-dt-check.sh against the base: 138 DTBs, no new warnings, none removed
  • dt_binding_check on cirrus,cs42l84.yaml passes (dtschema 2026.9)
  • tools/asahi/run-host-tests.py on this head and on the base, same machine and toolchain (rustc 1.100.0): 422/451 and 424/451. 27 failures are the same on both and are my setup: the four g15 tests want rust 1.93.1, which is not installed here, the 22 sep-suspend-errors tests fail at link, and one tbnet-refill mutant (refill-count). The two extra on this head are also tbnet-refill mutants (no-cancel, worker-allocation). Run on its own, tbnet-refill passes 5/5 on both trees, twice each, and this series does not touch tbnet

What ran on the J604: an earlier list-based version of the ring-sense and latch changes did, and with it the codec took 0 interrupts in 10 s at idle. This head has not run on the J604 yet. I'll post the rows before asking for another look: codec interrupts over 10 s at idle, the same after a deep sleep, headphones, headset with mic, the button, and boot with the headset already in.

This is independent of #1894, though both touch t8132-j604.dts; whichever lands second gets rebased.

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

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Please hold this one for now. We found a side effect on the J604 (MEASURED 2026-11-14).

One of the macOS probe writes, 0x1480 = 0x80, unmasks bits 5-6 of REMOTE_BUTTON_STATUS1 (0x1484). macOS reads 0x1484 right after that write: it reads 0x60, the latch clears on read, and the codec is quiet from then on. This driver reads 0x1484 only for button polling, so the latch stays set and holds the interrupt line asserted. With nothing plugged in that is about 990 codec interrupts/s, plus about 1980/s on its I2C bus, which macOS never sees.

The fix is to read 0x1484 once after the apple,init-writes and in every codec interrupt, as macOS does; button polling is unchanged. It is built and runs on our next J604 kernel. Once the J604 shows 0 codec interrupts at idle, I'll add it to this PR as a fourth commit with the measurement.

IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 14, 2026
…terrupt storm)

UPSTREAM.md: the cs42l84 pull request is held by us. One of the macOS writes it
carries unmasks a status latch the driver never reads, which keeps the codec's
interrupt asserted at idle; the fix is built for the next kernel.
@davishann15-commits

Copy link
Copy Markdown

Tested on a J604 (MacBook Pro 14", M4, Mac16,1; os-fw 26.6.2, system-fw 27.0; aura 1.0.0b13). The kernel was alarm-aurora's pkgrel 38 recipe on integration/aurora 7c71d6d, plus #1543, #1894, #1895, #1917, #1918, #1919 and #1922. It booted on its own J604 tree as an aura-try trial. Userspace: Hyprland 0.57.2, mesa-aurora 26.3.0_devel.202611130318, speakerguardd-v2 1.0.0alpha.1-40.

apple,init-writes is on the J604's cs42l84 node, and the codec probes cleanly (cs42l84 0-004b: Cirrus Logic CS42L84, Revision: 36, no errors). With the jack profile of alsa-ucm-conf-asahi#18 the jack card resolves its HiFi verb. Not tested: playback or headset detection through the jack (no wired headphones at hand).


Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening and looking, reviewed it, and am responsible for it.

Assisted-by: LLM

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

The hold is resolved: I pushed a 4th commit, c0a5945 "ASoC: cs42l84: acknowledge the remote status latch after apple,init-writes".

The cause: the init writes move 0x1480 from 0xe0 to 0x80, which unmasks bits 5 and 6. Their status latches in REMOTE_BUTTON_STATUS1 (0x1484) at power-up and only clears when 0x1484 is read. macOS reads it once at boot. This driver read it only for button polling, so the latch held the IRQ line asserted.

The fix: when init writes were applied, read 0x1484 once right after them and on every codec interrupt.

Measured on the J604, kernel 7.3.0 1.913, screen unlocked, nothing plugged in:

  • cs42l84 IRQ delta 0 in 10 s (it was 9918 per 10 s on 1.910). Both pasemi_apple_i2c controllers also 0 (they were about 19800).
  • The jack reports "not available", which is correct with nothing plugged in.
  • Codec and amp registers are unchanged from 1.910, and there are no codec error lines.
  • Our audio check passes (38/38 biquads, 0 xruns).

One difference from what ran: on our tree the same read sits inside the ring-sense path. This branch has no ring-sense detection, so here it is keyed on the init writes instead. It makes the same reads at the same points.

Still to do: the plug/unplug test with a headset.

Build: checkpatch --strict 0/0/0, and the codec builds with W=1 and no warnings.

Tested on the J604 only (linux-aurora 1.913).

IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 14, 2026
…p reading corrected

kernel/: the 8 patches 1.913 and 1.914 add (595 in all), same Aurora base.
1.913 (0588-0593): the thermal sensor polled every 50 ms while cool, the
ISP's old first-open workarounds dropped, the SMC's power channels in the
device tree, a wake mark at __cpu_setup, the headset codec reading its
remote status as macOS does, and a deeper G16 job queue. 1.914 (0594-0595):
the HDMI converter powered the Apple device-tree way, and the doorbell
count macOS keeps in the GPU firmware's Globals. The recipe is the
linux-aurora-next package.

STATUS.md: 1.914 is the default as linux-aurora-next with 1.913 beside it
as linux-aurora. 1.913 stalled early in boot on its first start and passed
on its second; a 1.911 build failed its gate and was never the default.
The headset codec's idle interrupt storm is gone (0 in 10 s, as macOS), so
the jack moves to parity at idle: 22 at parity, 16 short, 13 untested.
Correction: 1.910's deep-sleep reset was in the resume stub's 60 s window,
not in __cpu_setup; every deep sleep since 1.905 slept and woke before the
reset. The GPU's fourth idle fix is in 1.914, not measured yet.

UPSTREAM.md: aurora-silicon/linux#1895's hold resolved by a fourth commit;
#1894 held on an outside J604 test that reports silent speakers.
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

I force-pushed to fix the dt-checks failure (apple,init-writes: [...] is too short).

The cause is in the binding. It gave maxItems: 64 without minItems. dtschema's _fixup_items_size() then sets minItems to the maxItems value, so the J604's 42 values counted as too short.

The binding commit now also has minItems: 2 (one register/value pair). Against the previous head, the tree differs only by that one line in cirrus,cs42l84.yaml. The other three commits are unchanged apart from their hashes. checkpatch --strict is still 0/0/0 on all four commits.

@davishann15-commits

Copy link
Copy Markdown

@IronsideXXVI The fourth commit works on a second J604.

I built this PR at c0a5945, plus #1543, #1894, #1917, #1918, #1919 and #1922, on integration/aurora 7c71d6d with alarm-aurora's pkgrel 38 recipe. Its code and DT hunks are identical to your force-pushed f0ca074 (only cirrus,cs42l84.yaml differs). It booted on its own J604 tree as an aura-try trial. With the screen unlocked and nothing plugged in:

  • Over 10 s: cs42l84 IRQ delta 0. Both pasemi_apple_i2c controllers: delta 0. The codec had raised 2 interrupts in total since boot.
  • Headphone Jack and Headset Mic Jack both read off, which is correct with nothing plugged in.
  • The only cs42l84 line in the log is Cirrus Logic CS42L84, Revision: 36. No errors.

For comparison, on our default kernel (linux 2129f55, no codec init writes) the same counters also stay at 0 in 10 s. Not tested: plug/unplug and headset buttons, since I have no wired headset here.


Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening, reviewed it, and am responsible for it.

Assisted-by: LLM

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@davishann15-commits thank you, that is the independent check this needed. It is also a fair point that your default kernel without the init writes stays at 0 too: the storm only came with apple,init-writes, which this series now handles.

Results so far for the four commits:

  • Your J604: 0 codec and 0 I2C interrupts in 10 s, jacks read off with nothing plugged in, no codec errors.
  • Ours (linux-aurora 1.913 to 1.915): the same, 0 in 10 s (9918 per 10 s before the fourth commit).

Still open on both machines: plug/unplug and headset buttons. I will post ours here when someone at our Mac has a headset plugged in.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora df62a8c and brought in line with the kernel my J604 runs (linux-aurora 1.1125); cs42l84.c here is now the same code as there.

  • New patch 4: with the init writes, plug and unplug come from ring sense with tip sense masked, the plug interrupt mask macOS sets after the same writes (0xfc).
  • Patch 5 is the old patch 4: the same REMOTE_BUTTON_STATUS1 read once after the writes and on every codec interrupt, now under the ring-sense scheme.

On 1.1125 the codec takes 0 interrupts in 10 s at idle. Plug/unplug and the headset buttons are still untested, so patch 4 has not seen a plug yet. The description is updated.

@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.

Thanks for tracking the interrupt storm down to the 0x1484 latch; reading it as macOS does is the right fix. A few things need to change before this goes in.

1. Resume after a deep sleep. cs42l84_resume() (the sleep_reset path) still sets the masks the tip-sense way:

  • with a plug in, cs42l84_set_interrupt_masks(cs42l84, 0);
  • with none, ring sense masked.

Under ring_detect that unmasks tip sense, which you measured re-asserting about 1000 times a second with nothing plugged in. It also masks the ring sense the IRQ handler now relies on. After the reset, the remote status latch comes back set until 0x1484 is read. So the first deep sleep brings the storm back. The resume path needs the same ring-detect setup as probe: the 0x1484 read, the initial ring state, and the TS-masked interrupt mask.

2. Plug detection is untested. Patch 4 changes how plug state is detected, and plug/unplug and the headset buttons haven't been tried yet. Before merge, please post a row with:

  • headphones in and out;
  • a headset with a mic, in and out;
  • a button press;
  • one of those after a deep sleep.

3. Where the writes live. This has the shape #2595 had: a raw register list in the J604 board file. Here the presence of that list also switches the jack-detect scheme (ring_detect). The direction you and Ryan settled for the amplifiers on #2615 applies here too:

  • writes macOS makes on every CS42L84 belong in the driver's own init;
  • values that really differ per board want named properties with a stated reason;
  • the ring-sense scheme shouldn't depend on whether a register blob is present.

Do you know which of the 20 are chip-level, for example what 0x31b0..0x31d4 and 0x31e8/0x31f4 control? A macOS trace from another CS42L84 Mac would settle it; the M2 and M3 laptops have this codec. If the J604 really differs, the binding and the DT comment should say what makes it different.

4. Smaller. The bounds check seq[i] > CS42L84_REVID lets the list write the device-ID and status registers. With the writes in the driver this goes away. If a list stays, it should refuse the volatile registers.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks. I'll give the resume path the same ring-detect setup as probe, and post the rows you listed: headphones in and out, a headset with a mic, a button press, and one of those after a deep sleep.

On which of the 20 writes are chip-level: I don't know yet for 0x31b0..0x31d4 and 0x31e8/0x31f4, and I'd rather find out than guess. I'll look for a CS42L84 trace from another Mac, move what's common into the driver's own init, use named properties only for what really differs on the J604, and stop tying the ring-sense scheme to the list.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora 5b596e6 (the only conflict was the J604 DT, next to the new keyboard-light block) and pushed c7e13af, with two new commits on top:

  • 8fe3761: cs42l84_resume() now gets the same ring-detect setup as probe. It reads 0x1484 after the register sync, takes the initial ring state from TSRS_PLUG_STATUS, reports the plug from it, and keeps tip sense masked. Probe and resume share cs42l84_ring_detect_setup(). Without the init writes, resume is unchanged.
  • c7e13af: apple,init-writes refuses the revision register and every volatile register.

checkpatch --strict is clean on all 7 commits, cs42l84.o builds with W=1 and no warnings on each one, and the DT check shows no new warnings across the 138 Apple DTBs.

Still open:

  • Point 2: the jack rows (headphones, headset with mic, a button, one after a deep sleep). They need someone at the Mac with a plug, so I'll post them when I have them.
  • Point 3: I have no CS42L84 trace from another Mac yet. Until one shows which of the 20 writes are chip-level, I haven't moved them, because I'd only be guessing. If anyone can run an M2 or M3 laptop under the m1n1 hypervisor, an I2C trace of the codec probe in macOS would settle it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 1.

The resume fix (8fe3761) and the volatile-register refusal (c7e13af) address points 1 and 4 of the earlier review. Points 2 (jack rows) and 3 (chip-level writes in the driver, ring sense not keyed on the list) are still open, and I have nothing to add to them. New:

  1. All seven commits carry an Assisted-by: LLM trailer (047dcfc .. c7e13af). Please drop it from the commit messages and keep only the human Signed-off-by; the disclosure goes as the last line of the PR body (Assisted-by: LLM (<vendor>:<model>)), which the body is currently missing.
  2. sound/soc/codecs/cs42l84.c:1204 and the binding say the pairs are "applied in order", but after a deep sleep regcache_sync() at cs42l84.c:1470 writes them back in register-address order (0x0203, 0x0c01, 0x1471 .. 0x3000, 0x3065, 0x31ae ..), not list order. If the order matters, resume has to replay the list; if it does not, drop "in order" from the binding and the comment so nobody relies on it.

HW row: J604, this head on integration/aurora 5b596e6: headphones in/out, a headset with mic in/out (mic type reported), one remote button press, then the same plug/unplug after an s2r deep sleep, with the cs42l84 IRQ delta over 10 s idle before and after the sleep (expect 0), plus 0 AVC / 0 failed units / 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Both done at f90e1c0.

  1. The trailer is gone from all seven commits, and the description now ends with the Assisted-by line. I've left the vendor/model part off for now and will come back on that separately.
  2. I can't show that the order doesn't matter, so resume now does what the text says. A new last commit keeps the pairs from probe and writes them again at resume, in list order, before regcache_sync(). They go past the cache (regcache_cache_bypass()): the cache already holds them, along with what the driver has changed since, and the sync then restores that as before. This commit has not run on the J604.

The description was behind the branch. It now lists all eight patches, and it no longer says the driver is byte for byte what my J604 runs: that holds for patches 1 to 5 only.

Still open, as you say: point 2 (the jack rows) and point 3 (the chip-level writes). The HW row needs someone at the Mac with a plug, so it comes with the jack rows, on this head over 5b596e6 and with the IRQ deltas before and after the sleep.

Rechecked on 5b596e6: checkpatch --strict 0 errors, 0 warnings, 0 checks on all eight; cs42l84.o builds with W=1 (clang 18) with no warnings. Commits: 123ec4a, 2eb9437, bb681c6, 39111c8, 0b89bae, ce7ae1a, f26fe4c, f90e1c0.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Coming back on the vendor/model part I left open: it's in now. The descriptions of all my open PRs in this repo end with the full Assisted-by: LLM (Vendor:Model) line.

The trailers are also off the commits on the PRs you hadn't got to yet (#1894, #1918, #1959, #1962, #1994, #1995, #2020, #2615). Those were message-only rewrites: same trees, same authorship, Signed-off-by untouched. #1998 gets the same with the rework push.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of f90e1c0: Blockers: 2.

Since 11:42Z there is one new commit (f90e1c0). The first seven commits keep the same tree as c7e13af (be031391); only their messages changed.

From the last review:

  1. Assisted-by trailers: resolved. All eight commits carry only Signed-off-by: Dylan Ironside, and the PR body ends with an Assisted-by: LLM (...) line.
  2. List order at resume: resolved. cs42l84_apply_init_writes() keeps the validated pairs (sound/soc/codecs/cs42l84.c:1242-1243). cs42l84_replay_init_writes() (:1259-1269) writes them past the cache in list order, and resume calls it (:1492) after regcache_cache_only(false) (:1481) and before regcache_sync(), so the bypass never runs with cache-only set. The regmap has no reg_defaults, so after regcache_mark_dirty() the sync writes every cached register back. A register the driver has changed since probe therefore still ends up at its cached value. The bounds (n <= 64, the u16 init_writes[64] copy) are fine.

Still open from the earlier review (not repeated here): the jack rows (headphones, headset with mic, button, after deep sleep), and moving the chip-level writes into the driver so that ring-sense detection doesn't depend on whether the list is present.

Nit: cs42l84.c:1501 "The sync wrote macOS's probe writes back" is now the replay plus the sync. Say "The replay wrote ...".

HW row: J604, this head on integration/aurora 5b596e6: headphones in/out, headset with mic in/out (mic type reported), one remote button press, then the same plug/unplug after an s2r deep sleep (this exercises the new replay commit, which has not run yet). Include the cs42l84 IRQ delta over 10 s idle before and after the sleep (expect 0), plus 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks Ryan. I looked at where those writes come from. macOS's driver for this codec makes the same register writes in the M4 and M2 kernels, and none of the values depends on the machine. The only per-machine inputs it reads are whether ring sense is on (and inverted), DC ID and the MCLK source. So the writes are chip setup, and the driver now makes them itself, with the registers named, at probe and again at resume before the cache is written back.

The apple,init-writes list and its binding property are gone. Ring-sense detection now comes from a boolean, cirrus,ring-sense-detect, the same switch as macOS's enable-ringsense, and the detect block is only set up when it is there. Machines without it keep tip sense as before. The soft-reset register is volatile now, so a cache sync never resets the codec partway through. The comment nit is fixed too.

I also squashed the series into the three commits that stay (binding, driver, J604 DTS), so no commit adds the list and a later one takes it out. The final tree is the same as the unsquashed rework. The description is updated for the new head 1126b15.

Checkpatch, the W=1 builds with clang and gcc, and apple-dt-check with dt_binding_check are clean. The host tests differ from the base only in five Thunderbolt/CIO suites, none in sound, and all five pass on both the head and the base when run alone. The numbers are in the description.

None of this new head has run on the J604 yet. The jack checks (headphones, headset with mic, button, and after a deep sleep) will follow on 1126b15. The tip-sense path on a machine without the property hasn't run either. If anyone with an M2 or M3 and the headphone jack can try one playback and a plug/unplug, that would cover it.

@IronsideXXVI IronsideXXVI changed the title ASoC: cs42l84: J604 headset codec probe writes as macOS does them ASoC: cs42l84: set the chip up as macOS does, ring-sense plug detection for the J604 Nov 21, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 1126b15: Blockers: 2.

Since f90e1c0 the series is squashed into three commits and the register list is gone: the setup is now cs42l84_chip_init() in the driver and ring-sense detection is selected by cirrus,ring-sense-detect.

From the earlier reviews:

  • Chip-level writes in the driver, ring sense not keyed on the list: resolved in the code (sound/soc/codecs/cs42l84.c:1211-1263, the property read at :1351-1352), but see 1 for where the values come from.
  • Jack rows (headphones, headset with mic, button, after a deep sleep): not resolved. The PR body says this head has not run on the J604.
  • Nit "The sync wrote ...": the replay it was about is gone, and cs42l84.c:1497-1499 now says "The replay wrote the detect setup back". It is cs42l84_chip_init() (:1489) and the sync that write it; please fix the comment.
  1. The values have the wrong source. The PR body says "I compared its code in the M4 (T8132, 26B123) and M2 (T8112, 26B131) kernels: the register accesses and the constants are the same". Commit 276c593 says the same, and the code comments describe macOS's driver code rather than anything we observed: what it writes "after the device ID check" (cs42l84.c:1213-1216), what "macOS's handler" reads (:1018-1021), "macOS's detect setup" (:1186), "macOS writes TSRS_PLUG_INT_MASK = 0xfc" (:1364-1365). Values and behaviour read out of Apple's kernel binaries can't go into this tree or this PR, even with the registers renamed. The same applies to "same on every Mac with this codec" and the list of per-machine inputs macOS reads, which only the binaries show. Fix: take every value in cs42l84_chip_init() and in the cs42l84.h defines it uses (soft reset, SR_CFG_A/B/C, SR_TRIM, PAD_SLEW_CTL2, DET_CTL3, DET_INT_MASK1, DAC_CTL1_HP_OUT_INIT) from our own capture: an I2C trace of the codec probe under macOS on the J604 (the 0x1480/0x1484 latch finding was already a measurement), or the datasheet. Keep only what that capture shows. For "the same on every CS42L84 Mac", get a second capture from an M2 or M3 laptop; otherwise say the values are measured on the J604 only. Then rewrite the commit messages, the comments listed above and the PR body to cite the capture and drop the description of macOS's code and which kernels were compared. Commits 253e74c and 1126b15 and the DTS comment at t8132-j604.dts:634-637 also name the macOS device-tree property. Say what the hardware does instead (the J604 jack reports the plug on ring sense; tip sense re-asserts with nothing plugged in, measured at about 1000 interrupts/s).

  2. cs42l84.c:1353-1372, probe with ring-sense detection: (a) The threaded IRQ is live from :1311, and probe does not hold irq_lock. cs42l84_chip_init() writes DET_INT_MASK1 while the remote status latch is still set, and the latch is only read at :1358. In that window the line asserts, and the handler can run the ring branch (:1016-1048) against ring_state = 0 from kzalloc. With a plug in at boot it calls cs42l84_detect_hs(), which connects HSBIAS and starts the remote poll. cs42l84_setup_plug_detect() at :1361 then disconnects HSBIAS again, and :1372 records PLUG, so nothing redoes the detection. (b) Even without the race, a headset plugged in at boot is never detected. cs42l84_ring_detect_setup() stores ring_state = PLUG but never calls cs42l84_detect_hs(), so hs_type stays 0, set_jack() (:312) reports nothing, and the next ring interrupt sees no change. Resume handles this case (:1507-1515), probe doesn't. Fix: hold irq_lock from cs42l84_chip_init() through the mask setup in probe. After cs42l84_ring_detect_setup(), set tip_state and call cs42l84_detect_hs() when ring_state == CS42L84_PLUG, as resume does.

HW row: J604, this head on integration/aurora 5b596e6. Run headphones in/out, a headset with mic in/out (mic type reported), one remote button press, and a boot with the headset already plugged in (jack and mic reported). Then repeat the plug/unplug after an s2r deep sleep, with the cs42l84 IRQ delta over 10 s idle before and after the sleep (expect 0). Also needed: one M2 or M3 laptop without the property, which now gets the soft reset, the sample-rate block and the DAC_CTL1 output-stage writes too. On it, run headphone playback and a plug/unplug before and after the series. Both machines: 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

The tip-sense plug detection the driver uses does not fit every machine
with this codec. On the J604 (MacBook Pro 14-inch, M4) the jack reports
the plug on ring sense, and tip sense keeps re-asserting with nothing
plugged in, measured at about 1000 interrupts a second.

Add cirrus,ring-sense-detect to select ring-sense plug detection.
Without it, plug detection stays on tip sense as before.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
On the J604 (MacBook Pro 14-inch, M4) the headset jack reports the plug
on ring sense. With the tip-sense scheme this driver uses, tip sense
re-asserts about 1000 times a second with nothing plugged in, each
interrupt costing two I2C reads.

With cirrus,ring-sense-detect:

- write the detect block setup: TIP_SENSE_CTL2 mode only, bit 5 set in
  0x1471, 0x1478 = 0x8f and 0x1480 = 0x80. Apart from TIP_SENSE_CTL2
  these registers have no public description. The addresses and values
  come from an I2C trace of the codec probe under macOS on a J604 and
  are written in the order of that trace. What the single bits do is
  not known, and no other machine has been measured,
- mask tip sense (TSRS_PLUG_INT_MASK = 0xfc, as in the trace) and take
  plug and unplug from the ring sense state in TSRS_PLUG_STATUS,
- read REMOTE_BUTTON_STATUS1 (0x1484) once after the setup and on every
  codec interrupt. The 0x1480 write clears bits 5 and 6 there, and
  0x1484 then reads 0x60 once and 0 after that: two more sources are
  unmasked and their status is latched from power-up. Unread, it holds
  the interrupt line asserted. The polled button bits (0 and 1) are not
  affected.

The interrupt is requested before this point, so probe holds irq_lock
from the detect setup until the masks are written and the first ring
state is read. A plug that is in at boot raises no ring interrupt, so
probe runs the headset detection itself in that case, as resume does.

The resume after a deep sleep gets the same setup as probe: the detect
block before the cache is written back, the 0x1484 read after the sync,
the first ring state from TSRS_PLUG_STATUS, and tip sense masked.

Machines without the property get no new register writes and keep the
tip-sense scheme as before.

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

The J604's headset jack reports the plug on ring sense, and tip sense
keeps re-asserting with nothing plugged in (about 1000 interrupts a
second). Select ring-sense plug detection for its codec.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI IronsideXXVI changed the title ASoC: cs42l84: set the chip up as macOS does, ring-sense plug detection for the J604 ASoC: cs42l84: ring-sense plug detection for the J604 Nov 21, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks. Both blockers are addressed in d7271aeecb5.

1. Where the values come from. You're right, and I want to be plain about it: on the earlier heads I took the
register values and the order of the probe writes from reading Apple's kernel binaries, and I compared two of them
to claim the setup was the same on every machine. That should never have gone into this PR, and none of it is left.

What the series uses now comes only from an I2C trace I took on this J604: macOS booted under the hypervisor with the
I2C controller's MMIO window traced, codec at address 0x4b, nothing plugged into the jack. For the detect block the
trace shows, in this order:

W 0x1473 = 0xc0
R 0x1471 = 0xc0, W 0x1471 = 0xe0
W 0x1478 = 0x8f
R 0x1480 = 0xe0, W 0x1480 = 0x80
R 0x1484 = 0x60, then R 0x1484 = 0x00

and before them R 0x0418 = 0xff, W 0x0418 = 0xfc. The driver writes exactly those, only when
cirrus,ring-sense-detect is set. The three registers without a public description are written by address, with one
comment that says where the values were measured, that what the bits do is not known, and that no other machine has
been measured. cs42l84.h is back to the base.

I dropped the rest of the old chip setup: the 0x0203 write, the 0x31xx block, 0x3065, 0x0c01 and the DAC_CTL1
change. The trace does show those writes on the J604, but one trace from one machine can't tell me what they do or
whether they're right for an M2 or M3, and I have neither machine. So machines without the property now get no new
register writes at all, and the M2/M3 row should no longer be needed. If a second capture turns up they can come back
as their own patch.

Commit messages, code comments, the DTS comment and the PR body are rewritten to say what the hardware does and to
cite the trace. Nothing describes macOS's code or names its device-tree property any more.

The earlier heads are still in this PR's history. If you'd rather not have them attached to the tree at all, tell me
and I'll open a fresh PR from a clean branch and point this one at it.

2. Probe. Probe now takes irq_lock before the detect setup and holds it through the mask setup, so the handler
can't run against ring_state from kzalloc while the latch is still set. After cs42l84_ring_detect_setup() it sets
tip_state and calls cs42l84_detect_hs() when ring_state == CS42L84_PLUG, as resume does, so a headset that is
in at boot is detected.

Nit. The resume comment now names cs42l84_ring_detect_init() and the cache sync.

HW rows. Not run on this head yet. I'll post the J604 rows (codec IRQ delta over 10 s idle before and after a
deep sleep, headphones, headset with mic, button, boot with the headset in) before asking for another look.

@RyanTheTide
RyanTheTide merged commit fe5bd71 into aurora-silicon:integration/aurora Nov 21, 2026
2 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.

4 participants