Skip to contentSkip to conversation

ASoC: cdns: Add Cadence I2S-SC and I2S-MC controller support

PATCH Superseded [email protected] 3 participants 9 messages Oct 19 – Oct 20

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 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 v4:
- Enforce the dma-names order in the bindings: a single "tx" or "rx" name is still allowed for single-direction instances, but a pair must be "tx", "rx".
- Drop the DMA controller stub node from the binding examples.
- Select REGMAP_MMIO; a COMPILE_TEST build without it would fail to link the regmap MMIO users.
- Include the transmitter and receiver synchronizing-unit reset bits in the masked register write of the I2S-MC DAI probe, so that the write actually programs the state its comment describes.

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       |  119 ++
 .../bindings/sound/cix,sky1-i2s-sc.yaml       |   89 ++
 sound/soc/Kconfig                             |    1 +
 sound/soc/Makefile                            |    1 +
 sound/soc/cdns/Kconfig                        |   23 +
 sound/soc/cdns/Makefile                       |    7 +
 sound/soc/cdns/cdns-i2s-mc.c                  | 1128 ++++++++++++++++
 sound/soc/cdns/cdns-i2s-sc.c                  | 1166 +++++++++++++++++
 8 files changed, 2534 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
#1 lore raw

PATCH v4 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       | 89 +++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml
Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml new file +89 -0
new file mode 100644
index 000000000000..9ef11272d0fd
@@ -0,0 +1,89 @@
+# 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
+    items:
+      - enum: [ tx, rx ]
+      - const: 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>
+
+    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
maintainer Reviewed-by on v4 1/4
#2 lore raw

Re: [PATCH v4 1/4] ASoC: dt-bindings: Add Cadence I2S-SC controller

Quoted 7 lines · On Mon, 19 Oct 2026 20:20:45 +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.

Quoted 6 lines
---
 .../bindings/sound/cix,sky1-i2s-sc.yaml       | 89 +++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-sc.yaml
#3 lore raw

PATCH v4 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       |   12 +
 sound/soc/cdns/Makefile      |    4 +
 sound/soc/cdns/cdns-i2s-sc.c | 1166 ++++++++++++++++++++++++++++++++++
 5 files changed, 1184 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
index edfdcbf734fe..d9b746ffd701 100644
@@ -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
index 21d8406767fc..ba3cf6eb937a 100644
@@ -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 +12 -0
new file mode 100644
index 000000000000..06fd8fd6cb54
@@ -0,0 +1,12 @@
+# 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
+	select REGMAP_MMIO
+	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
new file mode 100644
index 000000000000..6abfeef29e43
@@ -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
#4 lore raw

Re: [PATCH v4 2/4] ASoC: cdns: Add Cadence I2S-SC controller driver

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] ASoC: cdns: unbalanced clock enable in cdns_i2s_sc_probe() and on unbind - [Medium] ASoC: cdns…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] ASoC: cdns: unbalanced clock enable in cdns_i2s_sc_probe() and on unbind
- [Medium] ASoC: cdns: wrong devres ordering for IRQ and PM in cdns_i2s_sc_probe()
- [Medium] ASoC: cdns: cdns_i2s_sc_set_tdm_slot() rejects slots == 0 to disable TDM --

commit 2113a0aa999e1c1986bfd71dc4824e99103d3036
Author: Joakim Zhang <[email protected]>

ASoC: cdns: Add Cadence I2S-SC controller driver

This patch adds an ASoC CPU DAI driver for the Cadence I2S-SC controller found in the CIX SKY1 audio subsystem. It supports full-duplex stereo I2S, left/right-justified, DSP, and TDM modes with up to 16 slots, along with runtime and system power management.

Quoted 6 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
new file mode 100644
index 0000000000000..160a0ec573d72
@@ -0,0 +1,1166 @@

[ ... ]

Quoted 23 lines
sound/soc/cdns/cdns-i2s-sc.c new file +23 -0
+static int cdns_i2s_sc_set_tdm_slot(struct snd_soc_dai *cpu_dai, unsigned int tx_mask,
+				    unsigned int rx_mask, int slots, int slot_width)
+{
+	struct cdns_i2s_sc_priv *i2s_sc_priv = snd_soc_dai_get_drvdata(cpu_dai);
+	struct device *dev = i2s_sc_priv->dev;
+
+	dev_dbg(dev, "tx_mask = 0x%x, rx_mask = 0x%x, slots = %d, slot_width = %d\n",
+		tx_mask, rx_mask, slots, slot_width);
+
+	if (slots < 1 || slots > 16) {
+		dev_err(i2s_sc_priv->dev, "TDM mode supports 1 to 16 slots\n");
+		return -EINVAL;
+	}
+
+	if (slot_width < 8 || slot_width > 32) {
+		dev_err(i2s_sc_priv->dev, "TDM slot width must be 8 to 32 bits\n");
+		return -EINVAL;
+	}
+
+	if ((tx_mask >> slots) || (rx_mask >> slots)) {
+		dev_err(i2s_sc_priv->dev, "TDM slot mask has bits outside the slots\n");
+		return -EINVAL;
+	}

sound/soc/cdns/cdns-i2s-sc.c line 446

Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +10 -0
+
+	i2s_sc_priv->tdm_config.slots = slots;
+	i2s_sc_priv->tdm_config.slot_width = slot_width;
+	i2s_sc_priv->tdm_config.rx_mask = rx_mask;
+	i2s_sc_priv->tdm_config.tx_mask = tx_mask;
+
+	i2s_sc_priv->is_tdm_mode = true;
+
+	return 0;
+}

[Severity: Medium]
How can a machine driver or generic card helper disable TDM mode once cdns_i2s_sc_set_tdm_slot() has set i2s_sc_priv->is_tdm_mode to true?

In sound/soc/soc-dai.c, snd_soc_dai_set_tdm_slot() documents that TDM mode is disabled by passing 0 for slots (with tx_mask, rx_mask, and slot_width ignored) and forwards that call directly to ops->set_tdm_slot():

sound/soc/soc-dai.c:snd_soc_dai_set_tdm_slot() {
/*
* TDM mode can be disabled by passing 0 for @slots. In this case @tx_mask,
* @rx_mask and @slot_width will be ignored.
*/
}

Here in cdns_i2s_sc_set_tdm_slot(), slots == 0 is rejected with -EINVAL by the slots < 1 check, and nothing else resets i2s_sc_priv->is_tdm_mode to false. Should slots == 0 set i2s_sc_priv->is_tdm_mode = false and return 0?

[ ... ]

Quoted 2 lines
sound/soc/cdns/cdns-i2s-sc.c new file +2 -0
+static int cdns_i2s_sc_probe(struct platform_device *pdev)
+{

[ ... ]

Quoted 19 lines
sound/soc/cdns/cdns-i2s-sc.c new file +19 -0
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable runtime PM\n");
+	}
+
+	ret = cdns_i2s_sc_clks_enable(i2s_sc_priv);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
+	}
+
+	cdns_i2s_sc_rst(i2s_sc_priv);
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		ret = irq;

sound/soc/cdns/cdns-i2s-sc.c line 1043

Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +10 -0
+		goto err_disable_clks;
+	}
+	i2s_sc_priv->irq = irq;
+
+	ret = devm_request_irq(&pdev->dev, irq, cdns_i2s_sc_isr, 0,
+			       dev_name(&pdev->dev), i2s_sc_priv);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);
+		goto err_disable_clks;
+	}

[Severity: Medium]
Can devres teardown invoke cdns_i2s_sc_runtime_suspend() or cdns_i2s_sc_runtime_resume() after the IRQ has already been freed?

In cdns_i2s_sc_probe(), devm_pm_runtime_enable() is registered before devm_request_irq(). Because devres unwinds in reverse registration order, free_irq() runs while runtime PM is still enabled.

If a runtime PM transition runs during teardown before pm_runtime_disable() executes (for example, when component removal closes an active stream), cdns_i2s_sc_runtime_suspend() and cdns_i2s_sc_runtime_resume() will call disable_irq(i2s_sc_priv->irq) or enable_irq(i2s_sc_priv->irq) on the already-freed IRQ.

Should devm_request_irq() be registered before enabling runtime PM (or with IRQF_NO_AUTOEN before enabling clocks and runtime PM)?

Quoted 9 lines
sound/soc/cdns/cdns-i2s-sc.c new file +9 -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);

sound/soc/cdns/cdns-i2s-sc.c line 1062

Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +10 -0
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to register soc component\n");
+
+	return 0;
+
+err_disable_clks:
+	cdns_i2s_sc_clks_disable(i2s_sc_priv);
+	pm_runtime_put_noidle(&pdev->dev);
+	return ret;
+}

[Severity: Medium]
Does this leak the prepare and enable references on clk_hst and clk_i2s when CONFIG_PM is disabled or when the device is runtime-active at teardown?

In cdns_i2s_sc_probe(), clk_hst and clk_i2s are acquired with devm_clk_get() and manually enabled via cdns_i2s_sc_clks_enable(). Then pm_runtime_put_sync() is used to drop the runtime PM usage count.

When CONFIG_PM is disabled (or if runtime suspend is prevented via sysfs power/control), pm_runtime_put_sync() does not run cdns_i2s_sc_runtime_suspend(), so clk_hst and clk_i2s remain prepared and enabled. If devm_snd_soc_register_component() then fails, cdns_i2s_sc_probe() returns without calling cdns_i2s_sc_clks_disable().

Similarly, cdns_i2s_sc_driver has no .remove callback and registers no devm action to disable the clocks, and devm_pm_runtime_enable() only calls pm_runtime_disable() on unbind without suspending the device. Unbinding the driver while CONFIG_PM is disabled or while the device is runtime-active will leave clk_hst and clk_i2s enabled when devm_clk_get() releases them.

In addition, on the earlier error paths in cdns_i2s_sc_probe() (when devm_pm_runtime_enable(), cdns_i2s_sc_clks_enable(), platform_get_irq(), or devm_request_irq() fails), pm_runtime_set_active() is not undone with pm_runtime_set_suspended().

[ ... ]

Quoted 9 lines
sound/soc/cdns/cdns-i2s-sc.c new file +9 -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,
+	},
+};
+module_platform_driver(cdns_i2s_sc_driver);

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

PATCH v4 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       | 119 ++++++++++++++++++
 1 file changed, 119 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-mc.yaml
Documentation/devicetree/bindings/sound/cix,sky1-i2s-mc.yaml new file +119 -0
new file mode 100644
index 000000000000..e750009edbdb
@@ -0,0 +1,119 @@
+# 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
+    items:
+      - enum: [ tx, rx ]
+      - const: 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>
+
+    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
maintainer Reviewed-by on v4 3/4
#6 lore raw

Re: [PATCH v4 3/4] ASoC: dt-bindings: Add Cadence I2S-MC controller

Quoted 9 lines · On Mon, 19 Oct 2026 20:20:47 +0800, [email protected] wrote:

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.

Quoted 6 lines
---
 .../bindings/sound/cix,sky1-i2s-mc.yaml       | 119 ++++++++++++++++++
 1 file changed, 119 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cix,sky1-i2s-mc.yaml
#7 lore raw

PATCH v4 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       |   11 +
 sound/soc/cdns/Makefile      |    3 +
 sound/soc/cdns/cdns-i2s-mc.c | 1128 ++++++++++++++++++++++++++++++++++
 3 files changed, 1142 insertions(+)
 create mode 100644 sound/soc/cdns/cdns-i2s-mc.c
sound/soc/cdns/Kconfig +11 -0
index 06fd8fd6cb54..d0ef3ced06b2 100644
@@ -10,3 +10,14 @@ 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
+	select REGMAP_MMIO
+	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
index 6abfeef29e43..e440bb2bb5ca 100644
@@ -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 +1128 -0

1,128 lines not on this page · raw message

Signature · 1 line
2.50.1
#8 lore raw

Re: [PATCH v4 4/4] ASoC: cdns: Add Cadence I2S-MC controller driver

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] ASoC: cdns: shared clk_i2s reparented in cdns_i2s_mc_hw_params() while active - [Medium] ASoC…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] ASoC: cdns: shared clk_i2s reparented in cdns_i2s_mc_hw_params() while active
- [Medium] ASoC: cdns: clock and runtime PM leak in cdns_i2s_mc_probe() and on remove
- [Medium] ASoC: cdns: devm_pm_runtime_enable() ordered before IRQ in cdns_i2s_mc_probe() --

commit b995dbd0c500d9df940a91311e64f2712a2548e6
Author: Joakim Zhang <[email protected]>

ASoC: cdns: Add Cadence I2S-MC controller driver

This commit adds ASoC driver support for the Cadence I2S-MC multi-channel controller found in the CIX SKY1 audio subsystem. It exposes playback and capture DAIs using dmaengine PCM, manages audio reference clock parenting, and handles runtime and system power management.

Quoted 6 lines
sound/soc/cdns/cdns-i2s-mc.c new file +0 -0
new file mode 100644
index 0000000000000..defbb93adfe76
@@ -0,0 +1,1128 @@

[ ... ]

Quoted 23 lines
sound/soc/cdns/cdns-i2s-mc.c new file +23 -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 */
+	if (rate % 8000 == 0) {
+		/* Sampling rate is a multiple of 8KHz, select "audio-clk0" */
+		clk_parent = i2s_mc_priv->clks[AUDIO_CLK0];
+

sound/soc/cdns/cdns-i2s-mc.c line 586

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+		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);
+	} else {
+		dev_err(i2s_mc_priv->dev, "Invalid sample rate\n");
+		return -EINVAL;
+	}

[Severity: Medium]
Can switching the parent of i2s_mc_priv->clk_i2s here corrupt an already active stream on the other DAI?

The driver exposes two separate DAIs in cdns_i2s_mc_dai[] (i2s-mc-aif1 for playback and i2s-mc-aif2 for capture), which can be opened and configured independently. Both DAIs share the single functional clock i2s_mc_priv->clk_i2s.

If one DAI is running at a multiple of 8 kHz (using clks[AUDIO_CLK0]) and userspace calls snd_pcm_hw_params() -> cdns_i2s_mc_hw_params() on the second DAI with a multiple of 11.025 kHz (using clks[AUDIO_CLK2]), clk_set_parent() will change the parent of clk_i2s underneath the active stream. That changes i2s_clk_rate while the first stream is active, invalidating its programmed I2S_SRR divider (I2S_SRR_TSAMPLE_RATE or I2S_SRR_RSAMPLE_RATE) and potentially violating I2S_CLK_RATIO_MIN_MASTER or I2S_CLK_RATIO_MIN_SLAVE.

Should cdns_i2s_mc_hw_params() check whether the other stream is already configured with an incompatible clock parent, or constrain the two DAIs to the same rate family when both are active?

[ ... ]

Quoted 2 lines
sound/soc/cdns/cdns-i2s-mc.c new file +2 -0
+static int cdns_i2s_mc_probe(struct platform_device *pdev)
+{

[ ... ]

Quoted 19 lines
sound/soc/cdns/cdns-i2s-mc.c new file +19 -0
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable runtime PM\n");
+	}
+
+	ret = cdns_i2s_mc_clks_enable(i2s_mc_priv);
+	if (ret) {
+		pm_runtime_put_noidle(&pdev->dev);
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
+	}
+
+	cdns_i2s_mc_rst(i2s_mc_priv);
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		ret = irq;

sound/soc/cdns/cdns-i2s-mc.c line 1004

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+		goto err_disable_clks;
+	}
+	i2s_mc_priv->irq = irq;
+
+	ret = devm_request_irq(&pdev->dev, irq, cdns_i2s_mc_isr, 0,
+			       dev_name(&pdev->dev), i2s_mc_priv);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);
+		goto err_disable_clks;
+	}

[Severity: Medium]
Is the devres registration order between devm_pm_runtime_enable() and devm_request_irq() safe during teardown?

In cdns_i2s_mc_probe(), devm_pm_runtime_enable() is registered before i2s_mc_priv->irq is assigned and before devm_request_irq() is called. Because devres unwinds in reverse order, on driver unbind or if devm_snd_soc_register_component() fails, devm_irq_release() calls free_irq() before pm_runtime_disable_action() disables runtime PM.

Since cdns_i2s_mc_runtime_suspend() calls disable_irq(i2s_mc_priv->irq) and cdns_i2s_mc_runtime_resume() calls enable_irq(i2s_mc_priv->irq), a runtime PM transition occurring before runtime PM is disabled can call enable_irq() or disable_irq() on an already-freed IRQ. It also leaves the IRQ disabled when devm_irq_release() frees it.

Should platform_get_irq() and devm_request_irq() be moved before devm_pm_runtime_enable()?

Quoted 9 lines
sound/soc/cdns/cdns-i2s-mc.c new file +9 -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));

sound/soc/cdns/cdns-i2s-mc.c line 1023

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to register soc component\n");
+
+	return 0;
+
+err_disable_clks:
+	cdns_i2s_mc_clks_disable(i2s_mc_priv);
+	pm_runtime_put_noidle(&pdev->dev);
+	return ret;
+}

[Severity: Medium]
Does cdns_i2s_mc_probe() leak the prepare/enable counts on clk_hst and clk_i2s when devm_snd_soc_register_component() fails or when the driver is unbound?

In cdns_i2s_mc_probe(), clk_hst and clk_i2s are enabled via cdns_i2s_mc_clks_enable(), and the driver relies on pm_runtime_put_sync() running cdns_i2s_mc_runtime_suspend() to disable them. There is no devm action or .remove callback in cdns_i2s_mc_driver to disable the clocks.

When CONFIG_PM is disabled (where pm_runtime_put_sync() is a no-op and the clocks stay powered) or when runtime suspend is prevented (for example via sysfs power/control), if devm_snd_soc_register_component() fails, cdns_i2s_mc_probe() returns without calling cdns_i2s_mc_clks_disable(). The same leak occurs on driver unbind because devm_pm_runtime_enable() only calls pm_runtime_disable() and does not invoke cdns_i2s_mc_runtime_suspend() when the device is still runtime-active.

Also, on the error paths after pm_runtime_set_active(&pdev->dev) (when devm_pm_runtime_enable(), cdns_i2s_mc_clks_enable(), platform_get_irq(), or devm_request_irq() fails), pm_runtime_set_suspended(&pdev->dev) is not called, leaving the runtime PM status marked active while the clocks are disabled.

[ ... ]

Quoted 8 lines
sound/soc/cdns/cdns-i2s-mc.c new file +8 -0
+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,
+	},
+};

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4