Skip to contentSkip to conversation

Add I2S support for the StarFive JH7110 SoC

PATCH Superseded Xingyu Wu 3 participants 14 messages Aug 2, 2023 – Aug 7, 2023

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xingyu Wu

author
#0 lore raw

cover Add I2S support for the StarFive JH7110 SoC

This patch series adds I2S support for the StarFive JH7110 RISC-V SoC based on Designware I2S controller. There has three I2S channels (RX/TX0/TX1) on the JH7110 SoC, one of which is for record(RX) and two for playback(TX).

The first patch adds the ops to get data from platform bus in the I2S driver.
The second patch adds support for the StarFive JH7110 SoC in the Designware I2S bindings.
The third patch adds support for the StarFive JH7110 SoC in the Designware I2S driver.
The fourth patch fixes the name of I2STX1 pinmux.
The last patch adds device node of I2S RX/TX0/TX1 in JH7110 dts.

This patch series is based on Linux-next which is merge clock, syscon and dma nodes for the StarFive JH7110 SoC. And these should be applied after the following patchset:
https://lore.kernel.org/all/[email protected]/

The series has been tested and works normally on the VisionFive 2 board by plugging an audio expansion board.

Xingyu Wu (5):
ASoC: dwc: Use ops to get platform data
ASoC: dt-bindings: snps,designware-i2s: Add StarFive JH7110 SoC
support
ASoC: dwc: i2s: Add StarFive JH7110 SoC support
riscv: dts: starfive: pinfunc: Fix the pins name of I2STX1
riscv: dts: starfive: Add the nodes and pins of I2Srx/I2Stx0/I2Stx1

 .../bindings/sound/snps,designware-i2s.yaml   | 101 +++++-
 arch/riscv/boot/dts/starfive/jh7110-pinfunc.h |   4 +-
 .../jh7110-starfive-visionfive-2.dtsi         |  58 ++++
 arch/riscv/boot/dts/starfive/jh7110.dtsi      |  65 ++++
 include/sound/designware_i2s.h                |   3 +
 sound/soc/dwc/dwc-i2s.c                       | 318 ++++++++++++++++--
 sound/soc/dwc/local.h                         |   1 +
 7 files changed, 523 insertions(+), 27 deletions(-)

base-commit: 0fee53365d051781156b75c6f6e6015757e71fd8
prerequisite-patch-id: 0159f09bb0a1ff711a00ae17ef5b12662c9c7d3d

Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/5 ASoC: dwc: Use ops to get platform data

Use of_device_get_match_data() to get platform data.

---
 sound/soc/dwc/dwc-i2s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/dwc/dwc-i2s.c +1 -1
index 1f1ee14b04e6..c076090a9864 100644
@@ -690,7 +690,7 @@ static int dw_i2s_dai_probe(struct snd_soc_dai *dai)
 
 static int dw_i2s_probe(struct platform_device *pdev)
 {
-	const struct i2s_platform_data *pdata = pdev->dev.platform_data;
+	const struct i2s_platform_data *pdata = of_device_get_match_data(&pdev->dev);
 	struct dw_i2s_dev *dev;
 	struct resource *res;
 	int ret, irq;
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/5 ASoC: dt-bindings: snps,designware-i2s: Add StarFive JH7110 SoC support

In reply to Xingyu Wu

Add the StarFive JH7110 (TX0/TX1/RX channel) SoC support in the bindings of Designware I2S controller. The I2S controller needs two reset items to work properly on the JH7110 SoC. And TX0 channel as master mode needs 5 clock items and TX1/RX channels as slave mode need 9 clock items on the JH7110 SoC. The RX channel needs System Register Controller property to enable it and other platforms do not need it.

---
 .../bindings/sound/snps,designware-i2s.yaml   | 101 +++++++++++++++++-
 1 file changed, 98 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +98 -3
index a970fd264b21..a5ab7f3e49b2 100644
@@ -17,6 +17,9 @@ properties:
           - const: snps,designware-i2s
       - enum:
           - snps,designware-i2s
+          - starfive,jh7110-i2stx0
+          - starfive,jh7110-i2stx1
+          - starfive,jh7110-i2srx
 
   reg:
     maxItems: 1
@@ -29,15 +32,36 @@ properties:
     maxItems: 1
 
   clocks:
-    description: Sampling rate reference clock
-    maxItems: 1
+    items:
+      - description: Sampling rate reference clock
+      - description: APB clock
+      - description: Audio master clock
+      - description: Inner audio master clock source
+      - description: External audio master clock source
+      - description: Bit clock
+      - description: Left/right channel clock
+      - description: External bit clock
+      - description: External left/right channel clock
+    minItems: 1
 
   clock-names:
-    const: i2sclk
+    items:
+      - const: i2sclk
+      - const: apb
+      - const: mclk
+      - const: mclk_inner
+      - const: mclk_ext
+      - const: bclk
+      - const: lrck
+      - const: bclk_ext
+      - const: lrck_ext
+    minItems: 1
 
   resets:
     items:
       - description: Optional controller resets
+      - description: controller reset of Sampling rate
+    minItems: 1
 
   dmas:
     items:
@@ -51,6 +75,17 @@ properties:
       - const: rx
     minItems: 1
 
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller sys_syscon node.
+          - description: I2S-rx enabled control offset of SYS_SYSCONSAIF__SYSCFG register.
+          - description: I2S-rx enabled control mask
+    description:
+      The phandle to System Register Controller syscon node and the I2S-rx(ADC)
+      enabled control offset and mask of SYS_SYSCONSAIF__SYSCFG register.
+
 allOf:
   - $ref: dai-common.yaml#
   - if:
@@ -66,6 +101,66 @@ allOf:
       properties:
         "#sound-dai-cells":
           const: 0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: snps,designware-i2s
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names:
+          maxItems: 1
+        resets:
+          maxItems: 1
+    else:
+      properties:
+        resets:
+          minItems: 2
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx0
+    then:
+      properties:
+        clocks:
+          minItems: 5
+        clock-names:
+          minItems: 5
+      required:
+        - resets
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx1
+    then:
+      properties:
+        clocks:
+          minItems: 9
+        clock-names:
+          minItems: 9
+      required:
+        - resets
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2srx
+    then:
+      properties:
+        clocks:
+          minItems: 9
+        clock-names:
+          minItems: 9
+      required:
+        - resets
+        - starfive,syscon
+    else:
+      properties:
+        starfive,syscon: false
 
 required:
   - compatible
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v1 2/5] ASoC: dt-bindings: snps,designware-i2s: Add StarFive JH7110 SoC support

Quoted 2 lines · Xingyu Wu

Add the StarFive JH7110 (TX0/TX1/RX channel) SoC support in the bindings of Designware I2S controller. The I2S controller needs two reset items''

Thank you for your patch. There is something to discuss/improve.

Quoted 28 lines

resets:
items:
- description: Optional controller resets

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +13 -0
+      - description: controller reset of Sampling rate
+    minItems: 1
 
   dmas:
     items:
@@ -51,6 +75,17 @@ properties:
       - const: rx
     minItems: 1
 
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller sys_syscon node.
+          - description: I2S-rx enabled control offset of SYS_SYSCONSAIF__SYSCFG register.
+          - description: I2S-rx enabled control mask
+    description:
+      The phandle to System Register Controller syscon node and the I2S-rx(ADC)
+      enabled control offset and mask of SYS_SYSCONSAIF__SYSCFG register.
+
 allOf:
   - $ref: dai-common.yaml#
   - if:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 103

Quoted 3 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +0 -0
@@ -66,6 +101,66 @@ allOf:
       properties:
         "#sound-dai-cells":
           const: 0

You need to constrain clocks and resets also for all other existing variants.

Quoted 16 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +16 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: snps,designware-i2s
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names:
+          maxItems: 1
+        resets:
+          maxItems: 1
+    else:
+      properties:
+        resets:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 129

Quoted 10 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +10 -0
+          minItems: 2
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx0
+    then:
+      properties:
+        clocks:
+          minItems: 5

Also maxItems

Review allOf: · line 131

Quoted 2 lines
(quoted diff) +2 -0
+        clock-names:
+          minItems: 5

Also maxItems

What about resets? 1 or 2 items?

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 144

Quoted 13 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +13 -0
+      required:
+        - resets
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx1
+    then:
+      properties:
+        clocks:
+          minItems: 9
+        clock-names:
+          minItems: 9

resets?

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 157

Quoted 13 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +13 -0
+      required:
+        - resets
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2srx
+    then:
+      properties:
+        clocks:
+          minItems: 9
+        clock-names:
+          minItems: 9

resets?

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 166

Quoted 9 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +6 -0
+      required:
+        - resets
+        - starfive,syscon
+    else:
+      properties:
+        starfive,syscon: false
 
 required:
   - compatible

Best regards,
Krzysztof

author
#4 lore raw

Re: [PATCH v1 2/5] ASoC: dt-bindings: snps,designware-i2s: Add StarFive JH7110 SoC support

Quoted 32 lines · Krzysztof Kozlowski
Quoted 2 lines · Xingyu Wu

Add the StarFive JH7110 (TX0/TX1/RX channel) SoC support in the bindings of Designware I2S controller. The I2S controller needs two reset items''

Thank you for your patch. There is something to discuss/improve.

Quoted 26 lines

resets:
items:
- description: Optional controller resets

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +13 -0
+      - description: controller reset of Sampling rate
+    minItems: 1
 
   dmas:
     items:
@@ -51,6 +75,17 @@ properties:
       - const: rx
     minItems: 1
 
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller sys_syscon node.
+          - description: I2S-rx enabled control offset of SYS_SYSCONSAIF__SYSCFG register.
+          - description: I2S-rx enabled control mask
+    description:
+      The phandle to System Register Controller syscon node and the I2S-rx(ADC)
+      enabled control offset and mask of SYS_SYSCONSAIF__SYSCFG register.
+
 allOf:
   - $ref: dai-common.yaml#
Quoted 25 lines

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 103

Quoted 5 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +0 -0
   - if:
@@ -66,6 +101,66 @@ allOf:
       properties:
         "#sound-dai-cells":
           const: 0

You need to constrain clocks and resets also for all other existing variants.

Quoted 17 lines
Quoted 1 line

+ - if:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +16 -0
+      properties:
+        compatible:
+          contains:
+            const: snps,designware-i2s
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names:
+          maxItems: 1
+        resets:
+          maxItems: 1
+    else:
+      properties:
+        resets:
+          minItems: 2

The resets of TX0/TX1/RX on JH7110 SoC are mentioned in 'else' here.

Quoted 11 lines

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 129

Quoted 9 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +9 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx0
+    then:
+      properties:
+        clocks:
+          minItems: 5

Also maxItems

Will add.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+        clock-names:
+          minItems: 5

Also maxItems

Will add.

Quoted 2 lines

What about resets? 1 or 2 items?

Mentioned it in the 'else'.
Or do you mean I should drop the 'else' and add the resets in here? And is the same for TX1 and RX?

Quoted 30 lines
Quoted 4 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +3 -0
+      required:
+        - resets
+  - if:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 144

Quoted 10 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +10 -0
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx1
+    then:
+      properties:
+        clocks:
+          minItems: 9
+        clock-names:
+          minItems: 9

resets?>

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 157

Quoted 13 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +13 -0
+      required:
+        - resets
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2srx
+    then:
+      properties:
+        clocks:
+          minItems: 9
+        clock-names:
+          minItems: 9
Quoted 12 lines

resets?

Quoted 9 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +6 -0
+      required:
+        - resets
+        - starfive,syscon
+    else:
+      properties:
+        starfive,syscon: false
 
 required:
   - compatible

Best regards,
Xingyu Wu

#5 lore raw

Re: [PATCH v1 2/5] ASoC: dt-bindings: snps,designware-i2s: Add StarFive JH7110 SoC support

Quoted 18 lines · Xingyu Wu
Quoted 17 lines
Quoted 7 lines
Quoted 1 line

+ - if:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +6 -0
+      properties:
+        compatible:
+          contains:
+            const: snps,designware-i2s
+    then:
+      properties:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 120

Quoted 10 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +10 -0
+        clocks:
+          maxItems: 1
+        clock-names:
+          maxItems: 1
+        resets:
+          maxItems: 1
+    else:
+      properties:
+        resets:
+          minItems: 2
Quoted 1 line

The resets of TX0/TX1/RX on JH7110 SoC are mentioned in 'else' here.

Ah, its fine. Clocks seem to be also constrained.

Quoted 21 lines
Quoted 11 lines

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 129

Quoted 10 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +9 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx0
+    then:
+      properties:
+        clocks:
+          minItems: 5
Quoted 1 line

Also maxItems

Will add.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+        clock-names:
+          minItems: 5

Also maxItems

Quoted 8 lines

Will add.

Quoted 2 lines

What about resets? 1 or 2 items?

Mentioned it in the 'else'.
Or do you mean I should drop the 'else' and add the resets in here? And is the same for TX1 and RX?

It won't be easy to read... probably the binding should be split. Anyway, it's fine as is, except the maxItems above.

Best regards,
Krzysztof

author
#6 lore raw

Re: [PATCH v1 2/5] ASoC: dt-bindings: snps,designware-i2s: Add StarFive JH7110 SoC support

Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Xingyu Wu
Quoted 17 lines
Quoted 17 lines
Quoted 1 line

+ - if:

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +16 -0
+      properties:
+        compatible:
+          contains:
+            const: snps,designware-i2s
+    then:
+      properties:
+        clocks:
+          maxItems: 1
+        clock-names:
+          maxItems: 1
+        resets:
+          maxItems: 1
+    else:
+      properties:
+        resets:
+          minItems: 2
Quoted 3 lines
Quoted 1 line

The resets of TX0/TX1/RX on JH7110 SoC are mentioned in 'else' here.

Ah, its fine. Clocks seem to be also constrained.

OK, I will keep it here.

Quoted 25 lines
Quoted 25 lines
Quoted 12 lines

Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml allOf: · line 129

Quoted 11 lines
Documentation/devicetree/bindings/sound/snps,designware-i2s.yaml +9 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,jh7110-i2stx0
+    then:
+      properties:
+        clocks:
+          minItems: 5
Quoted 1 line

Also maxItems

Will add.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+        clock-names:
+          minItems: 5

Also maxItems

Will add.

Quoted 1 line
Quoted 9 lines
Quoted 5 lines
Quoted 1 line

What about resets? 1 or 2 items?

Mentioned it in the 'else'.
Or do you mean I should drop the 'else' and add the resets in here? And is the same for TX1 and RX?

It won't be easy to read... probably the binding should be split. Anyway, it's fine as is, except the maxItems above.

So I will keep it and just add the maxItems in next version.

Thanks,
Xingyu Wu

author
#7 lore raw

PATCH 3/5 ASoC: dwc: i2s: Add StarFive JH7110 SoC support

In reply to Xingyu Wu

Add StarFive JH7110(TX0/TX1/RX channels) SoC support in the designware I2S driver and a flag to check if it is on the JH7110 SoC.

These channels need to enable clocks, resets and syscon register on the JH7110 SoC. So add init ops in platform data for the JH7110 SoC to do this. Their resets should be deassert before changing the parent of clocks so these are done in the init ops of platform data. The I2S controllers use DMA controller by platform data on the JH7110 and these settings about snd_dmaengine_dai_dma_data() should be added in the dw_configure_dai_by_pd(). And use dmaengine PCM registration if these do not have IRQ on the JH7110 SoC.

---
 include/sound/designware_i2s.h |   3 +
 sound/soc/dwc/dwc-i2s.c        | 316 ++++++++++++++++++++++++++++++---
 sound/soc/dwc/local.h          |   1 +
 3 files changed, 299 insertions(+), 21 deletions(-)
include/sound/designware_i2s.h +3 -0
index 80d275b9ae0d..f6803205a9fb 100644
@@ -21,6 +21,8 @@ struct i2s_clk_config_data {
 	u32 sample_rate;
 };
 
+struct dw_i2s_dev;
+
 struct i2s_platform_data {
 	#define DWC_I2S_PLAY	(1 << 0)
 	#define DWC_I2S_RECORD	(1 << 1)
@@ -42,6 +44,7 @@ struct i2s_platform_data {
 	void *capture_dma_data;
 	bool (*filter)(struct dma_chan *chan, void *slave);
 	int (*i2s_clk_cfg)(struct i2s_clk_config_data *config);
+	int (*i2s_pd_init)(struct dw_i2s_dev *dev);
 };
 
 struct i2s_dma_data {
sound/soc/dwc/dwc-i2s.c +295 -21

392 lines not on this page · raw message

sound/soc/dwc/local.h +1 -0
index 4ce96bac2f39..dce88c9ad5f3 100644
@@ -123,6 +123,7 @@ struct dw_i2s_dev {
 	u32 fifo_th;
 	u32 l_reg;
 	u32 r_reg;
+	bool is_jh7110; /* Flag for StarFive JH7110 SoC */
 
 	/* data related to DMA transfers b/w i2s and DMAC */
 	union dw_i2s_snd_dma_data play_dma_data;
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v1 3/5] ASoC: dwc: i2s: Add StarFive JH7110 SoC support

Quoted 22 lines · Xingyu Wu
sound/soc/dwc/dwc-i2s.c +2 -1
index c076090a9864..4dfbd8ddbcf5 100644
@@ -16,6 +16,7 @@
  #include <linux/init.h>
  #include <linux/io.h>
  #include <linux/interrupt.h>
+#include <linux/mfd/syscon.h>
  #include <linux/module.h>
  #include <linux/reset.h>
  #include <linux/slab.h>
@@ -198,7 +199,7 @@ static void i2s_start(struct dw_i2s_dev *dev,
  	else
  		i2s_write_reg(dev->i2s_base, IRER, 1);
 
-	if (dev->use_pio)
+	if (dev->use_pio || dev->is_jh7110)
  		i2s_enable_irqs(dev, substream->stream, config->chan_nr);
  	else
  		i2s_enable_dma(dev, substream->stream);

sound/soc/dwc/dwc-i2s.c static void i2s_stop(struct dw_i2s_dev *dev, · line 223

Quoted 8 lines
sound/soc/dwc/dwc-i2s.c +1 -1
@@ -216,7 +217,7 @@ static void i2s_stop(struct dw_i2s_dev *dev,
  	else
  		i2s_write_reg(dev->i2s_base, IRER, 0);
 
-	if (dev->use_pio)
+	if (dev->use_pio || dev->is_jh7110)
  		i2s_disable_irqs(dev, substream->stream, 8);
  	else
  		i2s_disable_dma(dev, substream->stream);

Why do we need to enable interrupts for DMA mode?

Quoted 23 lines
sound/soc/dwc/dwc-i2s.c +15 -0
@@ -227,6 +228,21 @@ static void i2s_stop(struct dw_i2s_dev *dev,
  	}
  }
 
+static int dw_i2s_startup(struct snd_pcm_substream *substream,
+			  struct snd_soc_dai *cpu_dai)
+{
+	struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
+
+	if (dev->is_jh7110) {
+		struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+		struct snd_soc_dai_link *dai_link = rtd->dai_link;
+
+		dai_link->trigger_stop = SND_SOC_TRIGGER_ORDER_LDC;
+	}
+
+	return 0;
+}
+
  static void dw_i2s_config(struct dw_i2s_dev *dev, int stream)
  {
  	u32 ch_reg;

sound/soc/dwc/dwc-i2s.c static int dw_i2s_hw_params(struct snd_pcm_substream *substream, · line 290

Quoted 8 lines
sound/soc/dwc/dwc-i2s.c +5 -0
@@ -267,6 +283,11 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
  		config->data_width = 16;
  		dev->ccr = 0x00;
  		dev->xfer_resolution = 0x02;
+		/* Set DMA buswidth on JH7110 */
+		if (dev->is_jh7110) {
+			dev->play_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+			dev->capture_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+		}

Not needed.
See: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20230802&id=6f80197f40515853814d0f22e5209d53f899ab91
Proper bus width calculations is performed by snd_hwparams_to_dma_slave_config()

sound/soc/dwc/dwc-i2s.c static int dw_i2s_hw_params(struct snd_pcm_substream *substream, · line 307

Quoted 12 lines
sound/soc/dwc/dwc-i2s.c +5 -0
  		break;
 
  	case SNDRV_PCM_FORMAT_S24_LE:
@@ -279,6 +300,11 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
  		config->data_width = 32;
  		dev->ccr = 0x10;
  		dev->xfer_resolution = 0x05;
+		/* Set DMA buswidth on JH7110 */
+		if (dev->is_jh7110) {
+			dev->play_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+			dev->capture_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+		}

Not needed.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author
#9 lore raw

Re: [PATCH v1 3/5] ASoC: dwc: i2s: Add StarFive JH7110 SoC support

Quoted 26 lines · Maxim Kochetkov
Quoted 22 lines · Xingyu Wu
sound/soc/dwc/dwc-i2s.c +1 -0
index c076090a9864..4dfbd8ddbcf5 100644
@@ -16,6 +16,7 @@
   #include <linux/init.h>
   #include <linux/io.h>
   #include <linux/interrupt.h>
+#include <linux/mfd/syscon.h>
   #include <linux/module.h>
   #include <linux/reset.h>
   #include <linux/slab.h>
@@ -198,7 +199,7 @@ static void i2s_start(struct dw_i2s_dev *dev,

      else
          i2s_write_reg(dev->i2s_base, IRER, 1);
  -    if (dev->use_pio)
+    if (dev->use_pio || dev->is_jh7110) i2s_enable_irqs(dev, substream->stream, config->chan_nr); else
          i2s_enable_dma(dev, substream->stream);

sound/soc/dwc/dwc-i2s.c +0 -0
@@ -216,7 +217,7 @@ static void i2s_stop(struct dw_i2s_dev *dev,

      else

Quoted 8 lines
Quoted 6 lines

          i2s_write_reg(dev->i2s_base, IRER, 0); -    if (dev->use_pio)
+    if (dev->use_pio || dev->is_jh7110) i2s_disable_irqs(dev, substream->stream, 8); else
          i2s_disable_dma(dev, substream->stream);

Why do we need to enable interrupts for DMA mode?

This is special mechanism about data transmission by DMA controller on the StarFive JH7110 SoC.
The DMA controller needs to make a handshake with I2S interrupt and cannot move the audio data without enabling the I2S interrupt.
So I should keep the I2S interrupt enabled in both interrupt or DMA mode.

Quoted 27 lines
Quoted 27 lines
sound/soc/dwc/dwc-i2s.c +15 -0
@@ -227,6 +228,21 @@ static void i2s_stop(struct dw_i2s_dev *dev,
       }
   }
   +static int dw_i2s_startup(struct snd_pcm_substream *substream,
+              struct snd_soc_dai *cpu_dai)
+{
+    struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
+
+    if (dev->is_jh7110) {
+        struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+        struct snd_soc_dai_link *dai_link = rtd->dai_link;
+
+        dai_link->trigger_stop = SND_SOC_TRIGGER_ORDER_LDC;
+    }
+
+    return 0;
+}
+
   static void dw_i2s_config(struct dw_i2s_dev *dev, int stream)
   {
       u32 ch_reg;
@@ -267,6 +283,11 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
           config->data_width = 16;
           dev->ccr = 0x00;
           dev->xfer_resolution = 0x02;
+        /* Set DMA buswidth on JH7110 */
Quoted 8 lines

sound/soc/dwc/dwc-i2s.c static int dw_i2s_hw_params(struct snd_pcm_substream *substream, · line 290

Quoted 4 lines
sound/soc/dwc/dwc-i2s.c +4 -0
+        if (dev->is_jh7110) {
+            dev->play_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+            dev->capture_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+        }

Not needed.
See: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20230802&id=6f80197f40515853814d0f22e5209d53f899ab91
Proper bus width calculations is performed by snd_hwparams_to_dma_slave_config()

Will use this ops instead.

Quoted 14 lines

sound/soc/dwc/dwc-i2s.c static int dw_i2s_hw_params(struct snd_pcm_substream *substream, · line 307

Quoted 12 lines
sound/soc/dwc/dwc-i2s.c +0 -0
           break;

        case SNDRV_PCM_FORMAT_S24_LE:

sound/soc/dwc/dwc-i2s.c +5 -0
@@ -279,6 +300,11 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
           config->data_width = 32;
           dev->ccr = 0x10;
           dev->xfer_resolution = 0x05;
+        /* Set DMA buswidth on JH7110 */
+        if (dev->is_jh7110) {
+            dev->play_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+            dev->capture_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+        }

Not needed

Will drop.

Quoted 1 line

Thanks,
Xingyu Wu

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author
#10 lore raw

PATCH 4/5 riscv: dts: starfive: pinfunc: Fix the pins name of I2STX1

In reply to Xingyu Wu

These pins are actually I2STX1 clock input, not I2STX0, so their names should be changed.

---
 arch/riscv/boot/dts/starfive/jh7110-pinfunc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/boot/dts/starfive/jh7110-pinfunc.h +2 -2
index fb0139b56723..256de17f5261 100644
@@ -240,8 +240,8 @@
 #define GPI_SYS_MCLK_EXT			30
 #define GPI_SYS_I2SRX_BCLK			31
 #define GPI_SYS_I2SRX_LRCK			32
-#define GPI_SYS_I2STX0_BCLK			33
-#define GPI_SYS_I2STX0_LRCK			34
+#define GPI_SYS_I2STX1_BCLK			33
+#define GPI_SYS_I2STX1_LRCK			34
 #define GPI_SYS_TDM_CLK				35
 #define GPI_SYS_TDM_RXD				36
 #define GPI_SYS_TDM_SYNC			37
Signature · 1 line
2.25.1
author
#11 lore raw

PATCH 5/5 riscv: dts: starfive: Add the nodes and pins of I2Srx/I2Stx0/I2Stx1

In reply to Xingyu Wu

Add I2Srx/I2Stx0/I2Stx1 nodes and pins configuration for the StarFive JH7110 SoC.

---
 .../jh7110-starfive-visionfive-2.dtsi         | 58 +++++++++++++++++
 arch/riscv/boot/dts/starfive/jh7110.dtsi      | 65 +++++++++++++++++++
 2 files changed, 123 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +58 -0
index f874d31006a6..8f90d1b6fd66 100644
@@ -185,6 +185,24 @@ &i2c6 {
 	status = "okay";
 };
 
+&i2srx {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2srx_pins>;
+	status = "okay";
+};
+
+&i2stx0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mclk_ext_pins>;
+	status = "okay";
+};
+
+&i2stx1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2stx1_pins>;
+	status = "okay";
+};
+
 &spi0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&spi0_pins>;
@@ -254,6 +272,46 @@ GPOEN_SYS_I2C6_DATA,
 		};
 	};
 
+	i2srx_pins: i2srx-0 {
+		clk-sd-pins {
+			pinmux = <GPIOMUX(38, GPOUT_LOW,
+					      GPOEN_DISABLE,
+					      GPI_SYS_I2SRX_BCLK)>,
+				 <GPIOMUX(63, GPOUT_LOW,
+					      GPOEN_DISABLE,
+					      GPI_SYS_I2SRX_LRCK)>,
+				 <GPIOMUX(38, GPOUT_LOW,
+					      GPOEN_DISABLE,
+					      GPI_SYS_I2STX1_BCLK)>,
+				 <GPIOMUX(63, GPOUT_LOW,
+					      GPOEN_DISABLE,
+					      GPI_SYS_I2STX1_LRCK)>,
+				 <GPIOMUX(61, GPOUT_LOW,
+					      GPOEN_DISABLE,
+					      GPI_SYS_I2SRX_SDIN0)>;
+			input-enable;
+		};
+	};
+
+	i2stx1_pins: i2stx1-0 {
+		sd-pins {
+			pinmux = <GPIOMUX(44, GPOUT_SYS_I2STX1_SDO0,
+					      GPOEN_ENABLE,
+					      GPI_NONE)>;
+			bias-disable;
+			input-disable;
+		};
+	};
+
+	mclk_ext_pins: mclk-ext-0 {
+		mclk-ext-pins {
+			pinmux = <GPIOMUX(4, GPOUT_LOW,
+					     GPOEN_DISABLE,
+					     GPI_SYS_MCLK_EXT)>;
+			input-enable;
+		};
+	};
+
 	spi0_pins: spi0-0 {
 		mosi-pins {
 			pinmux = <GPIOMUX(52, GPOUT_SYS_SPI0_TXD,
arch/riscv/boot/dts/starfive/jh7110.dtsi +65 -0

77 lines not on this page · raw message

Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH v1 5/5] riscv: dts: starfive: Add the nodes and pins of I2Srx/I2Stx0/I2Stx1

Quoted 5 lines · Xingyu Wu

Add I2Srx/I2Stx0/I2Stx1 nodes and pins configuration for the StarFive JH7110 SoC.

---

...

arch/riscv/boot/dts/starfive/jh7110.dtsi tdm: tdm@10090000 { · line 515

Quoted 13 lines
arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +1 -0
+
 	spi0_pins: spi0-0 {
 		mosi-pins {
 			pinmux = <GPIOMUX(52, GPOUT_SYS_SPI0_TXD,
arch/riscv/boot/dts/starfive/jh7110.dtsi +1 -0
index 05f843b8ca03..507312eb6053 100644
@@ -512,6 +512,30 @@ tdm: tdm@10090000 {
 			status = "disabled";
 		};
 
+		i2srx: i2srx@100e0000 {

Node names should be generic, so:
i2s@

Quoted 27 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +23 -0
+			compatible = "starfive,jh7110-i2srx";
+			reg = <0x0 0x100e0000 0x0 0x1000>;
+			clocks = <&syscrg JH7110_SYSCLK_I2SRX_BCLK_MST>,
+				 <&syscrg JH7110_SYSCLK_I2SRX_APB>,
+				 <&syscrg JH7110_SYSCLK_MCLK>,
+				 <&syscrg JH7110_SYSCLK_MCLK_INNER>,
+				 <&mclk_ext>,
+				 <&syscrg JH7110_SYSCLK_I2SRX_BCLK>,
+				 <&syscrg JH7110_SYSCLK_I2SRX_LRCK>,
+				 <&i2srx_bclk_ext>,
+				 <&i2srx_lrck_ext>;
+			clock-names = "i2sclk", "apb", "mclk",
+				      "mclk_inner", "mclk_ext", "bclk",
+				      "lrck", "bclk_ext", "lrck_ext";
+			resets = <&syscrg JH7110_SYSRST_I2SRX_APB>,
+				 <&syscrg JH7110_SYSRST_I2SRX_BCLK>;
+			dmas = <0>, <&dma 24>;
+			dma-names = "tx", "rx";
+			starfive,syscon = <&sys_syscon 0x18 0x2>;
+			#sound-dai-cells = <0>;
+			status = "disabled";
+		};
+
 		usb0: usb@10100000 {
 			compatible = "starfive,jh7110-usb";
 			ranges = <0x0 0x0 0x10100000 0x100000>;

arch/riscv/boot/dts/starfive/jh7110.dtsi spi6: spi@120a0000 { · line 763

Quoted 4 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +1 -0
@@ -736,6 +760,47 @@ spi6: spi@120a0000 {
 			status = "disabled";
 		};
 
+		i2stx0: i2stx0@120b0000 {

i2s@

Quoted 8 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +8 -0
+			compatible = "starfive,jh7110-i2stx0";
+			reg = <0x0 0x120b0000 0x0 0x1000>;
+			clocks = <&syscrg JH7110_SYSCLK_I2STX0_BCLK_MST>,
+				 <&syscrg JH7110_SYSCLK_I2STX0_APB>,
+				 <&syscrg JH7110_SYSCLK_MCLK>,
+				 <&syscrg JH7110_SYSCLK_MCLK_INNER>,
+				 <&mclk_ext>;
+			clock-names = "i2sclk", "apb", "mclk",

arch/riscv/boot/dts/starfive/jh7110.dtsi spi6: spi@120a0000 { · line 781

Quoted 10 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +10 -0
+				      "mclk_inner","mclk_ext";
+			resets = <&syscrg JH7110_SYSRST_I2STX0_APB>,
+				 <&syscrg JH7110_SYSRST_I2STX0_BCLK>;
+			dmas = <&dma 47>;
+			dma-names = "tx";
+			#sound-dai-cells = <0>;
+			status = "disabled";
+		};
+
+		i2stx1: i2stx1@120c0000 {

i2s@

Best regards,
Krzysztof

author
#13 lore raw

Re: [PATCH v1 5/5] riscv: dts: starfive: Add the nodes and pins of I2Srx/I2Stx0/I2Stx1

Quoted 21 lines · Krzysztof Kozlowski
Quoted 5 lines · Xingyu Wu

Add I2Srx/I2Stx0/I2Stx1 nodes and pins configuration for the StarFive JH7110 SoC.

---

...

Quoted 12 lines
arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +1 -0
+
 	spi0_pins: spi0-0 {
 		mosi-pins {
 			pinmux = <GPIOMUX(52, GPOUT_SYS_SPI0_TXD,
arch/riscv/boot/dts/starfive/jh7110.dtsi +0 -0
index 05f843b8ca03..507312eb6053 100644
@@ -512,6 +512,30 @@ tdm: tdm@10090000 {
 			status = "disabled";
 		};
 
Quoted 4 lines

arch/riscv/boot/dts/starfive/jh7110.dtsi tdm: tdm@10090000 { · line 515

Quoted 1 line
arch/riscv/boot/dts/starfive/jh7110.dtsi +1 -0
+		i2srx: i2srx@100e0000 {

Node names should be generic, so:
i2s@

Will fix. Thanks.

Quoted 31 lines
Quoted 31 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +23 -0
+			compatible = "starfive,jh7110-i2srx";
+			reg = <0x0 0x100e0000 0x0 0x1000>;
+			clocks = <&syscrg JH7110_SYSCLK_I2SRX_BCLK_MST>,
+				 <&syscrg JH7110_SYSCLK_I2SRX_APB>,
+				 <&syscrg JH7110_SYSCLK_MCLK>,
+				 <&syscrg JH7110_SYSCLK_MCLK_INNER>,
+				 <&mclk_ext>,
+				 <&syscrg JH7110_SYSCLK_I2SRX_BCLK>,
+				 <&syscrg JH7110_SYSCLK_I2SRX_LRCK>,
+				 <&i2srx_bclk_ext>,
+				 <&i2srx_lrck_ext>;
+			clock-names = "i2sclk", "apb", "mclk",
+				      "mclk_inner", "mclk_ext", "bclk",
+				      "lrck", "bclk_ext", "lrck_ext";
+			resets = <&syscrg JH7110_SYSRST_I2SRX_APB>,
+				 <&syscrg JH7110_SYSRST_I2SRX_BCLK>;
+			dmas = <0>, <&dma 24>;
+			dma-names = "tx", "rx";
+			starfive,syscon = <&sys_syscon 0x18 0x2>;
+			#sound-dai-cells = <0>;
+			status = "disabled";
+		};
+
 		usb0: usb@10100000 {
 			compatible = "starfive,jh7110-usb";
 			ranges = <0x0 0x0 0x10100000 0x100000>;
@@ -736,6 +760,47 @@ spi6: spi@120a0000 {
 			status = "disabled";
 		};
 
Quoted 3 lines

arch/riscv/boot/dts/starfive/jh7110.dtsi spi6: spi@120a0000 { · line 763

Quoted 1 line
arch/riscv/boot/dts/starfive/jh7110.dtsi +1 -0
+		i2stx0: i2stx0@120b0000 {

i2s@

Will fix.

Quoted 13 lines
Quoted 13 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +12 -0
+			compatible = "starfive,jh7110-i2stx0";
+			reg = <0x0 0x120b0000 0x0 0x1000>;
+			clocks = <&syscrg JH7110_SYSCLK_I2STX0_BCLK_MST>,
+				 <&syscrg JH7110_SYSCLK_I2STX0_APB>,
+				 <&syscrg JH7110_SYSCLK_MCLK>,
+				 <&syscrg JH7110_SYSCLK_MCLK_INNER>,
+				 <&mclk_ext>;
+			clock-names = "i2sclk", "apb", "mclk",
+				      "mclk_inner","mclk_ext";
+			resets = <&syscrg JH7110_SYSRST_I2STX0_APB>,
+				 <&syscrg JH7110_SYSRST_I2STX0_BCLK>;
+			dmas = <&dma 47>;
Quoted 8 lines

arch/riscv/boot/dts/starfive/jh7110.dtsi spi6: spi@120a0000 { · line 781

Quoted 6 lines
arch/riscv/boot/dts/starfive/jh7110.dtsi +6 -0
+			dma-names = "tx";
+			#sound-dai-cells = <0>;
+			status = "disabled";
+		};
+
+		i2stx1: i2stx1@120c0000 {

i2s@

Will fix.

Best regards,
Xingyu Wu