ASoC: cdns: Add Cadence I2S-SC and I2S-MC controller support
Subsystems (3)
v3 cover ASoC: cdns: Add Cadence I2S-SC and I2S-MC controller support
From: Joakim Zhang <[email protected]>
This series adds support for the Cadence I2S-SC and I2S-MC controllers integrated in the CIX SKY1 audio subsystem, together with their DT bindings.
I2S-SC provides full-duplex stereo playback and capture in standard I2S, left/right-justified and DSP modes, along with TDM operation supporting up to 16 slots. I2S-MC provides multi-channel playback and capture through a configurable set of its 8 data pins, described by cix,pin-out-num, cix,pin-rx-mask and cix,pin-tx-mask, and exposes a transmit DAI and a receive DAI.
Both drivers register the dmaengine PCM helper, select the audio reference clock parent for the 8 kHz or 11.025 kHz sample rate family and keep the minimum functional-clock to bit-clock ratio required for safe clock domain crossing.
Changes in v3:
- Add the explicit <linux/bitfield.h> include, which a W=1 build of the FIELD_PREP() sites needs (both drivers).
- Fix the probe error paths: disable the manually enabled clocks and drop the runtime PM usage count on every failure path, unwinding through a single goto label (both drivers).
- Return dev_err_probe() directly instead of logging with it and then returning the error separately (both drivers).
Changes in v2:
- Move the IRQ request after the clocks are enabled and the reset is released, so the handler never runs against unclocked hardware.
- Disable the IRQ before switching the regcache to cache-only mode on suspend, and re-enable it only after the cache is synced on resume; check the status read in the ISR (both drivers).
- Replace the manual runtime PM bookkeeping with devm_pm_runtime_enable() and drop the remove() callbacks (both drivers).
- Switch to RUNTIME_PM_OPS()/SYSTEM_SLEEP_PM_OPS() wrapped in pm_ptr() and drop the __maybe_unused annotations (both drivers).
- Serialize the shared transceiver clock state in prepare() against the trigger() state machine with the existing spinlock (I2S-SC).
- Disable clocks in the reverse order of enablement (both drivers).
- Sort the cdns/ entry into the vendor list in sound/soc/Makefile and switch sound/soc/cdns/Makefile to the '-y' object syntax.
- Clean up the includes and initializer style (both drivers).
- Add a NULL check for the match data in probe (both drivers).
- Factor the MC transmitter and receiver configuration into a shared helper.
- Drop the compatible string from the DMAC stub node in the binding examples.
Joakim Zhang (4):
ASoC: dt-bindings: Add Cadence I2S-SC controller
ASoC: cdns: Add Cadence I2S-SC controller driver
ASoC: dt-bindings: Add Cadence I2S-MC controller
ASoC: cdns: Add Cadence I2S-MC controller driver
.../bindings/sound/cix,sky1-i2s-mc.yaml | 123 ++ .../bindings/sound/cix,sky1-i2s-sc.yaml | 93 ++ sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/cdns/Kconfig | 21 + sound/soc/cdns/Makefile | 7 + sound/soc/cdns/cdns-i2s-mc.c | 1127 ++++++++++++++++ sound/soc/cdns/cdns-i2s-sc.c | 1166 +++++++++++++++++ 8 files changed, 2539 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-mc.yaml create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml create mode 100644 sound/soc/cdns/Kconfig create mode 100644 sound/soc/cdns/Makefile create mode 100644 sound/soc/cdns/cdns-i2s-mc.c create mode 100644 sound/soc/cdns/cdns-i2s-sc.c
Signature · 1 line
2.50.1
PATCH v3 1/4 ASoC: dt-bindings: Add Cadence I2S-SC controller
From: Joakim Zhang <[email protected]>
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
--- .../bindings/sound/cix,sky1-i2s-sc.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cix,sky1-i2s-sc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence I2S-SC controller + +maintainers: + - Joakim Zhang <[email protected]> + +description: | + The Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. + It supports full-duplex stereo playback and capture in standard I2S, + left/right-justified and DSP modes, as well as TDM operation with up to + 16 slots. The transmitter and receiver are started and stopped together + by the controller. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + const: cix,sky1-i2s-sc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: hst + - const: i2s + - const: audio-clk0 + - const: audio-clk2 + + resets: + maxItems: 1 + + dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ] + + "#sound-dai-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - dmas + - dma-names + - "#sound-dai-cells" + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + audss_dmac: dma-controller { + #dma-cells = <1>; + }; + + i2s@7020000 { + compatible = "cix,sky1-i2s-sc"; + reg = <0x7020000 0x10000>; + interrupts = <GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&audss_cru 16>, <&audss_cru 26>, + <&scmi_clk 100>, <&scmi_clk 101>; + clock-names = "hst", "i2s", "audio-clk0", "audio-clk2"; + resets = <&audss_cru 0>; + dmas = <&audss_dmac 0>, <&audss_dmac 1>; + dma-names = "tx", "rx"; + #sound-dai-cells = <0>; + };
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: loose schema constraint on dma-names allows invalid configurations --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: loose schema constraint on dma-names allows invalid configurations --
commit 41d6caf5f15433436b2c0289025efcf429404414
Author: Joakim Zhang <[email protected]>
ASoC: dt-bindings: Add Cadence I2S-SC controller
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
Quoted 5 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml line 56
Quoted 12 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +12
-0+ dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ]
[Severity: Low]
Does this schema definition permit invalid DMA combinations?
Because items is set to just an enum, this allows combinations like ["tx", "tx"], ["rx", "rx"], or out-of-order configurations like ["rx", "tx"] to silently pass validation.
Is there a specific ordering and uniqueness constraint expected here when providing two channels?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Rob Herring
maintainerRe: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller
Quoted 35 lines · On Fri, Oct 09, 2026 at 09:32:13AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: loose schema constraint on dma-names allows invalid configurations --commit
41d6caf5f15433436b2c0289025efcf429404414
Author: Joakim Zhang <[email protected]>ASoC: dt-bindings: Add Cadence I2S-SC controller
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
Quoted 5 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +0
-0[ ... ]
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml line 56
Quoted 12 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +12
-0+ dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ]
Quoted 6 lines
[Severity: Low]
Does this schema definition permit invalid DMA combinations?Because items is set to just an enum, this allows combinations like ["tx", "tx"], ["rx", "rx"], or out-of-order configurations like ["rx", "tx"] to silently pass validation.
Yes, normally that is prevented, but IIRC there's a binding that needed something like this.
minItems: 1
uniqueItems: true
items:
- enum: [ tx, rx ]
- const: tx
Then when both are there the order is enforced.
Rob
Rob Herring
maintainerRe: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller
In reply to [email protected]Quoted 65 lines · On Fri, Oct 09, 2026 at 05:25:49PM +0800, [email protected] wrote:
From: Joakim Zhang <[email protected]>
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
Signed-off-by Joakim Zhang <[email protected]>--- .../bindings/sound/cix,sky1-i2s-sc.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamlDocumentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +46
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cix,sky1-i2s-sc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence I2S-SC controller + +maintainers: + - Joakim Zhang <[email protected]> + +description: | + The Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. + It supports full-duplex stereo playback and capture in standard I2S, + left/right-justified and DSP modes, as well as TDM operation with up to + 16 slots. The transmitter and receiver are started and stopped together + by the controller. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + const: cix,sky1-i2s-sc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: hst + - const: i2s + - const: audio-clk0 + - const: audio-clk2 + + resets: + maxItems: 1 + + dmas: + minItems: 1
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +10
-0+ maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ]
Address the sashiko comment.
Rob
RE: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller
Quoted 90 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, October 9, 2026 10:16 PM
To: Joakim Zhang (张强庆) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; cix-kernel-upstream <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controllerEXTERNAL EMAIL
Quoted 74 lines · On Fri, Oct 09, 2026 at 05:25:49PM +0800, [email protected] wrote:
From: Joakim Zhang <[email protected]>
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
Signed-off-by Joakim Zhang <[email protected]>--- .../bindings/sound/cix,sky1-i2s-sc.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamldiff --git
a/Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamlb/Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamlnew file mode 100644
index 000000000000..3fdf2334c492Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +52
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cix,sky1-i2s-sc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence I2S-SC controller + +maintainers: + - Joakim Zhang <[email protected]> + +description: | + The Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. + It supports full-duplex stereo playback and capture in standard +I2S, + left/right-justified and DSP modes, as well as TDM operation with +up to + 16 slots. The transmitter and receiver are started and stopped +together + by the controller. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + const: cix,sky1-i2s-sc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: hst + - const: i2s + - const: audio-clk0 + - const: audio-clk2 + + resets: + maxItems: 1 + + dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive.
Quoted 8 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml line 56
Quoted 6 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +6
-0+ + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ]Address the sashiko comment.
Bob, thanks.
Joakim
Rob Herring
maintainerRe: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller
In reply to [email protected]Quoted 89 lines · On Fri, Oct 09, 2026 at 05:25:49PM +0800, [email protected] wrote:
From: Joakim Zhang <[email protected]>
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
Signed-off-by Joakim Zhang <[email protected]>--- .../bindings/sound/cix,sky1-i2s-sc.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamlDocumentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +70
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cix,sky1-i2s-sc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence I2S-SC controller + +maintainers: + - Joakim Zhang <[email protected]> + +description: | + The Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. + It supports full-duplex stereo playback and capture in standard I2S, + left/right-justified and DSP modes, as well as TDM operation with up to + 16 slots. The transmitter and receiver are started and stopped together + by the controller. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + const: cix,sky1-i2s-sc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: hst + - const: i2s + - const: audio-clk0 + - const: audio-clk2 + + resets: + maxItems: 1 + + dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ] + + "#sound-dai-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - dmas + - dma-names + - "#sound-dai-cells"
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml line 80
Quoted 10 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +10
-0+ +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + audss_dmac: dma-controller { + #dma-cells = <1>; + };
Drop. We don't put providers in examples. What example made you think you needed it? And if you do, why not the clock, reset, and interrupt providers?
Rob
RE: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller
Quoted 115 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, October 9, 2026 10:19 PM
To: Joakim Zhang (张强庆) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; cix-kernel-upstream <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v3 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controllerEXTERNAL EMAIL
Quoted 99 lines · On Fri, Oct 09, 2026 at 05:25:49PM +0800, [email protected] wrote:
From: Joakim Zhang <[email protected]>
Add the DT binding for the Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. I2S-SC is a full-duplex stereo controller supporting standard I2S, left/right-justified and DSP formats, plus TDM operation with up to 16 slots.
Signed-off-by Joakim Zhang <[email protected]>--- .../bindings/sound/cix,sky1-i2s-sc.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamldiff --git
a/Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamlb/Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yamlnew file mode 100644
index 000000000000..3fdf2334c492Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +77
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cix,sky1-i2s-sc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence I2S-SC controller + +maintainers: + - Joakim Zhang <[email protected]> + +description: | + The Cadence I2S-SC controller integrated in the CIX SKY1 audio subsystem. + It supports full-duplex stereo playback and capture in standard +I2S, + left/right-justified and DSP modes, as well as TDM operation with +up to + 16 slots. The transmitter and receiver are started and stopped +together + by the controller. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + const: cix,sky1-i2s-sc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: hst + - const: i2s + - const: audio-clk0 + - const: audio-clk2 + + resets: + maxItems: 1 + + dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ] + + "#sound-dai-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - dmas + - dma-names + - "#sound-dai-cells" + +unevaluatedProperties: false + +examples: + - |
Quoted 8 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml line 80
Quoted 5 lines
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +5
-0+ #include <dt-bindings/interrupt-controller/arm-gic.h> + + audss_dmac: dma-controller { + #dma-cells = <1>; + };Drop. We don't put providers in examples. What example made you think you needed it? And if you do, why not the clock, reset, and interrupt providers?
Yes, will drop, thanks.
Joakim
PATCH v3 2/4 ASoC: cdns: Add Cadence I2S-SC controller driver
In reply to [email protected]From: Joakim Zhang <[email protected]>
Add support for the Cadence I2S-SC controller found in the CIX SKY1 audio subsystem.
The controller provides full-duplex stereo playback and capture in standard I2S, left/right-justified and DSP modes, with mono operation mapped onto the left audio channel. It also supports TDM operation with up to 16 slots per frame, where the PCM channels map onto the active slots of the stream direction while the bit clock covers the whole frame.
The transmitter and receiver share the transceiver enable sequence, so the start/stop state machine is serialized with a spinlock against independently triggered playback and capture PCMs. The driver registers the dmaengine PCM helper, selects the audio reference clock parent for the 8 kHz or 11.025 kHz sample rate family and keeps the minimum functional-clock to bit-clock ratio required for safe clock domain crossing. Runtime and system suspend/resume restore the registers through the regcache.
--- sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/cdns/Kconfig | 11 + sound/soc/cdns/Makefile | 4 + sound/soc/cdns/cdns-i2s-sc.c | 1166 ++++++++++++++++++++++++++++++++++ 5 files changed, 1183 insertions(+) create mode 100644 sound/soc/cdns/Kconfig create mode 100644 sound/soc/cdns/Makefile create mode 100644 sound/soc/cdns/cdns-i2s-sc.c
sound/soc/Kconfig +1 -0
@@ -108,6 +108,7 @@ source "sound/soc/apple/Kconfig" source "sound/soc/atmel/Kconfig" source "sound/soc/au1x/Kconfig" source "sound/soc/bcm/Kconfig" +source "sound/soc/cdns/Kconfig" source "sound/soc/cirrus/Kconfig" source "sound/soc/dwc/Kconfig" source "sound/soc/fsl/Kconfig"
sound/soc/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_SND_SOC) += amd/ obj-$(CONFIG_SND_SOC) += atmel/ obj-$(CONFIG_SND_SOC) += au1x/ obj-$(CONFIG_SND_SOC) += bcm/ +obj-$(CONFIG_SND_SOC) += cdns/ obj-$(CONFIG_SND_SOC) += cirrus/ obj-$(CONFIG_SND_SOC) += dwc/ obj-$(CONFIG_SND_SOC) += fsl/
sound/soc/cdns/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +config SND_SOC_CDNS_I2S_SC + tristate "Cadence I2S-SC controller support" + depends on ARCH_CIX || COMPILE_TEST + select SND_SOC_GENERIC_DMAENGINE_PCM + help + Say Y or M if you want to add support for the Cadence I2S-SC + controller found in the CIX SKY1 audio subsystem. It provides + full-duplex stereo playback and capture in standard I2S and + TDM modes with up to 16 slots.
sound/soc/cdns/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +snd-soc-cdns-i2s-sc-y := cdns-i2s-sc.o +obj-$(CONFIG_SND_SOC_CDNS_I2S_SC) += snd-soc-cdns-i2s-sc.o
sound/soc/cdns/cdns-i2s-sc.c new file +1166 -0
1,166 lines not on this page · raw message
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v3 2/4] ASoC: cdns: Add Cadence I2S-SC controller driver
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] asoc: inverted master/slave clock provider configuration in set_fmt - [High] regmap: racy…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] asoc: inverted master/slave clock provider configuration in set_fmt
- [High] regmap: racy read-modify-write on volatile interrupt status register I2S_STAT
- [Medium] pm: missing devm action or .remove callback leaves clocks permanently enabled
- [Low] kconfig: missing select REGMAP_MMIO causes build failure
--
commit c5bda621f50576e786b53bd1505239571117bd15
Author: Joakim Zhang <[email protected]>
Subject: ASoC: cdns: Add Cadence I2S-SC controller driver
Add support for the Cadence I2S-SC controller found in the CIX SKY1 audio subsystem.
sound/soc/cdns/Kconfig line 6
Quoted 12 lines
sound/soc/cdns/Kconfig new file +6
-0@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +config SND_SOC_CDNS_I2S_SC + tristate "Cadence I2S-SC controller support" + depends on ARCH_CIX || COMPILE_TEST + select SND_SOC_GENERIC_DMAENGINE_PCM
[Severity: Low]
Since this driver unconditionally calls devm_regmap_init_mmio() to manage its registers, should this also select REGMAP_MMIO?
If it is built (e.g., via COMPILE_TEST) without another driver selecting it, it could cause an undefined reference to __devm_regmap_init_mmio_clk during the link stage.
Quoted 5 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0
-0
[ ... ]
Quoted 5 lines
sound/soc/cdns/cdns-i2s-sc.c new file +5
-0+static irqreturn_t cdns_i2s_sc_isr (int irq,void *devid) +{ +struct cdns_i2s_sc_priv *i2s_sc_priv = (struct cdns_i2s_sc_priv *)devid; +struct device *dev = i2s_sc_priv->dev; +u32 stat;
sound/soc/cdns/cdns-i2s-sc.c line 401
Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +10
-0+ +if (regmap_read (i2s_sc_priv->regmap,I2S_STAT , &stat)) +return IRQ_NONE ; + + stat &=I2S_STAT_TDATA_UNDERR |I2S_STAT_RDATA_OVERR ; +if (!stat) +return IRQ_NONE ; + +/* Clear the status */ +regmap_update_bits (i2s_sc_priv->regmap,I2S_STAT , stat,0 );
[Severity: High]
Is it safe to use regmap_update_bits() here to clear the interrupt status?
I2S_STAT is correctly marked as a volatile register in the regmap configuration, but regmap_update_bits() performs a non-atomic physical read-modify-write cycle.
If the hardware uses Write-1-to-Clear (W1C) or Write-0-to-Clear (W0C) semantics, this read-modify-write might accidentally clear unhandled events or permanently drop new interrupts asserted between the read and write.
Could we use a direct regmap_write() here instead?
[ ... ]
Quoted 2 lines
sound/soc/cdns/cdns-i2s-sc.c new file +2
-0+static int cdns_i2s_sc_set_fmt (struct snd_soc_dai *cpu_dai,unsigned int fmt) +{
[ ... ]
sound/soc/cdns/cdns-i2s-sc.c line 523
Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +10
-0+/* DAI hardware clock masters */ +switch (fmt &SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK ) { +case SND_SOC_DAIFMT_CBC_CFC : + ctrl &= ~I2S_CTRL_MS_CFG ; + i2s_sc_priv->is_master_mode = false; +break ; +case SND_SOC_DAIFMT_CBP_CFP : + ctrl |=I2S_CTRL_MS_CFG ; + i2s_sc_priv->is_master_mode = true; +break ;
[Severity: High]
Are these clock provider configurations inverted?
In the ASoC framework, SND_SOC_DAIFMT_CBC_CFC means the Codec is the Bitclock/Frame Consumer, which makes the CPU DAI (this controller) the Provider (Master).
SND_SOC_DAIFMT_CBP_CFP means the Codec is the Provider, so the CPU DAI must be the Consumer (Slave).
The driver logic seems to do the exact opposite. Will this cause bus contention by actively driving clocks when the codec is already doing so?
[ ... ]
Quoted 2 lines
sound/soc/cdns/cdns-i2s-sc.c new file +2
-0+static int cdns_i2s_sc_probe (struct platform_device *pdev) +{
[ ... ]
sound/soc/cdns/cdns-i2s-sc.c line 1054
Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +10
-0+/* +* Let pm_runtime_put_sync() disable the clocks, and take regcache effect. +* If CONFIG_PM is not enabled, the clock will stay powered. +*/ +pm_runtime_put_sync (&pdev->dev); + + ret =devm_snd_soc_register_component (&pdev->dev, &cdns_i2s_sc_component, + &cdns_i2s_sc_dai,1 ); +if (ret) +return dev_err_probe (&pdev->dev, ret,"Failed to register soc component\n" );
[Severity: Medium]
If devm_snd_soc_register_component() fails here, the probe function returns directly, bypassing the err_disable_clks label.
Does this leak the clocks if CONFIG_PM is disabled (since pm_runtime_put_sync() would be a no-op)?
[ ... ]
sound/soc/cdns/cdns-i2s-sc.c line 1161
Quoted 8 lines
sound/soc/cdns/cdns-i2s-sc.c new file +8
-0+static struct platform_driver cdns_i2s_sc_driver = { + .probe = cdns_i2s_sc_probe, + .driver = { + .name =DRV_NAME , + .pm =pm_ptr (&cdns_i2s_sc_pm_ops), + .of_match_table = cdns_i2s_sc_of_match, + }, +};
[Severity: Medium]
I noticed there is no .remove callback or devm_add_action_or_reset() cleanup for the hardware clocks enabled during probe.
During driver unbind, the driver core calls pm_runtime_get_sync() (waking the device and enabling clocks if they were suspended) followed by pm_runtime_disable().
Without a .remove callback to force suspend or manually disable them, does this leave the clocks permanently enabled?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v3 3/4 ASoC: dt-bindings: Add Cadence I2S-MC controller
In reply to [email protected]From: Joakim Zhang <[email protected]>
Add the DT binding for the Cadence I2S-MC multi-channel controller integrated in the CIX SKY1 audio subsystem. The controller exposes a transmit DAI and a receive DAI and moves audio through a configurable set of its 8 data pins. Which pins are wired out and in which direction is fixed by the board design and described by the cix,pin-out-num, cix,pin-rx-mask and cix,pin-tx-mask properties.
--- .../bindings/sound/cix,sky1-i2s-mc.yaml | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-mc.yaml
Documentation/devicetree/bindings/sound/cix,sky1-i2s-mc.yaml new file +123 -0
@@ -0,0 +1,123 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cix,sky1-i2s-mc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence I2S-MC controller + +maintainers: + - Joakim Zhang <[email protected]> + +description: | + The Cadence I2S-MC multi-channel controller integrated in the CIX SKY1 + audio subsystem. It provides up to 8-channel playback and capture through + a configurable number of I2S data pins, and exposes two DAIs: a transmit + DAI and a receive DAI. + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + const: cix,sky1-i2s-mc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 4 + + clock-names: + items: + - const: hst + - const: i2s + - const: audio-clk0 + - const: audio-clk2 + + resets: + maxItems: 1 + + dmas: + minItems: 1 + maxItems: 2 + description: + One DMA channel for instances wired for a single direction, either + "tx" or "rx", or two channels for both transmit and receive. + + dma-names: + minItems: 1 + maxItems: 2 + items: + enum: [ tx, rx ] + + "#sound-dai-cells": + const: 1 + description: + Cell selects the DAI, 0 for the transmit DAI (i2s-mc-aif1) and + 1 for the receive DAI (i2s-mc-aif2). + + cix,pin-out-num: + $ref: /schemas/types.yaml#/definitions/uint8 + minimum: 1 + maximum: 8 + description: + Number of I2S data output pins wired on this instance. Which of + the 8 controller data pins are wired out is fixed by the board + design and can be any subset. + + cix,pin-rx-mask: + $ref: /schemas/types.yaml#/definitions/uint8 + description: + Bit mask of I2S data pins used for capture, bit N selects data + pin N. + + cix,pin-tx-mask: + $ref: /schemas/types.yaml#/definitions/uint8 + description: + Bit mask of I2S data pins used for playback, bit N selects data + pin N. The rx and tx masks must not overlap, and the number of + set bits must not exceed cix,pin-out-num. + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - resets + - dmas + - dma-names + - "#sound-dai-cells" + - cix,pin-out-num + - cix,pin-rx-mask + - cix,pin-tx-mask + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + audss_dmac: dma-controller { + #dma-cells = <1>; + }; + + i2s@7050000 { + compatible = "cix,sky1-i2s-mc"; + reg = <0x7050000 0x10000>; + interrupts = <GIC_SPI 222 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&audss_cru 17>, <&audss_cru 27>, + <&scmi_clk 100>, <&scmi_clk 101>; + clock-names = "hst", "i2s", "audio-clk0", "audio-clk2"; + resets = <&audss_cru 1>; + dmas = <&audss_dmac 2>, <&audss_dmac 3>; + dma-names = "tx", "rx"; + #sound-dai-cells = <1>; + cix,pin-out-num = /bits/ 8 <2>; + cix,pin-rx-mask = /bits/ 8 <0x1>; + cix,pin-tx-mask = /bits/ 8 <0x2>; + };
Signature · 1 line
2.50.1
PATCH v3 4/4 ASoC: cdns: Add Cadence I2S-MC controller driver
In reply to [email protected]From: Joakim Zhang <[email protected]>
Add support for the Cadence I2S-MC multi-channel controller found in the CIX SKY1 audio subsystem.
The controller moves up to 16 channels through a configurable set of its 8 data pins, each pin carrying two slots. Wired-out pins may sit at any pin index and are described by cix,pin-out-num, cix,pin-rx-mask and cix,pin-tx-mask. The driver exposes a transmit DAI and a receive DAI which can act as clock provider or consumer independently, and streams with fewer channels than the wired pins narrow the enabled pin mask at runtime.
The driver registers the dmaengine PCM helper, selects the audio reference clock parent for the 8 kHz or 11.025 kHz sample rate family and keeps the minimum functional-clock to bit-clock ratio required for safe clock domain crossing, with an extra margin cycle when the bit clock is sourced externally. Runtime and system suspend/resume restore the registers through the regcache.
--- sound/soc/cdns/Kconfig | 10 + sound/soc/cdns/Makefile | 3 + sound/soc/cdns/cdns-i2s-mc.c | 1127 ++++++++++++++++++++++++++++++++++ 3 files changed, 1140 insertions(+) create mode 100644 sound/soc/cdns/cdns-i2s-mc.c
sound/soc/cdns/Kconfig +10 -0
@@ -9,3 +9,13 @@ config SND_SOC_CDNS_I2S_SC controller found in the CIX SKY1 audio subsystem. It provides full-duplex stereo playback and capture in standard I2S and TDM modes with up to 16 slots. + +config SND_SOC_CDNS_I2S_MC + tristate "Cadence I2S-MC controller support" + depends on ARCH_CIX || COMPILE_TEST + select SND_SOC_GENERIC_DMAENGINE_PCM + help + Say Y or M if you want to add support for the Cadence I2S-MC + multi-channel controller found in the CIX SKY1 audio subsystem. + It provides multi-channel playback and capture through a + configurable number of I2S data pins.
sound/soc/cdns/Makefile +3 -0
@@ -2,3 +2,6 @@ snd-soc-cdns-i2s-sc-y := cdns-i2s-sc.o obj-$(CONFIG_SND_SOC_CDNS_I2S_SC) += snd-soc-cdns-i2s-sc.o + +snd-soc-cdns-i2s-mc-y := cdns-i2s-mc.o +obj-$(CONFIG_SND_SOC_CDNS_I2S_MC) += snd-soc-cdns-i2s-mc.o
sound/soc/cdns/cdns-i2s-mc.c new file +1127 -0
1,127 lines not on this page · raw message
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v3 4/4] ASoC: cdns: Add Cadence I2S-MC controller driver
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [High] sound: cdns: clock refcount leak on late probe error and driver unbind - [High] sound: cdns…
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] sound: cdns: clock refcount leak on late probe error and driver unbind
- [High] sound: cdns: inverted clock master/slave mode evaluation in hw_params
- [High] sound: cdns: inverted BCLK data delay for I2S and Left-Justified formats
- [High] sound: cdns: read-modify-write race on volatile interrupt status register
- [Medium] sound: cdns: synchronizing unit resets dropped due to incomplete regmap mask
- [Medium] sound: cdns: unprotected shared clock parent modification across DAIs
- [Medium] cdns: premature FIFO reset deassertion over APB bus
--
commit ba70a70c0f6376ecabc6aa01d7c62b130cb6e3a9
Author: Joakim Zhang <[email protected]>
ASoC: cdns: Add Cadence I2S-MC controller driver
Add support for the Cadence I2S-MC multi-channel controller found in the CIX SKY1 audio subsystem.
Quoted 5 lines
sound/soc/cdns/cdns-i2s-mc.c new file +0
-0
[ ... ]
Quoted 5 lines
sound/soc/cdns/cdns-i2s-mc.c new file +5
-0+static irqreturn_t cdns_i2s_mc_isr (int irq,void *devid) +{ +struct cdns_i2s_mc_priv *i2s_mc_priv = (struct cdns_i2s_mc_priv *)devid; +struct device *dev = i2s_mc_priv->dev; +u32 stat;
sound/soc/cdns/cdns-i2s-mc.c line 279
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+ +if (regmap_read (i2s_mc_priv->regmap,I2S_INTR_STAT , &stat)) +return IRQ_NONE ; + + stat &=I2S_INTR_STAT_TDATA_UNDERR |I2S_INTR_STAT_RDATA_OVERR ; +if (!stat) +return IRQ_NONE ; + +/* Clear the status */ +regmap_update_bits (i2s_mc_priv->regmap,I2S_INTR_STAT , stat,0 );
[Severity: High]
Does this read-modify-write cycle introduce a hardware race condition on the volatile interrupt status register?
The I2S_INTR_STAT register is asynchronously updated by the hardware to flag events. When regmap_update_bits() performs its read-modify-write cycle, any new hardware interrupts that assert between the read and the write could be inadvertently cleared without being handled (if W1C) or overwritten with 0 and lost (if W0C or R/W).
Would it be safer to use a direct regmap_write() here?
[ ... ]
Quoted 5 lines
sound/soc/cdns/cdns-i2s-mc.c new file +5
-0+static int cdns_i2s_mc_set_fmt (struct snd_soc_dai *cpu_dai,unsigned int fmt) +{ +struct cdns_i2s_mc_priv *i2s_mc_priv =snd_soc_dai_get_drvdata (cpu_dai); +struct device *dev = i2s_mc_priv->dev; +u32 ctrl =0 , dev_conf =0 ;
[ ... ]
Quoted 9 lines
sound/soc/cdns/cdns-i2s-mc.c new file +9
-0+/* DAI hardware audio formats */ +switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) { +case SND_SOC_DAIFMT_I2S : + dev_conf |=I2S_DEV_CONF_TRAN_I2S_ALIGN_LR ; + dev_conf &= ~(I2S_DEV_CONF_TRAN_APB_ALIGN_LR | +I2S_DEV_CONF_TRAN_DATA_WS_DEL | +I2S_DEV_CONF_TRAN_WS_DSP_MODE ); +break ; +case SND_SOC_DAIFMT_RIGHT_J :
sound/soc/cdns/cdns-i2s-mc.c line 355
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+ dev_conf |=I2S_DEV_CONF_TRAN_DATA_WS_DEL ; + dev_conf &= ~(I2S_DEV_CONF_TRAN_I2S_ALIGN_LR | +I2S_DEV_CONF_TRAN_APB_ALIGN_LR | +I2S_DEV_CONF_TRAN_WS_DSP_MODE ); +break ; +case SND_SOC_DAIFMT_LEFT_J : + dev_conf |=I2S_DEV_CONF_TRAN_I2S_ALIGN_LR |I2S_DEV_CONF_TRAN_DATA_WS_DEL ; + dev_conf &= ~(I2S_DEV_CONF_TRAN_APB_ALIGN_LR | +I2S_DEV_CONF_TRAN_WS_DSP_MODE ); +break ;
[Severity: High]
Are the BCLK data delays inverted for I2S and Left-Justified formats?
Standard I2S requires a 1 BCLK delay for the data relative to the WS signal, while Left-Justified requires a 0 BCLK delay.
The I2S_DEV_CONF_TRAN_DATA_WS_DEL bit seems to configure this 1 BCLK delay (as it is explicitly set for DSP_A and cleared for DSP_B).
However, this code clears this bit for SND_SOC_DAIFMT_I2S (removing the required delay) and sets it for SND_SOC_DAIFMT_LEFT_J (adding an incorrect delay), which might cause 1-bit audio misalignment.
[ ... ]
Quoted 5 lines
sound/soc/cdns/cdns-i2s-mc.c new file +5
-0+static int cdns_i2s_mc_prepare (struct snd_pcm_substream *substream, +struct snd_soc_dai *cpu_dai) +{ +struct cdns_i2s_mc_priv *i2s_mc_priv =snd_soc_dai_get_drvdata (cpu_dai); +u32 ctrl =0 , fifo =0 ;
[ ... ]
Quoted 20 lines
sound/soc/cdns/cdns-i2s-mc.c new file +20
-0+if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +/* Transmitter clock enable */ +regmap_update_bits (i2s_mc_priv->regmap,I2S_CID_CTRL , +I2S_CID_CTRL_STROBE_TS ,0 ); + +/* +* Transmitter FIFO reset +* When '0', transmit FIFO pointers are reset to zero. Threshold level for +* this FIFO is unchanged. This bit is automatically set to '1' after one +* clock cycle if TX FIFO reset has been acknowledged. +* Deassert then assert this bit here, since I2S_CTRL register is not +* volatile, would not read from hardware any longer. If not, it would +* clear tx fifo every time when write this register. +*/ + ctrl &= ~I2S_CTRL_TFIFO_RST ; +regmap_update_bits (i2s_mc_priv->regmap,I2S_CTRL , +I2S_CTRL_TFIFO_RST , ctrl); + ctrl |=I2S_CTRL_TFIFO_RST ; +regmap_update_bits (i2s_mc_priv->regmap,I2S_CTRL , +I2S_CTRL_TFIFO_RST , ctrl);
[ ... ]
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+ }else { +/* Receiver clock enable */ +regmap_update_bits (i2s_mc_priv->regmap,I2S_CID_CTRL , +I2S_CID_CTRL_STROBE_RS ,0 ); + +/* +* Receiver FIFO reset +* When '0', receive FIFO pointers are reset to zero. Threshold level for +* this FIFO is unchanged. This bit is automatically set to '1' after one +* clock cycle if RX FIFO reset has been acknowledged.
sound/soc/cdns/cdns-i2s-mc.c line 532
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+* Deassert then assert this bit here, since I2S_CTRL register is not +* volatile, would not read from hardware any longer. If not, it would +* clear rx fifo every time when write this register. +*/ + ctrl &= ~I2S_CTRL_RFIFO_RST ; +regmap_update_bits (i2s_mc_priv->regmap,I2S_CTRL , +I2S_CTRL_RFIFO_RST , ctrl); + ctrl |=I2S_CTRL_RFIFO_RST ; +regmap_update_bits (i2s_mc_priv->regmap,I2S_CTRL , +I2S_CTRL_RFIFO_RST , ctrl);
[Severity: Medium]
Will these back-to-back writes deassert the FIFO resets too quickly?
The hardware requires the reset bit to be held for at least 1 I2S functional clock cycle before it auto-acknowledges and sets it to 1. Since these writes go over the fast APB bus, they might deassert the reset in tens of nanoseconds, and the slower clock domain crossing synchronizer could miss this pulse, aborting the reset.
Should there be a delay here, or could the cache be manipulated exclusively using regcache_cache_only() instead?
[ ... ]
Quoted 19 lines
sound/soc/cdns/cdns-i2s-mc.c new file +19
-0+static int cdns_i2s_mc_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params, +struct snd_soc_dai *cpu_dai) +{ +struct cdns_i2s_mc_priv *i2s_mc_priv =snd_soc_dai_get_drvdata (cpu_dai); +struct device *dev = i2s_mc_priv->dev; +u32 rate, sample_rate =0 ; +u32 slots, slot_width, resolution, ctrl; +unsigned long i2s_clk_rate; +u8 pin_tx_num, pin_rx_num; +struct clk *clk_parent; +bool is_master_mode; +int ret; + + rate =params_rate (params); + slot_width = i2s_mc_priv->devtype_data->data_width; +dev_dbg (dev,"rate = %d, slot_width = %d\n" , rate, slot_width); + +/* switch clk mux to select the appropriate clk parent */
sound/soc/cdns/cdns-i2s-mc.c line 582
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+if (rate %8000 ==0 ) { +/* Sampling rate is a multiple of 8KHz, select "audio-clk0" */ + clk_parent = i2s_mc_priv->clks[AUDIO_CLK0 ]; + + ret =clk_set_parent (i2s_mc_priv->clk_i2s, clk_parent); + }else if (rate %11025 ==0 ) { +/* Sampling rate is a multiple of 11.025KHz, select "audio-clk2" */ + clk_parent = i2s_mc_priv->clks[AUDIO_CLK2 ]; + + ret =clk_set_parent (i2s_mc_priv->clk_i2s, clk_parent);
[Severity: Medium]
Does this unconditionally change the shared clock parent without protecting against active streams on the other DAI?
Since there are two independent DAIs (I2S_MC_AIF1 and I2S_MC_AIF2), starting a new stream on one DAI with a different sample rate will silently change the parent of the shared clk_i2s clock.
Could this break the clock rate and corrupt the audio of a concurrently running stream on the other DAI?
Quoted 9 lines
sound/soc/cdns/cdns-i2s-mc.c new file +9
-0+ }else { +dev_err (i2s_mc_priv->dev,"Invalid sample rate\n" ); +return -EINVAL ; + } +if (ret) { +dev_err (i2s_mc_priv->dev,"Failed to set i2s clock parent\n" ); +return ret; + } +
sound/soc/cdns/cdns-i2s-mc.c line 601
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+ i2s_clk_rate =clk_get_rate (i2s_mc_priv->clk_i2s); +dev_dbg (dev,"i2s clk rate = %lu\n" , i2s_clk_rate); + +regmap_read (i2s_mc_priv->regmap,I2S_CTRL , &ctrl); +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + is_master_mode = ctrl &I2S_CTRL_T_MS ; +else + is_master_mode = ctrl &I2S_CTRL_R_MS ; + +if (is_master_mode) {
[Severity: High]
Is the clock master/slave mode evaluation inverted here?
In cdns_i2s_mc_set_fmt(), I2S_CTRL_T_MS is cleared when the CPU is master (SND_SOC_DAIFMT_CBC_CFC) and set when the CPU is slave (SND_SOC_DAIFMT_CBP_CFP).
However, the logic here evaluates is_master_mode as true when the CPU is a slave, and false when the CPU is a master.
This causes the driver to incorrectly calculate and program the clock divider when acting as a slave, and skip computing the divider entirely when acting as a master.
[ ... ]
Quoted 8 lines
sound/soc/cdns/cdns-i2s-mc.c new file +8
-0+static int cdns_i2s_mc_dai_probe (struct snd_soc_dai *cpu_dai) +{ +struct cdns_i2s_mc_priv *i2s_mc_priv =snd_soc_dai_get_drvdata (cpu_dai); +u32 ctrl =0 , cid_ctrl =0 ; + +/* +* Transceiver disable +* Transceiver clock disable
sound/soc/cdns/cdns-i2s-mc.c line 714
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+* All interrupts masked +* Reset for transmitter synchronizing unit +* Reset for receiver synchronizing unit +*/ + ctrl |=FIELD_PREP (I2S_CTRL_I2S_EN ,0 ); + ctrl &= ~(I2S_CTRL_TSYNC_RST |I2S_CTRL_RSYNC_RST ); + cid_ctrl |=I2S_CID_CTRL_STROBE_TS |I2S_CID_CTRL_STROBE_RS ; + cid_ctrl &= ~I2S_CID_CTRL_INTREQ_MASK ; + +regmap_update_bits (i2s_mc_priv->regmap,I2S_CTRL ,I2S_CTRL_I2S_EN , ctrl);
[Severity: Medium]
Will this restrictive mask prevent the synchronizing unit resets from reaching the hardware?
The driver clears I2S_CTRL_TSYNC_RST and I2S_CTRL_RSYNC_RST (bits 25 and 26) in the ctrl variable, but issues the write using only I2S_CTRL_I2S_EN (bits 0-7) as the mask. The intended hardware modifications to bits 25 and 26 will be silently masked out.
[ ... ]
Quoted 3 lines
sound/soc/cdns/cdns-i2s-mc.c new file +3
-0+static int cdns_i2s_mc_probe (struct platform_device *pdev) +{ +struct cdns_i2s_mc_priv *i2s_mc_priv;
[ ... ]
sound/soc/cdns/cdns-i2s-mc.c line 1014
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+/* +* Let pm_runtime_put_sync() disable the clocks, and take regcache effect. +* If CONFIG_PM is not enabled, the clock will stay powered. +*/ +pm_runtime_put_sync (&pdev->dev); + + ret =devm_snd_soc_register_component (&pdev->dev, &cdns_i2s_mc_component, + cdns_i2s_mc_dai,ARRAY_SIZE (cdns_i2s_mc_dai)); +if (ret) +return dev_err_probe (&pdev->dev, ret,"Failed to register soc component\n" );
[Severity: High]
Does returning directly here bypass the err_disable_clks cleanup path?
The clocks clk_hst and clk_i2s are manually enabled earlier in this function via cdns_i2s_mc_clks_enable(). Returning directly on failure will leak the clock prepare/enable reference counts.
Should this jump to err_disable_clks instead?
[ ... ]
Quoted 4 lines
sound/soc/cdns/cdns-i2s-mc.c new file +4
-0+static const struct of_device_id cdns_i2s_mc_of_match[] = { + { .compatible ="cix,sky1-i2s-mc" , .data = &sky1_devtype_data }, + {/* sentinel */ } +};
sound/soc/cdns/cdns-i2s-mc.c line 1122
Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10
-0+MODULE_DEVICE_TABLE (of, cdns_i2s_mc_of_match); + +static struct platform_driver cdns_i2s_mc_driver = { + .probe = cdns_i2s_mc_probe, + .driver = { + .name =DRV_NAME , + .pm =pm_ptr (&cdns_i2s_mc_pm_ops), + .of_match_table = cdns_i2s_mc_of_match, + }, +};
[Severity: High]
Does this driver lack a .remove callback to clean up the clocks?
Because the clocks are manually enabled in probe and there is no devm action registered to disable them, the clock references will be permanently leaked when the module is unbound or removed.
Could this leave the hardware clocks physically powered if CONFIG_PM is disabled?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4