Skip to contentSkip to conversation

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

PATCH Superseded [email protected] 3 participants 11 messages Sep 28 – Oct 9

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 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 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                  | 1121 ++++++++++++++++
 sound/soc/cdns/cdns-i2s-sc.c                  | 1160 +++++++++++++++++
 8 files changed, 2527 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 v2 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
new file mode 100644
index 000000000000..3fdf2334c492
@@ -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
#2 lore raw

PATCH v2 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 | 1160 ++++++++++++++++++++++++++++++++++
 5 files changed, 1177 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 +11 -0
new file mode 100644
index 000000000000..631e2e0764cb
@@ -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
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 +1160 -0

1,160 lines not on this page · raw message

Signature · 1 line
2.50.1
#3 lore raw

Re: [PATCH v2 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] sound/soc/cdns: resource leak in probe error paths - [High] sound/soc/cdns: missing remove…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] sound/soc/cdns: resource leak in probe error paths
- [High] sound/soc/cdns: missing remove callback causes clock leak and unbalanced IRQ
- [High] sound/soc/cdns: race condition in ISR dropping interrupts via regmap_update_bits
- [High] sound/soc/cdns: inverted ALSA DAI master/slave format mapping
--

commit 56f3604b0b0ce570297b51aeb442be0b9378dd2b
Author: Joakim Zhang <[email protected]>

ASoC: cdns: Add Cadence I2S-SC controller driver

This commit introduces the driver for the Cadence I2S-SC controller found 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.

Quoted 5 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
new file mode 100644
index 0000000000000..99ba7e34a06f1

[ ... ]

sound/soc/cdns/cdns-i2s-sc.c static irqreturn_t cdns_i2s_sc_isr(int irq, void *devid) · line 420

Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
@@ -412,18 +412,18 @@ static irqreturn_t cdns_i2s_sc_isr(int irq, void *devid)
 	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]
Does this create a race condition that can drop concurrent interrupts?

In cdns_i2s_sc_isr(), regmap_update_bits() performs a read-modify-write on a volatile interrupt status register. If a new interrupt arrives between the read and the write, writing back the modified value will incorrectly clear the newly arrived interrupt or fail to clear the handled ones, depending on whether the register is W0C or W1C.

Should this use regmap_write() directly to avoid losing hardware interrupts?

[ ... ]

Quoted 4 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
@@ -495,19 +495,19 @@ static int cdns_i2s_sc_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 		return -EINVAL;
 	}
 

sound/soc/cdns/cdns-i2s-sc.c static int cdns_i2s_sc_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) · line 507

Quoted 10 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -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]
Does this code invert the ALSA DAI master/slave format mapping?

When the machine driver requests SND_SOC_DAIFMT_CBC_CFC (Codec Clock Consumer, meaning CPU is Master), the driver clears I2S_CTRL_MS_CFG and sets is_master_mode = false, configuring the CPU DAI as a slave.

Conversely, when requested to be a slave (SND_SOC_DAIFMT_CBP_CFP), it configures the CPU DAI as a master. Does this prevent correct audio playback and capture?

[ ... ]

sound/soc/cdns/cdns-i2s-sc.c static int cdns_i2s_sc_probe(struct platform_device *pdev) · line 961

Quoted 13 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
@@ -950,20 +950,20 @@ static int cdns_i2s_sc_probe(struct platform_device *pdev)
 	ret = cdns_i2s_sc_clks_enable(i2s_sc_priv);
 	if (ret) {
 		dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
 		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
 	}
 
 	cdns_i2s_sc_rst(i2s_sc_priv);
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;

[Severity: High]
Does this error path leak manually enabled clocks and the PM runtime usage counter?

If platform_get_irq() fails, the function returns directly without dropping the PM runtime reference (pm_runtime_put_noidle()) or disabling the clocks (cdns_i2s_sc_clks_disable()). This prevents the device from entering low power states and prevents clock gating if this error path is taken.

Quoted 9 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
 	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);
 		pm_runtime_put_noidle(&pdev->dev);
 		return ret;

}

[Severity: High]
Does this error path fail to disable the clocks?

If devm_request_irq() fails, it correctly drops the PM runtime reference by calling pm_runtime_put_noidle(), but it fails to call cdns_i2s_sc_clks_disable(). This leaves the clocks permanently enabled on this error path.

[ ... ]

sound/soc/cdns/cdns-i2s-sc.c static const struct of_device_id cdns_i2s_sc_of_match[] = { · line 1155

Quoted 11 lines
sound/soc/cdns/cdns-i2s-sc.c new file +0 -0
@@ -1146,13 +1146,13 @@ static const struct of_device_id cdns_i2s_sc_of_match[] = {
 MODULE_DEVICE_TABLE(of, cdns_i2s_sc_of_match);
 
 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: High]
Is this missing a .remove callback to symmetrically tear down manually enabled clocks and IRQ states?

In cdns_i2s_sc_driver, there is no .remove callback. If the driver is unbound via sysfs or module removal, the driver core resumes the device (if suspended) before unbind, but the manually enabled clocks are never disabled.

Additionally, this could leave the hardware IRQ disabled permanently if unbound while runtime-suspended, which triggers a kernel warning on free_irq() and prevents the IRQ from being reused. Should a .remove callback be added to properly release these resources?

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

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

In reply to [email protected]
Quoted 65 lines · On 9/28/2026 11:06 AM, [email protected] wrote:

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.

---

(quoted diff) +40 -0
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/reset.h>
+#include <sound/dmaengine_pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
 
+static int cdns_i2s_sc_clks_enable(struct cdns_i2s_sc_priv *i2s_sc_priv)
+{
+	int ret;
+
+	ret = clk_prepare_enable(i2s_sc_priv->clk_hst);
+	if (ret)
+		return ret;
+
+	ret = clk_prepare_enable(i2s_sc_priv->clk_i2s);
+	if (ret)
+		clk_disable_unprepare(i2s_sc_priv->clk_hst);
+
+	return ret;
+}
+
+static void cdns_i2s_sc_clks_disable(struct cdns_i2s_sc_priv *i2s_sc_priv)
+{
+	clk_disable_unprepare(i2s_sc_priv->clk_i2s);
+	clk_disable_unprepare(i2s_sc_priv->clk_hst);
+}
+
+static void cdns_i2s_sc_rxtx_common_config(struct cdns_i2s_sc_priv *i2s_sc_priv, bool on)
+{
+	if (on) {
+		/* Full-duplex mode enable */
+		regmap_update_bits(i2s_sc_priv->regmap, I2S_CTRL_FDX,
+				   I2S_CTRL_FDX_FULL_DUPLEX, I2S_CTRL_FDX_FULL_DUPLEX);
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+		if (i2s_sc_priv->is_tdm_mode) {
+			/* TDM mode enable */
+			regmap_update_bits(i2s_sc_priv->regmap, I2S_TDM_CTRL,
+					   I2S_TDM_CTRL_TDM_EN, I2S_TDM_CTRL_TDM_EN);
+
+			/* Number of supported audio channels in TDM mode */
+			regmap_update_bits(i2s_sc_priv->regmap, I2S_TDM_CTRL,
+					   I2S_TDM_CTRL_CHN_NO,
+					   FIELD_PREP(I2S_TDM_CTRL_CHN_NO,
+						      i2s_sc_priv->tdm_config.slots - 1));

This driver uses FIELD_PREP() in several register programming paths, but it does not include <linux/bitfield.h>. A local targeted build with

M=sound/soc/cdns W=1 fails with:

error: implicit declaration of function 'FIELD_PREP'

Please add the explicit bitfield.h include. After adding that include locally, cdns-i2s-sc.c gets past this compile error.

Quoted 16 lines
(quoted diff) +15 -0
+
+			/* TDM mode channels enable */
+			regmap_update_bits(i2s_sc_priv->regmap, I2S_TDM_CTRL, I2S_TDM_CTRL_CHN_EN,
+					   FIELD_PREP(I2S_TDM_CTRL_CHN_EN,
+						      i2s_sc_priv->tdm_config.rx_mask |
+						      i2s_sc_priv->tdm_config.tx_mask));
+		}
 
+	ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to register dmaengine component\n");
+
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable runtime PM\n");
+
+	ret = cdns_i2s_sc_clks_enable(i2s_sc_priv);
+	if (ret) {
+		dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
+		pm_runtime_put_noidle(&pdev->dev);
+		return ret;
+	}
+

After cdns_i2s_sc_clks_enable() succeeds, the platform_get_irq() failure path returns directly without disabling the clocks or dropping the runtime PM usage count. The devm_request_irq() failure path has a similar issue: it calls pm_runtime_put_noidle(), but that will not run the runtime suspend callback, so the clocks enabled manually above remain prepared/enabled.

Thanks
Ajay Kumar Nandam

Quoted 14 lines
sound/soc/cdns/cdns-i2s-sc.c new file +14 -0
+	cdns_i2s_sc_rst(i2s_sc_priv);
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+	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);
+		pm_runtime_put_noidle(&pdev->dev);
+		return ret;
+	}
#5 lore raw

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

Hello,

Quoted 99 lines

-----Original Message-----
From: Ajay Kumar Nandam <[email protected]>
Sent: Wednesday, October 7, 2026 5:29 PM
To: Joakim Zhang (张强庆) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: cix-kernel-upstream <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 2/4] ASoC: cdns: Add Cadence I2S-SC controller driver

[你通常不会收到来自 [email protected] 的电子邮件。请访问
https://aka.ms/LearnAboutSenderIdentification,以了解这一点为什么很重要]

EXTERNAL EMAIL

Quoted 68 lines · On 9/28/2026 11:06 AM, [email protected] wrote:

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.

---

(quoted diff) +43 -0
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/reset.h>
+#include <sound/dmaengine_pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
 
+static int cdns_i2s_sc_clks_enable(struct cdns_i2s_sc_priv
+*i2s_sc_priv) {
+     int ret;
+
+     ret = clk_prepare_enable(i2s_sc_priv->clk_hst);
+     if (ret)
+             return ret;
+
+     ret = clk_prepare_enable(i2s_sc_priv->clk_i2s);
+     if (ret)
+             clk_disable_unprepare(i2s_sc_priv->clk_hst);
+
+     return ret;
+}
+
+static void cdns_i2s_sc_clks_disable(struct cdns_i2s_sc_priv
+*i2s_sc_priv) {
+     clk_disable_unprepare(i2s_sc_priv->clk_i2s);
+     clk_disable_unprepare(i2s_sc_priv->clk_hst);
+}
+
+static void cdns_i2s_sc_rxtx_common_config(struct cdns_i2s_sc_priv
+*i2s_sc_priv, bool on) {
+     if (on) {
+             /* Full-duplex mode enable */
+             regmap_update_bits(i2s_sc_priv->regmap, I2S_CTRL_FDX,
+                                I2S_CTRL_FDX_FULL_DUPLEX,
+I2S_CTRL_FDX_FULL_DUPLEX);
+
+             if (i2s_sc_priv->is_tdm_mode) {
+                     /* TDM mode enable */

Review

Quoted 10 lines
(quoted diff) +10 -0
+                     regmap_update_bits(i2s_sc_priv->regmap, I2S_TDM_CTRL,
+                                        I2S_TDM_CTRL_TDM_EN,
+ I2S_TDM_CTRL_TDM_EN);
+
+                     /* Number of supported audio channels in TDM mode */
+                     regmap_update_bits(i2s_sc_priv->regmap, I2S_TDM_CTRL,
+                                        I2S_TDM_CTRL_CHN_NO,
+                                        FIELD_PREP(I2S_TDM_CTRL_CHN_NO,
+
+ i2s_sc_priv->tdm_config.slots - 1));

This driver uses FIELD_PREP() in several register programming paths, but it does not include <linux/bitfield.h>. A local targeted build with

Quoted 6 lines

M=sound/soc/cdns W=1 fails with:

error: implicit declaration of function 'FIELD_PREP'

Please add the explicit bitfield.h include. After adding that include locally, cdns-i2s- sc.c gets past this compile error.

Yes, will update in v3.

Quoted 27 lines

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

Quoted 3 lines
sound/soc/cdns/cdns-i2s-sc.c new file +3 -0
+
+                     /* TDM mode channels enable */
+                     regmap_update_bits(i2s_sc_priv->regmap, I2S_TDM_CTRL,

I2S_TDM_CTRL_CHN_EN,

Quoted 23 lines
sound/soc/cdns/cdns-i2s-sc.c new file +22 -0
+                                        FIELD_PREP(I2S_TDM_CTRL_CHN_EN,
+                                                   i2s_sc_priv->tdm_config.rx_mask |
+                                                   i2s_sc_priv->tdm_config.tx_mask));
+             }
 
+     ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
+     if (ret)
+             return dev_err_probe(&pdev->dev, ret,
+                                  "Failed to register dmaengine
+ component\n");
+
+     pm_runtime_get_noresume(&pdev->dev);
+     pm_runtime_set_active(&pdev->dev);
+     ret = devm_pm_runtime_enable(&pdev->dev);
+     if (ret)
+             return dev_err_probe(&pdev->dev, ret, "Failed to enable
+ runtime PM\n");
+
+     ret = cdns_i2s_sc_clks_enable(i2s_sc_priv);
+     if (ret) {
+             dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
+             pm_runtime_put_noidle(&pdev->dev);
+             return ret;
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     }
+

After cdns_i2s_sc_clks_enable() succeeds, the platform_get_irq() failure path returns directly without disabling the clocks or dropping the runtime PM usage count. The devm_request_irq() failure path has a similar issue: it calls pm_runtime_put_noidle(), but that will not run the runtime suspend callback, so the clocks enabled manually above remain prepared/enabled.

Yes, thanks, will update in v3.

Joakim

#6 lore raw

PATCH v2 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
new file mode 100644
index 000000000000..22528bb2940e
@@ -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
#7 lore raw

PATCH v2 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 | 1121 ++++++++++++++++++++++++++++++++++
 3 files changed, 1134 insertions(+)
 create mode 100644 sound/soc/cdns/cdns-i2s-mc.c
sound/soc/cdns/Kconfig +10 -0
index 631e2e0764cb..aa5d35992a81 100644
@@ -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
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 +1121 -0

1,121 lines not on this page · raw message

Signature · 1 line
2.50.1
#8 lore raw

Re: [PATCH v2 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] ASoC: cdns: inverted clock provider/consumer configuration - [High] ASoC: cdns: unprotected clock…

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] ASoC: cdns: inverted clock provider/consumer configuration
- [High] ASoC: cdns: unprotected clock reparenting disrupts concurrent streams
- [High] ASoC: cdns: PM usage counter and clock leaks in probe error paths and unbind
- [High] ASoC: cdns: synchronizing unit resets bypassed by incomplete regmap mask
- [High] ASoC: cdns: unsafe read-modify-write on interrupt status register
- [High] ASoC: cdns: inconsistent DATA_WS_DEL alignment logic across formats
- [Medium] ASoC: cdns: unbalanced disable_irq() corrupts global IRQ descriptor --

commit 45344ef2691191bb925ca3e036d7808018f75305
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. The driver registers the dmaengine PCM helper, selects the audio reference clock parent and implements runtime PM and system suspend/resume.

Quoted 4 lines
sound/soc/cdns/cdns-i2s-mc.c new file +0 -0
new file mode 100644

[ ... ]

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 278

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 correctly handle write-1-to-clear semantics? Using regmap_update_bits() reads the register, writes 0 to the handled bits, and writes the preserved 1s to unhandled bits. If the register is write-1-to-clear, this could fail to clear handled interrupts and erroneously clear newly arrived interrupts without handling them. Could a direct regmap_write() be used here instead?

Quoted 4 lines
sound/soc/cdns/cdns-i2s-mc.c new file +4 -0
+
+	/* Transmitter status */
+	if (stat & I2S_INTR_STAT_TDATA_UNDERR)
+		dev_dbg(dev, "isr: tx data underrun\n");

[ ... ]

Quoted 2 lines
sound/soc/cdns/cdns-i2s-mc.c new file +2 -0
+static int cdns_i2s_mc_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+{

[ ... ]

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

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

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+		case SND_SOC_DAIFMT_DSP_A:
+			dev_conf |= I2S_DEV_CONF_TRAN_I2S_ALIGN_LR | I2S_DEV_CONF_TRAN_DATA_WS_DEL |
+				    I2S_DEV_CONF_TRAN_WS_DSP_MODE;
+			dev_conf &= ~I2S_DEV_CONF_TRAN_APB_ALIGN_LR;
+			break;
+		case SND_SOC_DAIFMT_DSP_B:
+			dev_conf |= I2S_DEV_CONF_TRAN_I2S_ALIGN_LR | I2S_DEV_CONF_TRAN_WS_DSP_MODE;
+			dev_conf &= ~(I2S_DEV_CONF_TRAN_APB_ALIGN_LR |
+				      I2S_DEV_CONF_TRAN_DATA_WS_DEL);
+			break;

[Severity: High]
Is this delay phase mapping contradictory? The I2S_DEV_CONF_TRAN_DATA_WS_DEL bit is cleared for SND_SOC_DAIFMT_I2S (1-clock delay) but set for SND_SOC_DAIFMT_DSP_A (also 1-clock delay). Conversely, it is set for SND_SOC_DAIFMT_LEFT_J (0-clock delay) but cleared for SND_SOC_DAIFMT_DSP_B (also 0-clock delay). This seems to result in misaligned phase for at least two of the supported formats.

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

Quoted 9 lines
sound/soc/cdns/cdns-i2s-mc.c new file +9 -0
+		default:
+			return -EINVAL;
+		}
+
+		/* DAI hardware clock masters */
+		switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
+		case SND_SOC_DAIFMT_CBC_CFC:
+			ctrl &= ~I2S_CTRL_T_MS;
+			break;

[Severity: High]
Does this invert the master/slave configuration? For SND_SOC_DAIFMT_CBC_CFC (Codec Bit/Frame Clock Consumer), the CPU DAI must act as the clock provider (Master), but this clears the I2S_CTRL_T_MS bit.

[ ... ]

Quoted 1 line
sound/soc/cdns/cdns-i2s-mc.c new file +1 -0
+	} else if (cpu_dai->id == I2S_MC_AIF2) {

[ ... ]

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

Quoted 5 lines
sound/soc/cdns/cdns-i2s-mc.c new file +5 -0
+		/* DAI hardware clock masters */
+		switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
+		case SND_SOC_DAIFMT_CBC_CFC:
+			ctrl &= ~I2S_CTRL_R_MS;
+			break;

[Severity: High]
Similarly, this clears the master bit for the receiver DAI when it should be set for SND_SOC_DAIFMT_CBC_CFC.

[ ... ]

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

[ ... ]

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

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

[Severity: High]
Can this reparenting disrupt a concurrent audio stream? Since both playback (I2S_MC_AIF1) and capture (I2S_MC_AIF2) share the single clk_i2s clock, starting a new stream will dynamically reparent the bit clock while the companion stream might be active, potentially causing data corruption.

[ ... ]

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

Quoted 8 lines
sound/soc/cdns/cdns-i2s-mc.c new file +8 -0
+	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) {
+		if (i2s_clk_rate < rate * 2 * slot_width * I2S_CLK_RATIO_MIN_MASTER) {

[Severity: High]
Because I2S_CTRL_T_MS and I2S_CTRL_R_MS are erroneously cleared for CBC_CFC in cdns_i2s_mc_set_fmt(), does this validate the clock frequency against the wrong constraints? The inverted logic cascades here, checking the slave mode multipliers when it should be checking the master mode.

[ ... ]

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 713

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: High]
Does this mask inadvertently bypass the hardware reset sequence? The I2S_CTRL_I2S_EN mask only covers bits 0-7 (GENMASK(7, 0)), completely filtering out the I2S_CTRL_TSYNC_RST (bit 25) and I2S_CTRL_RSYNC_RST (bit 26) modifications made to ctrl just above.

[ ... ]

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 8 lines
sound/soc/cdns/cdns-i2s-mc.c new file +8 -0
+	pm_runtime_get_noresume(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	ret = devm_pm_runtime_enable(&pdev->dev);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to enable runtime PM\n");
+
+	ret = cdns_i2s_mc_clks_enable(i2s_mc_priv);
+	if (ret) {

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

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

[Severity: High]
Does this error path leak the PM usage counter and leave the clocks enabled? The pm_runtime_get_noresume() and cdns_i2s_mc_clks_enable() calls complete successfully above, but this return does not clean them up.

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

Quoted 9 lines
sound/soc/cdns/cdns-i2s-mc.c new file +9 -0
+	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);
+		pm_runtime_put_noidle(&pdev->dev);
+		return ret;
+	}

[Severity: High]
Similar to the issue above, this drops the PM counter but appears to miss calling cdns_i2s_mc_clks_disable(), which permanently leaks the enabled clocks.

[ ... ]

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

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+static int cdns_i2s_mc_runtime_suspend(struct device *dev)
+{
+	struct cdns_i2s_mc_priv *i2s_mc_priv = dev_get_drvdata(dev);
+
+	/*
+	 * Disable the IRQ before switching the regcache to cache-only, so an
+	 * in-flight handler can never access the registers through a
+	 * cache-only regmap. disable_irq() waits for the handler to finish.
+	 */
+	disable_irq(i2s_mc_priv->irq);

[Severity: Medium]
Could this lead to an unbalanced IRQ disable depth? If the probe sequence fails later (e.g., at devm_snd_soc_register_component) or if the device is unbound while suspended, devm will free the IRQ while it is still deeply disabled. Freeing a disabled IRQ does not reverse the global descriptor's disable depth counter, leaving it permanently disabled for future requesters.

[ ... ]

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

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,
+	},
+};

[Severity: High]
Is this missing a .remove callback? Without one, unbinding the module will leave the clocks running permanently and leak hardware resources.

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

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

In reply to [email protected]
Quoted 24 lines · On 9/28/2026 11:06 AM, [email protected] wrote:

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/cdns-i2s-mc.c new file +1 -0
+static void cdns_i2s_mc_rxtx_config(struct cdns_i2s_mc_priv *i2s_mc_priv, bool on,

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

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+				    u8 pin_mask, u32 strobe, u32 sync_rst)
+{
+	u32 irq_mask = 0, clk_mask = 0, i2s_mask = 0;
+
+	irq_mask |= FIELD_PREP(I2S_CID_CTRL_I2S_MASK, pin_mask);
+
+	clk_mask |= FIELD_PREP(I2S_CID_CTRL_I2S_STROBE, pin_mask) | strobe;
+
+	i2s_mask |= FIELD_PREP(I2S_CTRL_I2S_EN, pin_mask);
+

This patch has the same build issue as the SC driver patch: cdns-i2s-mc.c uses FIELD_PREP() but does not include <linux/bitfield.h>.

ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);

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

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

Quoted 10 lines
sound/soc/cdns/cdns-i2s-mc.c new file +10 -0
+		return irq;
+	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);
+		pm_runtime_put_noidle(&pdev->dev);
+		return ret;
+	}

After cdns_i2s_mc_clks_enable() succeeds, the platform_get_irq() failure path returns directly without disabling the clocks or dropping the runtime PM usage count. The devm_request_irq() failure path also calls pm_runtime_put_noidle(), but that will not run the runtime suspend callback, so the clocks enabled manually above remain prepared/enabled.

Thanks
Ajay Kumar Nandam

Quoted 4 lines
sound/soc/cdns/cdns-i2s-mc.c new file +4 -0
+
+	/*
+	 * Let pm_runtime_put_sync() disable the clocks, and take regcache effect.
+	 * If CONFIG_PM is not enabled, the clock will stay powered.
#10 lore raw

RE: [PATCH v2 4/4] ASoC: cdns: Add Cadence I2S-MC controller driver

Hello,

Quoted 40 lines

-----Original Message-----
From: Ajay Kumar Nandam <[email protected]>
Sent: Wednesday, October 7, 2026 5:54 PM
To: Joakim Zhang (张强庆) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: cix-kernel-upstream <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 4/4] ASoC: cdns: Add Cadence I2S-MC controller driver

EXTERNAL EMAIL

Quoted 20 lines · On 9/28/2026 11:06 AM, [email protected] wrote:

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.

Quoted 4 lines

---

+static void cdns_i2s_mc_rxtx_config(struct cdns_i2s_mc_priv *i2s_mc_priv, bool

on,

Quoted 14 lines

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

Quoted 11 lines
sound/soc/cdns/cdns-i2s-mc.c new file +11 -0
+                                 u8 pin_mask, u32 strobe, u32
+sync_rst) {
+     u32 irq_mask = 0, clk_mask = 0, i2s_mask = 0;
+
+     irq_mask |= FIELD_PREP(I2S_CID_CTRL_I2S_MASK, pin_mask);
+
+     clk_mask |= FIELD_PREP(I2S_CID_CTRL_I2S_STROBE, pin_mask) |
+ strobe;
+
+     i2s_mask |= FIELD_PREP(I2S_CTRL_I2S_EN, pin_mask);
+

This patch has the same build issue as the SC driver patch:
cdns-i2s-mc.c uses FIELD_PREP() but does not include <linux/bitfield.h>.

Thanks, will update in v3.

Quoted 32 lines

ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);

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

Review

Quoted 2 lines
(quoted diff) +2 -0
+             return ret;
+     }

After cdns_i2s_mc_clks_enable() succeeds, the platform_get_irq() failure path returns directly without disabling the clocks or dropping the runtime PM usage count. The devm_request_irq() failure path also calls pm_runtime_put_noidle(), but that will not run the runtime suspend callback, so the clocks enabled manually above remain prepared/enabled.

Thanks, will update in v3.

Joakim