[PATCH v7 0/2] ASoC: codecs: Add Nuvoton NAU83G60 audio codec driver
Neo Chang <[email protected]> Tue, 4 Aug 2026 11:29:49 +0800
| Newsgroups | org.alsa-project.alsa-devel,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-sound |
|---|---|
| Message-ID | <[email protected]> |
This patch series adds support for the Nuvoton NAU83G60 audio codec. The NAU83G60 is a stereo Class-D amplifier with an integrated DSP and I/V-sense capabilities. The driver supports I2C register access through regmap, DAPM widgets and routes, TDM interface configuration, and DSP firmware loading. The series is structured as follows: - Patch 1: Adds the YAML device tree bindings documentation. - Patch 2: Adds the ASoC codec driver implementation. Changes in v7: [dt-bindings] - No changes, added Krzysztof's Reviewed-by tag. [codec driver] - Fix potential DMA cache coherency issue in I2C transfers by separating TX and RX buffers. - Change tdm_tx_func_slot and tdm_rx_func_slot types to u32 to fix incompatible pointer type warnings. - Fix TDM channel enabling logic to check against slot IDs instead of function indices - Add bounds check for TDM slot indices in nau8360_validate_tdm_slots to prevent out-of-bounds shift operations. - Fix payload reading loop in nau8360_read_data_payload to break early when data consumption is complete, preventing protocol errors. - Add wait_for_completion during driver removal/suspend to synchronize async firmware loading and prevent use-after-free issues. - Refactor resume flow to properly handle regcache synchronization and PEQ memory enablement. - Move PEQ Memory Clear process to execute after DSP reset. Changes in v6: [dt-bindings] - Removed '|' from descriptions. - Add firmware-name in required. - Add "nuvoton,dsp-tx-slot-mapping" and "nuvoton,dsp-rx-slot-mapping" properties. [codec driver] - Fix Use-After-Free during device unbind by properly synchronizing asynchronous firmware loading. - Fallback to default firmware names if the "firmware-name" property is missing. - Parse "nuvoton,dsp-tx-slot-mapping" and "nuvoton,dsp-rx-slot-mapping" properties for static TDM routing. - Drop dynamic TDM slot mapping via ALSA kcontrols. - Replace cached tdm_chan_len with direct register reads via nau8360_get_tdm_chan_len(). Changes in v5: [dt-bindings] - Remove detailed datasheet information, keeping only the valid I2C address enum. - Simplify the `firmware-name` items definition by removing redundant minItems/maxItems and moving channel descriptions directly into individual item entries. [codec driver] - Add FW_LOADER dependency to prevent silent probe failure. - Fix uninitialized return variables and add error checks for underlying I2C reads. - Replace stack-allocated buffers in I2C transfers with heap-allocated memory. - Eliminate potential Use-After-Free by synchronizing firmware loading. - Protect PEQ memory control operations with mutex locks to ensure thread-safe register updates. - Resolve TDM slot configuration races using mutex protection. - Correct mathematically invalid TDM TX slot offsets during channel length changes. - Ensure TDM streams are explicitly disabled when slots or slot_width is zero. - Fix DSP protocol corruption due to missing locking in the DAPM clock event handler. - Use FIELD_PREP() in protocol packing functions to replace manual bit-shifting. - Replace deprecated of_property_count_strings() with device_property_read_string(). - Remove unnecessary CONFIG_ACPI ifdefs as struct acpi_device_id is universally available. - Refactor repetitive DAPM event handlers (adacl/adacr/dacl/dacr). - Simplify code flow by removing redundant gotos, variables, debug messages, and dev_get_platdata(). - Standardize driver style using switch-cases, positive logic checks, and reduced conditional nesting. Changes in v4: [dt-bindings] - Refine the firmware-name description to clarify the loading order (Left then Right) and the PBTL mode behavior. - Remove the "dsp bypass" option description. - Update the example node to follow devicetree coding styles. [codec driver] - Clean up unused DSP state flags (dsp_enable, dsp_created, dsp_fws_num). - Fixed the use of an uninitialized stack variable. - Fixed unhandled failures in nau8360_dsp_init() that caused duplicated DAPM widgets to leak. - Add mutex protection for PEQ memory and TDM slot caches. - Restored the missing hardware memory access bit during suspend/resume to prevent PEQ coefficients from being silently lost. - Handled regmap_read() failure in nau8360_vbat_level() to prevent the usage of uninitialized stack memory. - Removed improper dynamic creation of DAPM widgets and routes within ALSA kcontrol `put` handlers, using proper static instantiation instead. - Moved RX enable logic to startup() for consistent stream state. - Replaced synchronous request_firmware() with request_firmware_nowait() to prevent deadlocks and avoid blocking the kernel during firmware I/O. - Explicitly disable TDM RX/TX when slots or slot_width is zero. Changes in v2/v3: - v3: Resolved YAML build warnings, added Kconfig/Makefile entries, fixed stack buffer overflows in DSP parsing, and refactored TDM slot validation logic. - v2: Migrated software/runtime configurations from DT properties to ALSA kcontrols, refactored TDM routing, and improved firmware path handling. Neo Chang (2): ASoC: dt-bindings: nuvoton,nau8360: Add NAU83G60 ASoC: codecs: nau8360: Add support for NAU83G60 amplifier .../bindings/sound/nuvoton,nau8360.yaml | 83 + sound/soc/codecs/Kconfig | 11 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/nau8360-dsp.c | 667 +++++ sound/soc/codecs/nau8360-dsp.h | 122 + sound/soc/codecs/nau8360.c | 2273 +++++++++++++++++ sound/soc/codecs/nau8360.h | 916 +++++++ 7 files changed, 4074 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/nuvoton,nau8360.yaml create mode 100644 sound/soc/codecs/nau8360-dsp.c create mode 100644 sound/soc/codecs/nau8360-dsp.h create mode 100644 sound/soc/codecs/nau8360.c create mode 100644 sound/soc/codecs/nau8360.h -- 2.25.1