Skip to contentSkip to conversation

Add Cadence I2S-MC controller driver

PATCH In review Xingyu Wu 2 participants 8 messages May 8, 2024 – May 22, 2024

Subsystems (3)
lore
Share & tools
lore

Xingyu Wu

author
#0 lore raw

v3 cover Add Cadence I2S-MC controller driver

The Cadence Multi-channel I2S (I2S-MC) Controller implements a function of the multi-channel (up to 8-channel) bus. Each stereo channel combines functions of a transmitter and a receiver, and can switch freely between them. Each channel has independent gating, clock and interruption control. It also support some of these channels are used as playback and others can also be used as record in the same time.

Four I2S controllers are used on the StarFive JH8100 SoC. Two of the I2S controllers use two stereo channels, one of them use four channels, and one use eight. It had tested on the fpga with WM8960 and PDM.

Changes since v2:
- Dropped the description of interrupts in bindings.
- Modified the properties like 'compatible' and 'required'.
- Defined the special property in top-level and made it false in other case in the bindings.
- Added the test of other format in the driver.
- Changed the return values and switch the TX and RX channels for convenience.
- Modified the macros about 'SND_SOC_DAIFMT_CBM_CFM'.
- Added pm_runtime_set_active() to fix the state of pm_runtime.

v2: https://lore.kernel.org/all/[email protected]/

Changes since v1:
- Added new compatible for StarFive JH8100 SoC and a special property to be got as the max channels number in the bindings.
- Dropped the useless '|' in the bindings.
- Moved the drivers to a new folder named 'cdns' and modified the name of functions.

v1: https://lore.kernel.org/all/[email protected]/

Xingyu Wu (2):
ASoC: dt-bindings: Add bindings for Cadence I2S-MC controller
ASoC: cdns: Add drivers of Cadence Multi-Channel I2S Controller

 .../bindings/sound/cdns,i2s-mc.yaml           | 109 +++
 MAINTAINERS                                   |   6 +
 sound/soc/Kconfig                             |   1 +
 sound/soc/Makefile                            |   1 +
 sound/soc/cdns/Kconfig                        |  18 +
 sound/soc/cdns/Makefile                       |   3 +
 sound/soc/cdns/cdns-i2s-mc-pcm.c              | 285 +++++++
 sound/soc/cdns/cdns-i2s-mc.c                  | 704 ++++++++++++++++++
 sound/soc/cdns/cdns-i2s-mc.h                  | 151 ++++
 9 files changed, 1278 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml
 create mode 100644 sound/soc/cdns/Kconfig
 create mode 100644 sound/soc/cdns/Makefile
 create mode 100644 sound/soc/cdns/cdns-i2s-mc-pcm.c
 create mode 100644 sound/soc/cdns/cdns-i2s-mc.c
 create mode 100644 sound/soc/cdns/cdns-i2s-mc.h
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v3 1/2 ASoC: dt-bindings: Add bindings for Cadence I2S-MC controller

Add bindings for the Multi-Channel I2S controller of Cadence.

The Multi-Channel I2S (I2S-MC) implements a function of the 8-channel I2S bus interfasce. Each channel can become receiver or transmitter. Four I2S instances are used on the StarFive JH8100 SoC. One instance of them is limited to 2 channels, two instance are limited to 4 channels, and the other one can use most 8 channels. Add a unique property about 'starfive,i2s-max-channels' to distinguish each instance.

---
 .../bindings/sound/cdns,i2s-mc.yaml           | 109 ++++++++++++++++++
 1 file changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml
Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +109 -0
new file mode 100644
index 000000000000..94ebce7fd5e4
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/cdns,i2s-mc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cadence multi-channel I2S controller
+
+description:
+  The Cadence I2S Controller implements a function of the multi-channel
+  (up to 8-channel) bus. It combines functions of a transmitter and a receiver.
+
+maintainers:
+  - Xingyu Wu <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - starfive,jh8100-i2s
+      - const: cdns,i2s-mc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bit clock
+      - description: Main ICG clock
+      - description: Inner master clock
+
+  clock-names:
+    items:
+      - const: bclk
+      - const: icg
+      - const: mclk_inner
+
+  resets:
+    maxItems: 1
+
+  dmas:
+    items:
+      - description: TX DMA Channel
+      - description: RX DMA Channel
+    minItems: 1
+
+  dma-names:
+    items:
+      - const: tx
+      - const: rx
+    minItems: 1
+
+  "#sound-dai-cells":
+    const: 0
+
+  starfive,i2s-max-channels:
+    description:
+      Number of I2S max stereo channels supported on the StarFive
+      JH8100 SoC.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [2, 4, 8]
+
+allOf:
+  - $ref: dai-common.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh8100-i2s
+    then:
+      required:
+        - starfive,i2s-max-channels
+    else:
+      properties:
+        starfive,i2s-max-channels: false
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - dmas
+  - dma-names
+  - interrupts
+  - "#sound-dai-cells"
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2s@122b0000 {
+      compatible = "starfive,jh8100-i2s", "cdns,i2s-mc";
+      reg = <0x122b0000 0x1000>;
+      clocks = <&syscrg_ne 133>,
+               <&syscrg_ne 170>,
+               <&syscrg 50>;
+      clock-names = "bclk", "icg",
+                    "mclk_inner";
+      resets = <&syscrg_ne 43>;
+      dmas = <&dma 7>, <&dma 6>;
+      dma-names = "tx", "rx";
+      interrupts = <59>;
+      #sound-dai-cells = <0>;
+      starfive,i2s-max-channels = <4>;
+    };
Signature · 1 line
2.25.1
Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] ASoC: dt-bindings: Add bindings for Cadence I2S-MC controller

Quoted 26 lines · Xingyu Wu

Add bindings for the Multi-Channel I2S controller of Cadence.

The Multi-Channel I2S (I2S-MC) implements a function of the 8-channel I2S bus interfasce. Each channel can become receiver or transmitter. Four I2S instances are used on the StarFive JH8100 SoC. One instance of them is limited to 2 channels, two instance are limited to 4 channels, and the other one can use most 8 channels. Add a unique property about 'starfive,i2s-max-channels' to distinguish each instance.

Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +13 -0
+
+  starfive,i2s-max-channels:
+    description:
+      Number of I2S max stereo channels supported on the StarFive
+      JH8100 SoC.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [2, 4, 8]
+
+allOf:
+  - $ref: dai-common.yaml#
+  - if:
+      properties:
+        compatible:

Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml line 80

Quoted 10 lines
Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +10 -0
+          contains:
+            const: starfive,jh8100-i2s
+    then:
+      required:
+        - starfive,i2s-max-channels
+    else:
+      properties:
+        starfive,i2s-max-channels: false
+
+required:

I asked to put it after properties: block, not after allOf:. See example-schema for preferred order. Why? Because we are used to it and it makes reading the schema easier for us.

Rest looks good, so with the re-order:

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v3 1/2] ASoC: dt-bindings: Add bindings for Cadence I2S-MC controller

Quoted 42 lines · Krzysztof Kozlowski
Quoted 26 lines · Xingyu Wu

Add bindings for the Multi-Channel I2S controller of Cadence.

The Multi-Channel I2S (I2S-MC) implements a function of the 8-channel I2S bus interfasce. Each channel can become receiver or transmitter. Four I2S instances are used on the StarFive JH8100 SoC. One instance of them is limited to 2 channels, two instance are limited to 4 channels, and the other one can use most 8 channels. Add a unique property about 'starfive,i2s-max-channels' to distinguish each instance.

Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +13 -0
+
+  starfive,i2s-max-channels:
+    description:
+      Number of I2S max stereo channels supported on the StarFive
+      JH8100 SoC.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [2, 4, 8]
+
+allOf:
+  - $ref: dai-common.yaml#
+  - if:
+      properties:
+        compatible:

Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml line 80

Quoted 10 lines
Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +10 -0
+          contains:
+            const: starfive,jh8100-i2s
+    then:
+      required:
+        - starfive,i2s-max-channels
+    else:
+      properties:
+        starfive,i2s-max-channels: false
+
+required:

I asked to put it after properties: block, not after allOf:. See example-schema for preferred order. Why? Because we are used to it and it makes reading the schema easier for us.

Quoted 3 lines

Rest looks good, so with the re-order:

Since you do not plan to fix it and already started pinging mark, I retract my review.

Unreviewed-by.

Implement the feedback I already asked you BEFORE.

Best regards,
Krzysztof

author
#4 lore raw

RE: [PATCH v3 1/2] ASoC: dt-bindings: Add bindings for Cadence I2S-MC controller

Quoted 51 lines · Krzysztof Kozlowski
Quoted 42 lines · Krzysztof Kozlowski
Quoted 26 lines · Xingyu Wu

Add bindings for the Multi-Channel I2S controller of Cadence.

The Multi-Channel I2S (I2S-MC) implements a function of the 8-channel I2S bus interfasce. Each channel can become receiver or transmitter. Four I2S instances are used on the StarFive
JH8100 SoC. One instance of them is limited to 2 channels, two instance are limited to 4 channels, and the other one can use most 8 channels. Add a unique property about 'starfive,i2s-max-channels' to distinguish each instance.

Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +13 -0
+
+  starfive,i2s-max-channels:
+    description:
+      Number of I2S max stereo channels supported on the StarFive
+      JH8100 SoC.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [2, 4, 8]
+
+allOf:
+  - $ref: dai-common.yaml#
+  - if:
+      properties:
+        compatible:

Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml line 80

Quoted 10 lines
Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml new file +10 -0
+          contains:
+            const: starfive,jh8100-i2s
+    then:
+      required:
+        - starfive,i2s-max-channels
+    else:
+      properties:
+        starfive,i2s-max-channels: false
+
+required:

I asked to put it after properties: block, not after allOf:. See example-schema for preferred order. Why? Because we are used to it and it makes reading the schema easier for us.

Quoted 3 lines

Rest looks good, so with the re-order:

Since you do not plan to fix it and already started pinging mark, I retract my review.

Quoted 6 lines

Unreviewed-by.

Implement the feedback I already asked you BEFORE.

Best regards,
Krzysztof

Sorry, I thought my reply email went out but it didn't. I will re-order it and put the required before the allOf in the next version.

I thought it would be nice to update both bindings and driver patches in the next version, so I ping mark.

Best regards,
Xingyu Wu

author
#5 lore raw

PATCH v3 2/2 ASoC: cdns: Add drivers of Cadence Multi-Channel I2S Controller

In reply to Xingyu Wu

Add the drivers of Cadence Multi-Channel I2S Controller.

The Cadence I2S Controller implements a function of the multi-channel (up to 8-channel) bus. Each stereo channel combines functions of a transmitter and a receiver. Each channel has independent and internal gating, clock and interruption control. It alos support some of these channels are used as playback and others can also be used as record in the same time.

The I2S-MC is used on the StarFive JH8100 SoC and add the compatible for this.

---
 MAINTAINERS                      |   6 +
 sound/soc/Kconfig                |   1 +
 sound/soc/Makefile               |   1 +
 sound/soc/cdns/Kconfig           |  18 +
 sound/soc/cdns/Makefile          |   3 +
 sound/soc/cdns/cdns-i2s-mc-pcm.c | 285 +++++++++++++
 sound/soc/cdns/cdns-i2s-mc.c     | 704 +++++++++++++++++++++++++++++++
 sound/soc/cdns/cdns-i2s-mc.h     | 151 +++++++
 8 files changed, 1169 insertions(+)
 create mode 100644 sound/soc/cdns/Kconfig
 create mode 100644 sound/soc/cdns/Makefile
 create mode 100644 sound/soc/cdns/cdns-i2s-mc-pcm.c
 create mode 100644 sound/soc/cdns/cdns-i2s-mc.c
 create mode 100644 sound/soc/cdns/cdns-i2s-mc.h
MAINTAINERS +6 -0
index ec0284125e8f..b41048f413fc 100644
@@ -4597,6 +4597,12 @@ L:	[email protected]
 S:	Maintained
 F:	tools/testing/selftests/cachestat/test_cachestat.c
 
+CADENCE MULTI CHANNEL I2S CONTROLLER DRIVER
+M:	Xingyu Wu <[email protected]>
+S:	Supported
+F:	Documentation/devicetree/bindings/sound/cdns,i2s-mc.yaml
+F:	sound/soc/cdns/cdns-i2s-mc*
+
 CADENCE MIPI-CSI2 BRIDGES
 M:	Maxime Ripard <[email protected]>
 L:	[email protected]
sound/soc/Kconfig +1 -0
index 439fa631c342..99133baff518 100644
@@ -83,6 +83,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 8376fdb217ed..d0d3d8d22eee 100644
@@ -40,6 +40,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 +18 -0
new file mode 100644
index 000000000000..5fbcfbc85340
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config SND_SOC_CADENCE_I2S_MC
+	tristate "Cadence I2S Multi-Channel Controller Device Driver"
+	depends on HAVE_CLK
+	select SND_SOC_GENERIC_DMAENGINE_PCM
+	help
+	  Say Y or M if you want to add support for I2S driver for the
+	  Cadence Multi-Channel I2S Controller device. The device supports
+	  up to a maximum of 8 channels each for play and record.
+
+config SND_SOC_CADENCE_I2S_MC_PCM
+	bool "PCM PIO extension for CDNS I2S MC driver"
+	depends on SND_SOC_CADENCE_I2S_MC
+	help
+	  Say Y or N if you want to add a custom ALSA extension that registers
+	  a PCM and uses PIO to transfer data.
+	  This functionality is specially suited for CDNS I2S-MC devices that
+	  use Interrupt not DMA controller.
sound/soc/cdns/Makefile new file +3 -0
new file mode 100644
index 000000000000..ca8c040e21df
@@ -0,0 +1,3 @@
+obj-$(CONFIG_SND_SOC_CADENCE_I2S_MC) += cdns-i2s.o
+cdns-i2s-y := cdns-i2s-mc.o
+cdns-i2s-$(CONFIG_SND_SOC_CADENCE_I2S_MC_PCM) += cdns-i2s-mc-pcm.o
sound/soc/cdns/cdns-i2s-mc-pcm.c new file +285 -0

285 lines not on this page · raw message

sound/soc/cdns/cdns-i2s-mc.c new file +704 -0

704 lines not on this page · raw message

sound/soc/cdns/cdns-i2s-mc.h new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#6 lore raw

RE: [PATCH v3 2/2] ASoC: cdns: Add drivers of Cadence Multi-Channel I2S Controller

Quoted 25 lines

Subject: [PATCH v3 2/2] ASoC: cdns: Add drivers of Cadence Multi-Channel I2S Controller

Add the drivers of Cadence Multi-Channel I2S Controller.

The Cadence I2S Controller implements a function of the multi-channel (up to 8- channel) bus. Each stereo channel combines functions of a transmitter and a receiver. Each channel has independent and internal gating, clock and interruption control. It alos support some of these channels are used as playback and others can also be used as record in the same time.

The I2S-MC is used on the StarFive JH8100 SoC and add the compatible for this.

---
 MAINTAINERS                      |   6 +
 sound/soc/Kconfig                |   1 +
 sound/soc/Makefile               |   1 +
 sound/soc/cdns/Kconfig           |  18 +
 sound/soc/cdns/Makefile          |   3 +
 sound/soc/cdns/cdns-i2s-mc-pcm.c | 285 +++++++++++++
 sound/soc/cdns/cdns-i2s-mc.c     | 704 +++++++++++++++++++++++++++++++
 sound/soc/cdns/cdns-i2s-mc.h     | 151 +++++++
 8 files changed, 1169 insertions(+)
 create mode 100644 sound/soc/cdns/Kconfig  create mode 100644
Quoted 4 lines

sound/soc/cdns/Makefile create mode 100644 sound/soc/cdns/cdns-i2s-mc- pcm.c create mode 100644 sound/soc/cdns/cdns-i2s-mc.c create mode 100644 sound/soc/cdns/cdns-i2s-mc.h

Hi Mark,

Could you please help to review and give your comment about this I2S driver? Thank you very much!

Best regards,
Xingyu Wu

#7 lore raw

Re: [PATCH v3 2/2] ASoC: cdns: Add drivers of Cadence Multi-Channel I2S Controller

Quoted 30 lines · Xingyu Wu
Quoted 25 lines

Subject: [PATCH v3 2/2] ASoC: cdns: Add drivers of Cadence Multi-Channel I2S Controller

Add the drivers of Cadence Multi-Channel I2S Controller.

The Cadence I2S Controller implements a function of the multi-channel (up to 8- channel) bus. Each stereo channel combines functions of a transmitter and a receiver. Each channel has independent and internal gating, clock and interruption control. It alos support some of these channels are used as playback and others can also be used as record in the same time.

The I2S-MC is used on the StarFive JH8100 SoC and add the compatible for this.

---
 MAINTAINERS                      |   6 +
 sound/soc/Kconfig                |   1 +
 sound/soc/Makefile               |   1 +
 sound/soc/cdns/Kconfig           |  18 +
 sound/soc/cdns/Makefile          |   3 +
 sound/soc/cdns/cdns-i2s-mc-pcm.c | 285 +++++++++++++
 sound/soc/cdns/cdns-i2s-mc.c     | 704 +++++++++++++++++++++++++++++++
 sound/soc/cdns/cdns-i2s-mc.h     | 151 +++++++
 8 files changed, 1169 insertions(+)
 create mode 100644 sound/soc/cdns/Kconfig  create mode 100644
Quoted 4 lines

sound/soc/cdns/Makefile create mode 100644 sound/soc/cdns/cdns-i2s-mc- pcm.c create mode 100644 sound/soc/cdns/cdns-i2s-mc.c create mode 100644 sound/soc/cdns/cdns-i2s-mc.h

Quoted 5 lines

Hi Mark,

Could you please help to review and give your comment about this I2S driver? Thank you very much!

So you are not going to implement my feedback? Then Review tag does not stand.

Also, please avoid pings for non-fixes during merge window. It's pointless now.

Best regards,
Krzysztof