Skip to content

[26.04_linux-nvidia] N1x audio: MediaTek mt8901 SoundWire/ASoC/SOF stack - #566

Open
dcemin-nv wants to merge 33 commits into
NVIDIA:26.04_linux-nvidiafrom
dcemin-nv:n1x-audio-series-26.04
Open

[26.04_linux-nvidia] N1x audio: MediaTek mt8901 SoundWire/ASoC/SOF stack#566
dcemin-nv wants to merge 33 commits into
NVIDIA:26.04_linux-nvidiafrom
dcemin-nv:n1x-audio-series-26.04

Conversation

@dcemin-nv

@dcemin-nv dcemin-nv commented Sep 3, 2026

Copy link
Copy Markdown

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux-nvidia/+bug/2166301

MediaTek mt8901 audio stack for the N1x laptops, as shipping and validated in the N1x FastOS kernel: the MediaTek SoundWire manager, the ASoC AFE platform and machine drivers with SDCA support, the SOF/ADSP platform driver, the reliability and enumeration fixes, and the machine table entries for the six validated OEM topologies.

Series shape (reworked per review):

  • 33 commits, dependency ordered; review fixups are folded into the commits they repair with Co-developed-by attribution, and the intermediate power-vote change is folded into the system sleep PM ops commit.
  • All commit messages rewritten as kernel prose; no internal metadata, tracker references, or device identifiers remain; config commits use the NVIDIA: [Config] classification, with the options introduced disabled and enabled by the final commit after the complete stack.
  • Every commit passes scripts/checkpatch.pl --strict --git with zero errors. Remaining strict-mode output: six "does MAINTAINERS need updating?" warnings for new files (downstream tree, not applicable) and a handful of style checks in the imported MediaTek code (CamelCase identifiers, macro argument reuse); left untouched to keep the series byte identical with the board validated content.

Dependencies (patches intentionally NOT carried here):

Upstream status: the NVIDIA authored generic fixes from this program are going to the lists (sdw_utils fix prepared against broonie/for-next for the ASoC list; the related sbsa_gwdt fix for linux-watchdog); lore links will be added to the corresponding downstream commits/PRs once archived. The MediaTek base drivers are MediaTek IP; mainline submission is being coordinated with MediaTek and their postings will be linked when available.

Validation (this exact content, as an NV-Kernels build on an N1x board): full kernel deb boots with the board's own config; audio stack enumerates with the correct machine identity; acoustic loopback QA 4/4 PASS at 61 to 67 dB SNR; 3/3 mode verified deep S3 cycles; loopback passes after resume. The rework preserved the validated tree byte for byte (verified by diff), so the results carry over.

Please use a rebase merge, not a squash.

@dcemin-nv

Copy link
Copy Markdown
Author

@kbutala-nv @aritger review requested per the N1x patch integration call for action (Sudeep asked for Andy on anything touching shared subsystems). Bharat Dintakurti should review the SOF DSP power management patch on his return; carrying it here since he is out.

@nirmoy nirmoy added the help wanted Extra attention is needed label Sep 3, 2026
@nirmoy

nirmoy commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Boro watcher review skipped

The PR watcher skips automatic boro reviews for changes with more than 50 commits. This change currently has 58 commits.

To run the review anyway, ask BaseOS_Kernel_Bot in #baseos-kernel:

review https://github.com/NVIDIA/NV-Kernels/pull/566

Head: 1db476381097

This comment is maintained by BaseOS Reviewer. It is updated when the watcher sees a newer head.

@dcemin-nv
dcemin-nv force-pushed the n1x-audio-series-26.04 branch from da5327d to fd241ea Compare September 3, 2026 01:24
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

PR Validation Report

Patchscan ✅ No Missing Fixes

All cherry-picked commits checked — no missing upstream fixes found.

PR Lint ✅ All checks passed

Details
Checking 33 commits...

Cherry-pick digest:
┌──────────────┬──────────────────────────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐
│ Local        │ Referenced upstream / Patch subject                              │ Patch-ID   │ Subject │ SoB chain                 │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ f7517c286a39 │ [UBUNTU] [Config] enable the MT8901 audio stack                  │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 813ae2acf89b │ [SAUCE] soundwire: mediatek: mask bus-clash interrupts on a stor │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 5357d93847f5 │ [SAUCE] soundwire: mediatek: add 2x rt1320 + rt712 machine entry │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 36b32c132de7 │ [SAUCE] soundwire: mediatek: support suspend/resume              │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ cdf233203920 │ [SAUCE] asoc: mediatek: mt8901: support suspend/resume           │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 306887023638 │ [SAUCE] asoc: mediatek: mt8901: add error handling in card probe │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 3536c96fecad │ [SAUCE] asoc: mediatek: mt8901: put the jack stream on dl1       │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 649b694ca179 │ [SAUCE] soundwire: mediatek: restart every link at probe         │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7d567a4ae6c4 │ [SAUCE] asoc: sof: add mt8901 acpi adsp platform driver          │ N/A        │ N/A     │ zhang, bdintaku, dcemin   │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ b6b569271d61 │ [SAUCE] soundwire: mediatek: add cs42l43 + 4x cs35l56 machine en │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 2b5684899bf6 │ [SAUCE] soundwire: mediatek: restart the bus when nothing attach │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 8e6fbcdcde90 │ [SAUCE] soundwire: mediatek: add a diagnostic quarantine knob    │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ be75c81363a5 │ [SAUCE] soundwire: mediatek: add bus reset recovery              │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ cff1f333b187 │ [SAUCE] soundwire: mediatek: pace dev0 enumeration rounds        │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ac08f5093b39 │ [SAUCE] soundwire: mediatek: verify dev0 devid reads             │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 1d70a796411d │ [SAUCE] soundwire: mediatek: fix lost slave status interrupts    │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 66b225098879 │ [SAUCE] asoc: mediatek: mt8901: do not advertise s32_le          │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 7ae2e966d851 │ [SAUCE] soundwire: mediatek: add pin bias configuration          │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ afe9cf877dbb │ [SAUCE] soundwire: mediatek: add cs42l43 + 2x cs35l56 machine en │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ aa5ab4650b7f │ [SAUCE] soundwire: mediatek: add 2x rt1321 + rt713 machine entry │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 4ca80f932f3f │ [SAUCE] soundwire: mediatek: add 4x cs35l56 + cs42l43 machine en │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 9db011598cbb │ [SAUCE] soundwire: mediatek: add system sleep pm ops             │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 6e28a1413214 │ [SAUCE] asoc: mediatek: mt8901: add system sleep pm ops          │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ b2ba5ff13b90 │ [SAUCE] soundwire: mediatek: add mt8901 clock control support    │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 79b07f43ad4a │ [SAUCE] asoc: mediatek: mt8901: add clock control                │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ e0c3fcbf6bda │ [UBUNTU] [Config] annotation for CONFIG_SND_SOC_MTK_SDCA (disabl │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 61468ea57f47 │ [SAUCE] asoc: mediatek: add sdca support for mediatek chip       │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ eb9e3f88de20 │ [SAUCE] asoc: mediatek: mt8901: add legacy machine driver        │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 74003e8e5ef9 │ [UBUNTU] [Config] annotation for CONFIG_SND_SOC_MT8901 (disabled │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ a6706d9969f9 │ [SAUCE] asoc: mediatek: mt8901: add audio platform driver        │ N/A        │ N/A     │ hsieh, wu, dcemin         │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 717ca7e1ec65 │ [SAUCE] soundwire: mediatek: register machine platform device    │ N/A        │ N/A     │ wu, dcemin                │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 250c49798d6e │ [UBUNTU] [Config] annotation for CONFIG_SOUNDWIRE_MTK (disabled) │ N/A        │ N/A     │ dcemin                    │
├──────────────┼──────────────────────────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 3f69aea02311 │ [SAUCE] soundwire: mediatek: add mediatek soundwire manager      │ N/A        │ N/A     │ wu, dcemin                │
└──────────────┴──────────────────────────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘

Lint: all checks passed.

@jamieNguyenNVIDIA

jamieNguyenNVIDIA commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Please follow the conventions defined in the patch submission guide.

In particular:

  • All commits need sign-offs
  • All internal information (bug IDs, JIRAs, Change-ID, etc, "Found by CodeRabbit review on noble MR 69", etc.) should be stripped
  • Downstream commits need to be prefaced with "NVIDIA: SAUCE:". Also, what is the plan for upstreaming these?
  • Upstream commits (if there are any) need "backported from" or "cherry picked from" trailers
  • There are a couple instances of commit1-revert-commit2 -- this should be squashed to keep our history clean

@dcemin-nv
dcemin-nv force-pushed the n1x-audio-series-26.04 branch 3 times, most recently from a3166ae to 1db4763 Compare September 3, 2026 03:07
@dcemin-nv

Copy link
Copy Markdown
Author

Thanks for the review. Updated the series to follow the guide:

  1. Every commit now carries a Signed-off-by (submitter sign off added where the source tree lacked one).
  2. Internal metadata stripped (change IDs, internal bug and change numbers, internal tracker references).
  3. All commits are prefaced with NVIDIA: SAUCE: (the whole series is downstream, no upstream cherry picks, which also resolves the two "cannot resolve upstream SHA" lint errors: those were internal change references, now removed).
  4. The add plus revert pairs are squashed out; the series is now 58 commits with a clean history.

On the upstreaming plan: the MediaTek authored base drivers (SoundWire manager, ASoC AFE and machine drivers, SOF platform) are MediaTek IP and mainline submission is expected to come from MediaTek, with coordination in progress (their rt712 codec fix from this program is already accepted upstream). The NVIDIA authored generic pieces go to mainline from our side: the sdw_utils fix is being prepared for alsa-devel and the watchdog change for linux-watchdog (a related parameter rename from this program was already accepted in the watchdog maintainer tree). The mt8901 specific machine table entries and fixes follow the MediaTek base drivers whenever those land upstream.

@nirmoy

nirmoy commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

@dcemin-nv I created the Launchpad bug for this change:
https://bugs.launchpad.net/ubuntu/+source/linux-nvidia/+bug/2166301

Could you please add this link to the PR description?


CONFIG_MTK_SSPM_CI policy<{'arm64': 'y'}>
CONFIG_MTK_SSPM_CI note<'MediaTek SSPM control interface used by the Power Wrap SCMI device-control path.'>

@nirmoy nirmoy Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@dcemin-nv Please split it into separate patch as annotation changes are limitted to Canonical distro. ref: 09c0ae5

There are below headings in some commits:

[Description]
[Solution]
[Test]

Those looks odd for linux kernel commits and should be removed.
V2, v3 changelog seems unnecessary as this is the 1st time we are seeing the patch.

@jamieNguyenNVIDIA

Copy link
Copy Markdown
Collaborator

Thanks for the cleanup. I rechecked the new 58-commit series at 1db476381097. The remaining add/revert chain is gone and every commit now has a Signed-off-by line. Several commit-hygiene issues remain:

  • 9ffe74fa3162 changes 290 lines across the power-wrap API and sysfs/debug interface but has no explanatory commit message. It also reintroduces an internal Change-Id: trailer. Please write a durable rationale and split the sysfs/debug interface from the API where appropriate.
  • 9ffe74fa3162 is authored by Kaushal Butala and 7138887f8972 by Sanket Diwate, but each contains only David Cemin's sign-off. Please confirm and preserve the original authors' DCO/provenance chain.
  • The SoundWire PM history still records a known-wrong intermediate change: 20bb553acfd7 applies the incorrect master-wide power-vote assumption, then eb4400dd49e2 reverses it. Fold the correct behavior into 852107f97783. eb440... also has a stale Fixes: ffce0bf0d541 reference which does not exist in this history.
  • Internal/source-tree information remains despite the cleanup note: eight commits still mention Gerrit or MR !114, 9ffe74fa3162 contains a Change-Id:, and f0b809ca211a includes device serial PF68ES30. Seven commits also retain FastOS-specific test boilerplate. Please convert source-review history into durable rationale and remove private identifiers.
  • Four config commits use the double prefix NVIDIA: SAUCE: UBUNTU:. Please use the project-standard classification for these commits rather than stacking both prefixes.
  • The upstreaming plan described on PR [26.04_linux-nvidia-bos] N1x audio: MediaTek mt8901 SoundWire/ASoC/SOF stack #567 is useful, but planned submissions are not traceable public provenance. Please get the applicable patches posted upstream first so the downstream commits can carry (backported from <lore link>) trailers. For the MediaTek-owned base drivers, please coordinate with MediaTek and link their postings once available; for the NVIDIA-owned generic fixes, please post them to the appropriate lists before carrying them downstream.
  • The intermediate history is not self-contained/buildable:
    • 2cf468ff9c4f and 2cedb2ad034b consume the power-wrap API before it is introduced by 9ffe74fa3162.
    • 6da1e1973ed4 includes the already-removed pwrap_public.h.
    • 0f3fe6c2ecbb enables the SOF driver before 6fb247a3c9e0 repairs its include/Kconfig/PM integration.
  • 306bb67708ee claims to enable "audio and ADSP" but does not touch CONFIG_SND_SOC_SOF_MT8901. Retitle/reorder it and place final enablement after the complete stack.
  • 17e0fb9b3e24 is patch-identical to b94410ff5376 in PR [26.04_linux-nvidia] pinctrl: mediatek: MT8901 ACPI wake-event EINT support and bus-hold bias #564. Drop it from one PR and express the dependency explicitly.
  • Please fold review/fixup commits into the commits they repair, particularly b8c8d79eee52 and 0171ed973db9, which are explicitly omnibus "review fixups." There are numerous other fix-on-introduction chains throughout the series that should be cleaned up before merge.
  • Several commits combine unrelated or mechanical work:
    • a444cca5a88b combines SSPM transport, power-wrap core, and sysfs/debug code.
    • 2cedb2ad034b mixes a feature with seven 100%-rename file moves.
    • 9ffe74fa3162 mixes the power-wrap API with a new sysfs/debug interface.
    • 0171ed973db9 contains unrelated build/include and runtime-PM fixes.
  • Twenty-one messages still use imported [Description]/[Solution]/[Test] templates, and 31 subjects exceed 75 characters after adding the prefix. Please rewrite these as normal kernel commit messages.
  • Please run scripts/checkpatch.pl --strict --git <commit> against every commit after rebuilding the series, and address or explain each remaining warning. A final-tree check does not catch commit-local metadata and formatting problems.
  • Minor, but helpful for reviewers: please update the stale PR description. It still says 64 commits, claims “the first 9” are prerequisites, and says two add/revert pairs remain; none of those accurately describes the current series.

Please rebuild this as a clean, dependency-ordered series whose individual commits are reviewable and buildable, update the PR description, and rerun validation.

Add the MediaTek mt8901 SoundWire manager driver. The manager wraps a
Cadence SoundWire master IP behind MediaTek link and interconnect glue:
ACPI probe and link enumeration, PDI allocation against the fixed AFE
interconnect grid, interrupt handling, and stream/port configuration
for the SoundWire codecs on the platform.

Folded review fixes from the bring-up: compare device 0 status against
the SLAVESTAT field encoding rather than the raw register value, track
the previous PDI across port contiguity checks, reset the group sync
state on every hw_params instead of leaking it across streams, and
return the correct error code when a core register map fails.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
@dcemin-nv
dcemin-nv force-pushed the n1x-audio-series-26.04 branch from 1db4763 to 307c81b Compare September 4, 2026 01:12
@nirmoy

nirmoy commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

BaseOS Kernel Review

Note

🔄 Review in progress

Boro is reviewing this pull request. Results will appear here when ready.

🔍 Review artifacts

  • 🟡 Boro review: in progress
Review metadata
  • Reviewed head: f7517c286a39
  • Overall status: in progress

This comment is maintained by BaseOS Reviewer and updated when the GitHub watcher publishes a newer review.

@dcemin-nv

Copy link
Copy Markdown
Author

Thanks for the thorough review; the series is rebuilt accordingly and force pushed (now 33 commits). Point by point:

  1. power_wrap and BusKeeper prerequisites: dropped from this series entirely. The power_wrap driver, client API (the 290 line commit) and its feature patches go through their own submission by their authors, which also resolves the authorship/DCO concern for the Kaushal and Sanket commits and the Change-Id/rationale issues there. BusKeeper is in PR [26.04_linux-nvidia] pinctrl: mediatek: MT8901 ACPI wake-event EINT support and bus-hold bias #564 (dropped the duplicate here). The commits that consume those APIs carry explicit dependency notes; this PR does not build standalone until the dependencies land.
  2. Power vote intermediate: folded. The master-wide vote change and its correction are squashed into the system sleep PM ops commit, which now introduces the per-link vote behavior directly with the rationale in the message.
  3. Review fixups and fix-on-introduction chains: folded into the commits they repair with Co-developed-by attribution (manager, AFE platform, machine driver, clock control, PM ops, suspend/resume, bus reset recovery). The suspend/resume omnibus fixup was split by subsystem into its two parents.
  4. Internal information: all Gerrit/MR references, Change-Id trailers, the device serial, internal template blocks and internal codenames are gone; messages are rewritten as kernel prose. The Change-Ids in the previous push turned out to be added at commit time by a local Gerrit hook, now bypassed.
  5. Config commits: reclassified as NVIDIA: [Config], options introduced disabled, single final enablement commit at the end covering the complete stack (retitled to what it actually enables).
  6. Ordering/buildability: SOF config now follows the SOF driver (whose integration repair is folded into it, includes corrected at introduction); annotations changes ride with their config commits; subjects are all within 75 characters.
  7. checkpatch --strict --git on every commit: zero errors across all 33. Remaining strict output is six "does MAINTAINERS need updating?" warnings for new files (downstream tree) and style checks in the imported MediaTek code (CamelCase, macro argument reuse), left as is to keep the series byte identical with the board validated content; happy to address those as follow ups if you prefer.
  8. Upstream first: the NVIDIA authored generic fixes are being posted (sdw_utils against broonie/for-next, sbsa_gwdt to linux-watchdog); I will add the lore links here once archived. Mainline submission of the MediaTek base drivers is being coordinated with MediaTek and their postings will be linked when available.
  9. PR description rewritten to match the current series.

The rework preserved the validated tree byte for byte (verified by diff against the board tested series), so the Yukon validation results carry over unchanged.

dcemin-nv and others added 12 commits September 3, 2026 19:02
Add the config annotation for the new MediaTek SoundWire manager.
The option is introduced disabled; enablement follows at the end of
the series once the complete audio stack is in place.

Signed-off-by: David Cemin <dcemin@nvidia.com>
ALSA needs a machine driver to bind the platform DAIs and the
SoundWire codecs into a sound card. Register a machine platform device
from the SoundWire manager, carrying the codec topology discovered
during enumeration, so a matching machine driver can complete the card
registration.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Add the mt8901 AFE platform driver: memory interfaces, the AFE
interconnect, DAI definitions and the platform component used by the
machine driver.

Folded review fixes from the bring-up: request the AFE interrupt only
after the regmap is set up so the handler cannot run against an
uninitialized map, and limit VUL_CM2 to the 16 channels that are
physically wired.

Signed-off-by: mtk34643 <weiyi.hsieh@mediatek.com>
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Add the config annotation for the mt8901 ASoC platform driver.
The option is introduced disabled; enablement follows at the end of
the series.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Add the mt8901 machine driver for SoundWire audio devices: Kconfig
and Makefile entries plus the machine driver implementation that binds
the AFE platform DAIs to the enumerated SoundWire codec endpoints.

Folded review fix: size the codec_conf array by the number of codec
endpoints rather than the number of devices; a device contributing
several endpoints previously overran the array.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Codec integration requires SDCA support on the SoundWire manager
side. Introduce the SND_SOC_MTK_SDCA configuration and the glue that
enables SDCA class devices behind the MediaTek manager.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Add the config annotation for the MediaTek SDCA support option,
introduced disabled; enablement follows at the end of the series.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Add the mt8901 audio clock control: the AFE clock tree (muxes,
gates, APLL tuner and engen control) and the SSPM-managed functional
clock requests issued through the power-wrap client API. Select
SOUNDWIRE_MTK_MT8901_CLK from the machine configuration so the clock
integration is always active with the machine driver.

Folded review fix: roll back a partially applied idle clock parent
switch instead of leaving the mux chain in a mixed state when one step
fails.

Depends on the MediaTek power_wrap driver providing
mtk_send_power_control_req() (submitted separately).

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Integrate clock management into the mt8901 SoundWire manager: bring
the functional clock tree up during link initialization and release it
symmetrically on teardown, using the shared mt8901 AFE clock helpers.

Folded review fixes: release the link top clock when link init fails
partway, and keep the register clock bookkeeping accurate in the probe
unwind path so a failed probe does not leave gates held.

Depends on the MediaTek power_wrap driver (submitted separately).

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Add system sleep suspend/resume callbacks to the mt8901 ASoC
platform driver so the audio block releases its clock and MTCMOS power
requests across suspend and the platform can reach its deepest sleep
state. The SSPM firmware reference counts power domain requests, so
per-module requests are intentionally symmetric with the other
operating system supported on this platform.

Folded review fix: unwind partial state when one of the system sleep
steps fails, instead of resuming into a half-suspended configuration.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Add system sleep suspend/resume callbacks to the mt8901 SoundWire
manager, releasing clocks and the power domain on suspend and
reacquiring them on resume so the platform can reach its deepest sleep
state.

The power domain votes are taken and released per link: each link that
was active before suspend restores its own vote on resume. A
master-wide vote is not sufficient because links power on independently
and a single vote either leaks references or releases a domain that
another link still needs.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
…entry

The machine table only described one Realtek layout (RT1320 x2 on link0
plus RT712 on link1), so on boards with the dual-link Cirrus topology no
machine matches and no sound card is created. Add that layout: four
CS35L56 amps on link0 (unique IDs 0x30-0x33, aggregated into one speaker
group) and a CS42L43 jack codec on link1 (unique ID 0x30), with the
endpoint shapes used by the upstream AMD and Intel entries for the same
codec combination.

_ADR values taken from the platform firmware ACPI dump. The
speaker-position-to-unique-ID mapping is assumed in ID order and will be
confirmed on hardware. The cs42l43 endpoint list carries only the jack
and mic endpoints; the sidecar speaker endpoint is omitted since these
boards use separate SoundWire amps.

Signed-off-by: David Cemin <dcemin@nvidia.com>
dcemin-nv and others added 20 commits September 3, 2026 19:02
Boards with this Realtek layout enumerate 2x RT1321 (unique IDs 0x30/
0x31) on link0 and an RT713 on link1. The existing Realtek entry matches
the E4032-A00 reference parts (RT1320 at unique IDs 0x30/0x32, RT712),
so these boards enumerated but never registered a card. Add the
combination with the _ADR values from the platform firmware. RT1321 and
RT713 are already handled by the rt1320-sdw and rt712-sdca codec drivers
and are present in the sdw_utils codec_info_list.

RT713 needs its own endpoint list {0, 1} (jack DAI 0, DMIC DAI 1 per the
sdw_utils codec info for part 0x713); reusing the RT712 endpoints {0, 2}
fails because the RT712 DMIC sits at index 2 behind the amp DAI. The
name prefixes follow the driver family so existing control names are
unchanged.

Signed-off-by: David Cemin <dcemin@nvidia.com>
…entry

This Cirrus variant puts all three codecs on link1 with link0 unused: a
CS42L43 jack codec at unique ID 0x30 plus two aggregated CS35L56 amps at
unique IDs 0x30/0x31 (_ADR values from the platform firmware dump;
peripherals of different part numbers may share unique IDs on one link).
Distinct from both the dual-link Cirrus arrangement (four amps on link0)
and the Realtek layouts. The cs42l43 entry uses the same speakerless
endpoint list as the dual-link Cirrus entry, and the amps take group
positions 0/1 of the existing aggregated group.

Signed-off-by: David Cemin <dcemin@nvidia.com>
The SoundWire pads need bus-keeper bias configuration; without it
codec enumeration fails unless the pads are configured by hand.
Program the pin bias from ACPI resources during link initialization.

Depends on the MediaTek pinctrl bus-keeper support (submitted
separately).

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
The AFE data path is 24-bit internally. S16 and S24 (24 valid bits in a
32-bit container) play clean on hardware, but true 32-bit memif mode
produces heavily distorted output regardless of the HD mode and align
settings (board verified: S16 clean, S24 clean, S32 badly distorted on
the same route). The reference driver for this silicon only uses the
16 and 24-bit memif modes.

This matters for the default desktop experience: with S32 advertised,
PipeWire negotiates it by preference and out-of-the-box playback is
audibly degraded. Dropping it makes PipeWire pick S24, full quality,
with no userspace format pinning needed.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Two defects combined to permanently lose peripheral attach transitions
after initial enumeration:

1) The interrupt handler scheduled the slave status work before masking
   the slave interrupt. The work re-enables that interrupt when it
   completes, so a work that ran to completion on another CPU before the
   handler's mask landed left the slave interrupt masked forever; every
   subsequent attach or detach transition on the link was invisible to
   the manager. Dense links (five peripherals) lose this race reliably
   during the enumeration interrupt storm. Mask first, then schedule.

2) A peripheral that soft-resets after enumeration (the cs42l43 jack
   codec does this during driver probe) drops to Dev0 and takes tens of
   ms to re-sync before it can ACK a device number write. The status
   work polls Dev0 in a tight loop bounded by SDW_MAX_DEVICES
   iterations, which completes well inside that window: the device
   number writes are ignored (-61) and the attach is dropped. Convert
   the work to a delayed work that re-schedules itself (20 ms period,
   bounded at 25 attempts) while Dev0 remains attached.

Observed on a five-peripheral single-link topology where the cs42l43
probe reset consistently left the codec UNATTACHED and the card at
-EPROBE_DEFER. The reference stack never exercises either path because
it does not reset codecs after enumeration.

Signed-off-by: David Cemin <dcemin@nvidia.com>
A peripheral still re-synchronizing at Dev0 (or several colliding
there) ACKs DevId reads while returning corrupted bytes. The bus core
trusts a single read, so a corrupted ID registers a phantom peripheral
that consumes a device number while the real device stays orphaned;
observed on a five-peripheral link as dozens of phantom entries with
bit-mixed IDs (part 0x0043 from a 0x4243 device, class 0 from class 1
peripherals) and the jack codec enumerated under a mangled identity
its driver never matches.

Run the Dev0 DevId read as two complete sequential 0x50..0x55 passes
and report the command ignored on mismatch so the core retries the
attach later, once the peripheral answers stably. The passes must be
complete and in-order: peripherals track the sequential DevId read to
commit arbitration, so per-byte repeat reads leave them uncommitted
and they then ignore the device number write.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Two peripherals answering a Dev0 DevId read while one of them is still
regaining frame sync produce deterministic wire-mixed responses (the
misaligned straggler corrupts the synced responder's bits the same way
every round), so read-and-verify cannot filter them and the bus core
enumerates phantom identities. The status work currently burns all its
enumeration rounds within ~50 ms, entirely inside the straggler's
re-sync window.

Sleep 30 ms between rounds while Dev0 reports attached so a straggler
reaches frame sync before the next DevId read, at which point both
peripherals arbitrate correctly and enumerate under their real
identities.

Signed-off-by: David Cemin <dcemin@nvidia.com>
The command reset issued once during hw_init is the only path that
brings every peripheral to Dev0 simultaneously for a clean group
enumeration; a link that fails enumeration (peripherals stuck
contending at Dev0, or carrying stale state from a previous OS run
across a warm reboot) currently has no way back to that state and
stays wedged until the next cold boot.

Re-issue the command reset when the Dev0 re-poll gives up, bounded at
three attempts per episode, and re-kick the status work after a settle
delay. Also expose the reset manually via debugfs
(echo <link> > mtk-sdw/bus_reset) for testing, and reject Dev0 DevId
reads that return all-zeros or all-ones (bus-keeper-held lines read
back stably but nothing real is driving).

Signed-off-by: David Cemin <dcemin@nvidia.com>
An electrically faulty peripheral that asserts Alert permanently drags
the bus core into an endless alert-read retry storm (every interrupt
register read fails parity) and the traffic from the misbehaving
responder disturbs enumeration of the healthy peripherals sharing the
link. Add quarantine_uid: report the matching 0x3556 peripheral as
plainly attached so its alerts are never serviced, allowing the rest of
the link to enumerate and be validated. Diagnostic aid for a bad unit,
default off.

Signed-off-by: David Cemin <dcemin@nvidia.com>
…ches

A re-initialized master (module reload, and eventually resume) comes up
in normal operation mode while the peripherals still hold their device
numbers from the previous enumeration. They raise no new attach
transition, so the interrupt-driven status machinery (including the bus
reset recovery) is never armed and the link sits dead with zero attach
events. The reference stack never hits this because it runs its restart
choreography (ResetAndReInitMaster) unconditionally on every re-init.

Detect the state instead of restarting unconditionally: schedule a
one-shot check per link at probe; if peripherals are declared for the
link but every one is still UNATTACHED 2 s after init, run the restart
choreography with the same interrupt quiesce/re-arm bracket as the
debugfs knob (SOFT_RST clears the slave interrupt masks; without the
re-arm the post-restart attach transitions never interrupt and
enumeration stalls after Dev0). The restart drops the peripherals to
Dev0 and re-enumerates them through the normal interrupt path. The 2 s
delay is far past the normal attach window (tens of ms out of POST,
where the check sees attached slaves and does nothing) but inside the
5 s the codec drivers wait for re-attach at probe, so the codecs
recover without a rebind.

Board-proven on the Lenovo Yoga 9 83N7 (S/N the affected unit, five peripherals
on link1): a plain module remove/reload of the audio stack, previously
the zero-attach dead-link signature, now recovers fully automatically:
restart at +2 s, all five peripherals re-enumerate, amp DSP firmware
reloads, the card re-registers with no manual step, and acoustic
loopback passes identically to cold boot.

Signed-off-by: David Cemin <dcemin@nvidia.com>
…entry

This Cirrus variant puts all five codecs on link1 with link0 unused: a
CS42L43 jack codec at unique ID 0x30 plus four aggregated CS35L56 amps
at unique IDs 0x30/0x31/0x34/0x35 (_ADR values from the platform
firmware dump; peripherals of different part numbers may share unique
IDs on one link). Distinct from the dual-link Cirrus arrangement (four
amps on link0) and from the two-amp single-link entry, of which it is a
superset: the entry is placed ahead of the two-amp one because matching
is first-fit and tolerates extra enumerated peripherals, so the two-amp
entry would otherwise match a four-amp board and register a card with
only half the speakers. The cs42l43 entry uses the same speakerless
endpoint list as the other Cirrus entries, and the amps take group
positions 0-3 of the existing aggregated group.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Add the SOF platform driver for the mt8901 audio DSP: ACPI probe,
DSP power management through the power-wrap client interface, and the
SOF plumbing needed to manage the ADSP power state from Linux.

Folded the initial integration repair: correct the Kconfig
dependencies, the Makefile include path and the power-wrap header use
so the driver builds and manages the DSP power state as intended.

Depends on the MediaTek power_wrap driver (submitted separately).

Signed-off-by: Greta Zhang <greta.zhang@mediatek.com>
Co-developed-by: Bharat Dintakurti <bdintakurti@nvidia.com>
Signed-off-by: Bharat Dintakurti <bdintakurti@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
POST leaves the peripherals enumerated and the bus running, and until
now Linux adopted that state. Adopting preserves whatever internal
state the peripherals hold, which has been observed in the field to
include defective persistent state that register-level
reconfiguration cannot clear: the codec sits on an always-on rail
(+1.8VSUS) that never drops while the battery is connected, so such
state survives reboots indefinitely. On an ASUS ProArt P14 unit that
had never run Windows, the internal microphone path was broken this
way for weeks; one bus restart cleared it permanently
and both microphones and speakers validated acoustically immediately
after.

The reference Windows stack never hits this class of problem because
it runs its restart choreography (ResetAndReInitMaster)
unconditionally on every init. Do the same: run the bus restart in
link init, after the hardware init and before interrupts are enabled,
so the slave interrupt masks that SOFT_RST clears are armed after the
restart and the fresh attach transitions are processed normally. The
post-init attach check remains as a backstop. A restart_on_probe
module parameter (default on) allows reverting to the old adopt
behavior from the kernel command line.

Boot-time cost is one restart dwell (about 30 ms) per link.

Signed-off-by: David Cemin <dcemin@nvidia.com>
The AFE playback interconnect is fixed in hardware: PDI2/PDI3/PDI4 are
only reachable from the speaker memifs (DL0/DL_24CH) and PDI5/PDI6
only from the headphone memif (DL1), and data port DP<n> is hard-wired
to PDI<n>. The machine driver hands out SoundWire cpu-DAI pins to
endpoint groups in plain endpoint order, which works on two-link
boards (the firmware allocates link1's DPs from DP5, so the jack group
lands on DP5 by accident of ordering) but breaks on single-link boards
such as the ASUS ProArt P14 and Lenovo Yoga 9 (CS42L43 plus CS35L56
amps, everything on link1, DPs allocated from DP2): the jack group got
DP2, which DL1 cannot reach, so opening the jack PCM (hw:,1) failed
with -EINVAL (no backend DAIs for DL1_FE). Worse, PipeWire drops an
entire UCM verb when any of its PCMs fails to open, so this removed
every audio device on those boards.

Read the firmware DP allocation (acpi-scd-dp-allocation, same property
the SoundWire controller parses; the machine device is a child of the
controller) and reserve the DP5 pin for the jack playback stream;
everything else allocates sequentially around it. On two-link boards
this computes the same assignment as before (jack pin 5 - 5 = 0). On
single-link boards the jack moves to DP5/PDI5 while the amps keep the
sequential pins they had before (DP3/DP4 on the P14, where the amp
backend is wired through the O152/O153 interconnect); DP2 is left
unused. If the property is absent the legacy sequential behaviour is
kept.

The jack reservation burns the sequential slot the jack would have
taken, but only while the sequence has not yet stepped over the jack
pin: if a non-jack stream already skipped it, burning again would
leave a pin gap and could push later streams past the firmware DP
window (review finding on the first revision).

Board-proven on the ASUS ProArt P14: full four-path matrix (speakers,
jack, DMIC capture, headset mic) passes with the UCM profile unchanged
for the non-jack paths.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Handle failures during card probe: unwind the partially registered
card and return the error instead of continuing with an inconsistent
component state.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Restore the AFE hardware state on resume: reprogram the memory
interfaces, interconnect routing and interrupt state so streams can
restart after system suspend without reloading the driver.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Complete the SoundWire manager resume path: reinitialize the links,
restore the Cadence configuration, re-enumerate the bus and restore the
data port setup so peripherals reattach and audio continues to work
after system suspend.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Co-developed-by: David Cemin <dcemin@nvidia.com>
Signed-off-by: David Cemin <dcemin@nvidia.com>
Boards with this Realtek layout enumerate two RT1320 amps on link0 at
unique IDs 0x30 and 0x31 plus an RT712 jack codec on link1. The existing
reference entry expects the second amp at unique ID 0x32, so these
boards enumerated but never matched a machine and no card was created.
Add the variant with the second amp at 0x31, reusing the existing RT712
endpoint list and the rt1320-1/rt1320-2/rt712 name prefixes so existing
mixer recipes and profiles apply unchanged.

_ADR values from the platform firmware ACPI dump. The firmware also
declares PinFunction pad entries (same 0x90/0xF0 policy as other
production boards) and full SDCA functions on the RT712.

Signed-off-by: David Cemin <dcemin@nvidia.com>
The clash interrupts are enabled unconditionally and the handler only
logs and clears them. Isolated clashes at bus power transitions are
harmless (1-2 per suspend/resume cycle in the reference board soak data), but a
persistent clash condition refires the interrupt as fast as it is
cleared: on an HP OmniBook (all peripherals on link1) an idle link0
storms continuously, pinning CPU0 with softirqs and flooding the log
(reported on production units). Detect a storm (32 clash
interrupts inside a 100 ms window) and mask the clash interrupts on
that link; ratelimit the per-event log lines.

All MCP_INTMASK updates are read-modify-write from the ISR, the status
work, and the attach-check work with no shared guard, so the new
ISR-side masking write is funneled, together with the existing enable
helpers, through one spinlock-serialized updater.

Audio is unaffected before and after masking: the storming link carries
no devices and stream traffic on the other link is serviced normally.

Signed-off-by: David Cemin <dcemin@nvidia.com>
Enable the complete MT8901 audio stack now that every component is
in place: the SoundWire manager, the ASoC platform and machine drivers
with SDCA support, and the SOF ADSP platform driver.

Signed-off-by: David Cemin <dcemin@nvidia.com>
@dcemin-nv
dcemin-nv force-pushed the n1x-audio-series-26.04 branch from 307c81b to f7517c2 Compare September 4, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed pending_review_comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants