Skip to contentSkip to conversation

Add PDM controller for StarFive JH8100 SoC

PATCH Superseded Xingyu Wu 3 participants 11 messages Mar 7, 2024 – Mar 8, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xingyu Wu

author
#0 lore raw

cover Add PDM controller for StarFive JH8100 SoC

The Pulse Density Modulation (PDM) controller is a digital PDM microphone interface controller and decoder that supports both mono/stereo PDM format, and a Inter-IC Sound (I2S) transmitter that outputs standard stereo audio data to another device. The PDM controller includes two PDM modules, each PDM module can drive one bitstream sampling clock and two bitstream coming data with sampling clock rising and falling edge.

On the JH8100 SoC, PDM and I2S are fixedly connected as follow:

    PDM module 0 --> I2S channel 0
    PDM module 1 --> I2S channel 1

The first patch adds documentation to describe PDM controller bindings. And the second patch adds PDM driver for the StarFive JH8100 SoC. The DTS patch of PDM controller will be submitted after the patchs of JH8100 DTS are accepted.

Xingyu Wu (2):
dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC
ASoC: starfive: Add PDM controller support

 .../bindings/sound/starfive,jh8100-pdm.yaml   |  84 ++++
 MAINTAINERS                                   |   7 +
 sound/soc/starfive/Kconfig                    |   7 +
 sound/soc/starfive/Makefile                   |   1 +
 sound/soc/starfive/jh8100_pdm.c               | 395 ++++++++++++++++++
 5 files changed, 494 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml
 create mode 100644 sound/soc/starfive/jh8100_pdm.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/2 dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC

Add bindings for the PDM controller for the StarFive JH8100 SoC.

---
 .../bindings/sound/starfive,jh8100-pdm.yaml   | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +84 -0
new file mode 100644
index 000000000000..a91b47d39ad3
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/starfive,jh8100-pdm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH8100 PDM controller
+
+description: |
+  The Pulse Density Modulation (PDM) controller is a digital PDM out
+  microphone interface controller and decoder that supports both
+  mono/stereo PDM format, and an Inter-IC Sound (I2S) transmitter that
+  outputs standard stereo audio data to another device. The I2S transmitter
+  can be configured to operate either a master or a slave (default mode).
+  The PDM controller includes two PDM modules, each PDM module can drive
+  one bitstream sampling clock and two bitstream coming data with sampling
+  clock rising and falling edge.
+
+maintainers:
+  - Xingyu Wu <[email protected]>
+  - Walker Chen <[email protected]>
+
+properties:
+  compatible:
+    const: starfive,jh8100-pdm
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: DMIC output clock
+      - description: Main ICG clock
+
+  clock-names:
+    items:
+      - const: dmic
+      - const: icg
+
+  resets:
+    maxItems: 1
+
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller sys_syscon_ne node.
+          - description: PDM source enabled control offset of SYS_SYSCON_NE register.
+          - description: PDM source enabled control mask
+    description:
+      The phandle to System Register Controller syscon node and the PDM source
+      from I2S enabled control offset and mask of SYS_SYSCON_NE register.
+
+  starfive,pdm-modulex:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      The module x will be using in PDM controller. Default use module 0.
+
+  "#sound-dai-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - starfive,syscon
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    pdm@12250000 {
+      compatible = "starfive,jh8100-pdm";
+      reg = <0x12250000 0x1000>;
+      clocks = <&syscrg_ne 142>,
+               <&syscrg_ne 171>;
+      clock-names = "dmic", "icg";
+      resets = <&syscrg_ne 44>;
+      starfive,syscon = <&sys_syscon_ne 0xC 0xFF>;
+      #sound-dai-cells = <0>;
+    };
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v1 1/2] dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC

Quoted 1 line · Xingyu Wu

Add bindings for the PDM controller for the StarFive JH8100 SoC.

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.

Quoted 61 lines
---
 .../bindings/sound/starfive,jh8100-pdm.yaml   | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +48 -0
new file mode 100644
index 000000000000..a91b47d39ad3
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/starfive,jh8100-pdm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH8100 PDM controller
+
+description: |
+  The Pulse Density Modulation (PDM) controller is a digital PDM out
+  microphone interface controller and decoder that supports both
+  mono/stereo PDM format, and an Inter-IC Sound (I2S) transmitter that
+  outputs standard stereo audio data to another device. The I2S transmitter
+  can be configured to operate either a master or a slave (default mode).
+  The PDM controller includes two PDM modules, each PDM module can drive
+  one bitstream sampling clock and two bitstream coming data with sampling
+  clock rising and falling edge.
+
+maintainers:
+  - Xingyu Wu <[email protected]>
+  - Walker Chen <[email protected]>
+
+properties:
+  compatible:
+    const: starfive,jh8100-pdm
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: DMIC output clock
+      - description: Main ICG clock
+
+  clock-names:
+    items:
+      - const: dmic
+      - const: icg
+
+  resets:
+    maxItems: 1
+
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller sys_syscon_ne node.
+          - description: PDM source enabled control offset of SYS_SYSCON_NE register.

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 58

Quoted 10 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +10 -0
+          - description: PDM source enabled control mask
+    description:
+      The phandle to System Register Controller syscon node and the PDM source
+      from I2S enabled control offset and mask of SYS_SYSCON_NE register.
+
+  starfive,pdm-modulex:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      The module x will be using in PDM controller. Default use module 0.

This is an index of the block instance? If so, then it's not allowed. Otherwise I don't understand the description.

Anyway, don't repeat constraints in free form text. default: 0, if this is going to stay.

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 71

Quoted 13 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +13 -0
+
+  "#sound-dai-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - starfive,syscon
+
+unevaluatedProperties: false

This is wrong without $ref, which points you to missing $ref to dai-common.

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 82

Quoted 11 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +11 -0
+
+examples:
+  - |
+    pdm@12250000 {
+      compatible = "starfive,jh8100-pdm";
+      reg = <0x12250000 0x1000>;
+      clocks = <&syscrg_ne 142>,
+               <&syscrg_ne 171>;
+      clock-names = "dmic", "icg";
+      resets = <&syscrg_ne 44>;
+      starfive,syscon = <&sys_syscon_ne 0xC 0xFF>;

Lowercase hex only.

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 84

Quoted 2 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +2 -0
+      #sound-dai-cells = <0>;
+    };

Best regards,
Krzysztof

author
#3 lore raw

回复: [PATCH v1 1/2] dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC

Quoted 7 lines · Xingyu Wu
Quoted 1 line

Add bindings for the PDM controller for the StarFive JH8100 SoC.

Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.

Okay, will fix.

Quoted 81 lines
Quoted 56 lines
---
 .../bindings/sound/starfive,jh8100-pdm.yaml   | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml

diff --git a/Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml b/Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file mode 100644
index 000000000000..a91b47d39ad3

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +40 -0
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/starfive,jh8100-pdm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH8100 PDM controller
+
+description: |
+  The Pulse Density Modulation (PDM) controller is a digital PDM out
+  microphone interface controller and decoder that supports both
+  mono/stereo PDM format, and an Inter-IC Sound (I2S) transmitter
+that
+  outputs standard stereo audio data to another device. The I2S
+transmitter
+  can be configured to operate either a master or a slave (default mode).
+  The PDM controller includes two PDM modules, each PDM module can
+drive
+  one bitstream sampling clock and two bitstream coming data with
+sampling
+  clock rising and falling edge.
+
+maintainers:
+  - Xingyu Wu <[email protected]>
+  - Walker Chen <[email protected]>
+
+properties:
+  compatible:
+    const: starfive,jh8100-pdm
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: DMIC output clock
+      - description: Main ICG clock
+
+  clock-names:
+    items:
+      - const: dmic

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +10 -0
+      - const: icg
+
+  resets:
+    maxItems: 1
+
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller

sys_syscon_ne node.

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 51

Quoted 1 line
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +1 -0
+          - description: PDM source enabled control offset of

SYS_SYSCON_NE register.

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml

Quoted 3 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +3 -0
+          - description: PDM source enabled control mask
+    description:
+      The phandle to System Register Controller syscon node and the PDM

source

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 58

Quoted 7 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +7 -0
+      from I2S enabled control offset and mask of SYS_SYSCON_NE register.
+
+  starfive,pdm-modulex:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      The module x will be using in PDM controller. Default use module 0.
Quoted 3 lines

This is an index of the block instance? If so, then it's not allowed. Otherwise I don't understand the description.

No, this is just one instance. The PDM have two internal and independent modules or called channels. They can be configured and used separately, and the user can choose which channel to use.

Quoted 3 lines

Anyway, don't repeat constraints in free form text. default: 0, if this is going to stay.

Oh, I just want to describe that if no this property, the driver default use module 0. I will make this clear in next version.

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +7 -0
+
+  "#sound-dai-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
Quoted 8 lines

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 71

Quoted 6 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +6 -0
+  - clocks
+  - clock-names
+  - resets
+  - starfive,syscon
+
+unevaluatedProperties: false

This is wrong without $ref, which points you to missing $ref to dai-common.

Will add it. Thanks.

Quoted 14 lines

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 82

Quoted 12 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +11 -0
+
+examples:
+  - |
+    pdm@12250000 {
+      compatible = "starfive,jh8100-pdm";
+      reg = <0x12250000 0x1000>;
+      clocks = <&syscrg_ne 142>,
+               <&syscrg_ne 171>;
+      clock-names = "dmic", "icg";
+      resets = <&syscrg_ne 44>;
+      starfive,syscon = <&sys_syscon_ne 0xC 0xFF>;

Lowercase hex only.

Will fix.

Quoted 6 lines

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 84

Quoted 3 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +2 -0
+      #sound-dai-cells = <0>;
+    };

Best regards,
Krzysztof

Thanks,
Xingyu Wu

#4 lore raw

Re: 回复: [PATCH v1 1/2] dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC

Quoted 7 lines · Xingyu Wu
Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +6 -0
+
+  starfive,pdm-modulex:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      The module x will be using in PDM controller. Default use module 0.
Quoted 7 lines
Quoted 3 lines

This is an index of the block instance? If so, then it's not allowed. Otherwise I don't understand the description.

No, this is just one instance. The PDM have two internal and independent modules or called channels. They can be configured and used separately, and the user can choose which channel to use.

Do the modulex differ? Why different boards would choose one over another?

Best regards,
Krzysztof

author
#5 lore raw

回复: 回复: [PATCH v1 1/2] dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC

Quoted 12 lines · Xingyu Wu
Quoted 11 lines
Quoted 10 lines

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 58

Quoted 6 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +6 -0
+
+  starfive,pdm-modulex:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      The module x will be using in PDM controller. Default use module 0.

This is an index of the block instance? If so, then it's not allowed. Otherwise I don't understand the description.

Quoted 8 lines
Quoted 1 line

No, this is just one instance. The PDM have two internal and independent

modules or called channels.

Quoted 1 line

They can be configured and used separately, and the user can choose which

channel to use.

Quoted 1 line

Do the modulex differ? Why different boards would choose one over another?

They are same. The choice between them is base on the match with I2S.
The DMA data channel of hardware between them is fixed linked:
PDM module 0 --> I2S channel 0,
PDM module 1 --> I2S channel 1
I2S uses higher-number channels first for capture (like channel 1), so PDM should skips module 0 and uses module 1.
Oh, I just thought of a way to fix them that change the priority of I2S channel to use lower-number channels first and PDM need not skip module0.

Best regards,
Xingyu Wu

#6 lore raw

Re: 回复: 回复: [PATCH v1 1/2] dt-bindings: ASoC: Add PDM controller for the StarFive JH8100 SoC

Quoted 21 lines · Xingyu Wu
Quoted 12 lines · Xingyu Wu
Quoted 11 lines
Quoted 10 lines

Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml line 58

Quoted 6 lines
Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml new file +6 -0
+
+  starfive,pdm-modulex:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      The module x will be using in PDM controller. Default use module 0.

This is an index of the block instance? If so, then it's not allowed. Otherwise I don't understand the description.

Quoted 8 lines
Quoted 1 line

No, this is just one instance. The PDM have two internal and independent

modules or called channels.

Quoted 1 line

They can be configured and used separately, and the user can choose which

channel to use.

Quoted 1 line

Do the modulex differ? Why different boards would choose one over another?

Quoted 7 lines

They are same. The choice between them is base on the match with I2S.
The DMA data channel of hardware between them is fixed linked:
PDM module 0 --> I2S channel 0,
PDM module 1 --> I2S channel 1
I2S uses higher-number channels first for capture (like channel 1), so PDM should skips module 0 and uses module 1.
Oh, I just thought of a way to fix them that change the priority of I2S channel to use lower-number channels first and PDM need not skip module0.

Hm, then maybe this should be somehow linked with choice of I2C channel? Do you have anywhere a link to complete DTS with sound card?

Best regards,
Krzysztof

author
#7 lore raw

PATCH 2/2 ASoC: starfive: Add PDM controller support

In reply to Xingyu Wu

Add the driver of PDM controller for the StarFive JH8100 SoC.

The Pulse Density Modulation (PDM) controller is a digital PDM microphone interface controller and decoder that supports both mono/stereo PDM format, and a Inter-IC Sound (I2S) transmitter that outputs standard stereo audio data to another device.

On the JH8100 SoC, PDM and I2S are fixedly connected as follow:
PDM module 0 --> I2S channel 0
PDM module 1 --> I2S channel 1

---
 MAINTAINERS                     |   7 +
 sound/soc/starfive/Kconfig      |   7 +
 sound/soc/starfive/Makefile     |   1 +
 sound/soc/starfive/jh8100_pdm.c | 395 ++++++++++++++++++++++++++++++++
 4 files changed, 410 insertions(+)
 create mode 100644 sound/soc/starfive/jh8100_pdm.c
MAINTAINERS +7 -0
index 2ecaaec6a6bf..7923f70d1192 100644
@@ -20941,6 +20941,13 @@ F:	Documentation/devicetree/bindings/power/starfive*
 F:	drivers/pmdomain/starfive/
 F:	include/dt-bindings/power/starfive,jh7110-pmu.h
 
+STARFIVE JH8100 PDM DRIVER
+M:	Xingyu Wu <[email protected]>
+M:	Walker Chen <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/sound/starfive,jh8100-pdm.yaml
+F:	sound/soc/starfive/jh8100_pdm.c
+
 STARFIVE SOC DRIVERS
 M:	Conor Dooley <[email protected]>
 S:	Maintained
sound/soc/starfive/Kconfig +7 -0
index 279ac5c1d309..9beb734d2028 100644
@@ -22,3 +22,10 @@ config SND_SOC_JH7110_TDM
 	select SND_SOC_GENERIC_DMAENGINE_PCM
 	help
 	  Say Y or M if you want to add support for StarFive TDM driver.
+
+config SND_SOC_JH8100_PDM
+	tristate "JH8100 PDM controller device driver"
+	select SND_CADENCE_I2S_MC
+	select REGMAP_MMIO
+	help
+	  Say Y or M if you want to add support for StarFive PDM driver.
sound/soc/starfive/Makefile +1 -0
index 9e958f70ef51..b672425830d9 100644
@@ -1,3 +1,4 @@
 # StarFive Platform Support
 obj-$(CONFIG_SND_SOC_JH7110_PWMDAC) += jh7110_pwmdac.o
 obj-$(CONFIG_SND_SOC_JH7110_TDM) += jh7110_tdm.o
+obj-$(CONFIG_SND_SOC_JH8100_PDM) += jh8100_pdm.o
sound/soc/starfive/jh8100_pdm.c new file +395 -0

395 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#8 lore raw

Re: [PATCH v1 2/2] ASoC: starfive: Add PDM controller support

sound/soc/starfive/jh8100_pdm.c line 72

Quoted 10 lines · Xingyu Wu
sound/soc/starfive/jh8100_pdm.c new file +10 -0
+static const struct snd_kcontrol_new jh8100_pdm_snd_controls[] = {
+	SOC_SINGLE("DC compensation Control", JH8100_PDM_DMIC_CTRL0, 30, 1, 0),
+	SOC_SINGLE("High Pass Filter Control", JH8100_PDM_DMIC_CTRL0, 28, 1, 0),
+	SOC_SINGLE("Left Channel Volume Control", JH8100_PDM_DMIC_CTRL0, 23, 1, 0),
+	SOC_SINGLE("Right Channel Volume Control", JH8100_PDM_DMIC_CTRL0, 22, 1, 0),
+	SOC_SINGLE_TLV("Volume", JH8100_PDM_DMIC_CTRL0, 16, 0x3F, 1, volume_tlv),
+	SOC_SINGLE("Data MSB Shift", JH8100_PDM_DMIC_CTRL0, 1, 7, 0),
+	SOC_SINGLE("SCALE", JH8100_PDM_DC_SCALE0, 0, 0x3F, 0),
+	SOC_SINGLE("DC offset", JH8100_PDM_DC_SCALE0, 8, 0xFFFFF, 0),
+};

Simple on/off switches should have names ending in Switch, volumes should end in Volume as per control-names.rst. Please for the next version you post show the output of running mixer-test on a system with this device, it will identify these and other issues.

sound/soc/starfive/jh8100_pdm.c line 214

Quoted 7 lines
sound/soc/starfive/jh8100_pdm.c new file +7 -0
+static int jh8100_pdm_component_probe(struct snd_soc_component *component)
+{
+	struct jh8100_pdm_priv *priv = snd_soc_component_get_drvdata(component);
+
+	snd_soc_component_init_regmap(component, priv->regmap);
+	snd_soc_add_component_controls(component, jh8100_pdm_snd_controls,
+				       ARRAY_SIZE(jh8100_pdm_snd_controls));

You can just specify the controls in the snd_soc_compoenent_driver.

Quoted 6 lines
sound/soc/starfive/jh8100_pdm.c new file +6 -0
+#ifdef CONFIG_PM
+static int jh8100_pdm_runtime_suspend(struct device *dev)
+{
+	struct jh8100_pdm_priv *priv = dev_get_drvdata(dev);
+
+	clk_disable_unprepare(priv->icg_clk);

sound/soc/starfive/jh8100_pdm.c line 255

Quoted 10 lines
sound/soc/starfive/jh8100_pdm.c new file +10 -0
+	return 0;
+}
+
+static int jh8100_pdm_runtime_resume(struct device *dev)
+{
+	struct jh8100_pdm_priv *priv = dev_get_drvdata(dev);
+
+	return jh8100_pdm_crg_enable(priv);
+}
+#endif

It's weird that the runtime suspend and resume are not symmetric - why do we need to bring the device out of reset but not put it into reset?

sound/soc/starfive/jh8100_pdm.c line 325

Quoted 3 lines
sound/soc/starfive/jh8100_pdm.c new file +3 -0
+	if (!device_property_read_u8(&pdev->dev, "starfive,pdm-modulex", &using_modulex))
+		if (using_modulex == 1)
+			base += JH8100_PDM_MODULEX_SHIFT; /* Use module 1 */

This really looks like you've got one hardware block with two devices in it, either the address ranges registered for the devices in DT should be separate and you shouldn't need this property or you should have one component registering both PDM interfaces.

author
#9 lore raw

回复: [PATCH v1 2/2] ASoC: starfive: Add PDM controller support

Quoted 14 lines · Xingyu Wu

Review

Quoted 3 lines
(quoted diff) +2 -0
+static const struct snd_kcontrol_new jh8100_pdm_snd_controls[] = {
+	SOC_SINGLE("DC compensation Control", JH8100_PDM_DMIC_CTRL0, 30,

1, 0),

Review

Quoted 1 line
(quoted diff) +1 -0
+	SOC_SINGLE("High Pass Filter Control", JH8100_PDM_DMIC_CTRL0, 28, 1,

0),

Review

Quoted 1 line
(quoted diff) +1 -0
+	SOC_SINGLE("Left Channel Volume Control", JH8100_PDM_DMIC_CTRL0,

23, 1, 0),

Review

Quoted 1 line
(quoted diff) +1 -0
+	SOC_SINGLE("Right Channel Volume Control", JH8100_PDM_DMIC_CTRL0,

22, 1, 0),

Review

Quoted 1 line
(quoted diff) +1 -0
+	SOC_SINGLE_TLV("Volume", JH8100_PDM_DMIC_CTRL0, 16, 0x3F, 1,

volume_tlv),

Quoted 8 lines

sound/soc/starfive/jh8100_pdm.c

Quoted 3 lines
sound/soc/starfive/jh8100_pdm.c new file +3 -0
+	SOC_SINGLE("Data MSB Shift", JH8100_PDM_DMIC_CTRL0, 1, 7, 0),
+	SOC_SINGLE("SCALE", JH8100_PDM_DC_SCALE0, 0, 0x3F, 0),
+	SOC_SINGLE("DC offset", JH8100_PDM_DC_SCALE0, 8, 0xFFFFF, 0), };

Simple on/off switches should have names ending in Switch, volumes should end in Volume as per control-names.rst. Please for the next version you post show the output of running mixer-test on a system with this device, it will identify these and other issues.

Will fix. Thanks.

Quoted 11 lines

sound/soc/starfive/jh8100_pdm.c line 214

Quoted 9 lines
sound/soc/starfive/jh8100_pdm.c new file +8 -0
+static int jh8100_pdm_component_probe(struct snd_soc_component
+*component) {
+	struct jh8100_pdm_priv *priv =
+snd_soc_component_get_drvdata(component);
+
+	snd_soc_component_init_regmap(component, priv->regmap);
+	snd_soc_add_component_controls(component, jh8100_pdm_snd_controls,
+				       ARRAY_SIZE(jh8100_pdm_snd_controls));

You can just specify the controls in the snd_soc_compoenent_driver.

It seem to be more convenient. Noted.

Quoted 10 lines
Quoted 10 lines
sound/soc/starfive/jh8100_pdm.c new file +9 -0
+#ifdef CONFIG_PM
+static int jh8100_pdm_runtime_suspend(struct device *dev) {
+	struct jh8100_pdm_priv *priv = dev_get_drvdata(dev);
+
+	clk_disable_unprepare(priv->icg_clk);
+	return 0;
+}
+
+static int jh8100_pdm_runtime_resume(struct device *dev) {
Quoted 8 lines

sound/soc/starfive/jh8100_pdm.c line 255

Quoted 5 lines
sound/soc/starfive/jh8100_pdm.c new file +5 -0
+	struct jh8100_pdm_priv *priv = dev_get_drvdata(dev);
+
+	return jh8100_pdm_crg_enable(priv);
+}
+#endif

It's weird that the runtime suspend and resume are not symmetric - why do we need to bring the device out of reset but not put it into reset?

I will add the reset when suspend.

Quoted 10 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+	if (!device_property_read_u8(&pdev->dev, "starfive,pdm-modulex",

&using_modulex))

sound/soc/starfive/jh8100_pdm.c line 325

Quoted 2 lines
sound/soc/starfive/jh8100_pdm.c new file +2 -0
+		if (using_modulex == 1)
+			base += JH8100_PDM_MODULEX_SHIFT; /* Use module 1 */

This really looks like you've got one hardware block with two devices in it, either the address ranges registered for the devices in DT should be separate and you shouldn't need this property or you should have one component registering both PDM interfaces.

Yeah, They like two independent device and have different register to configure, but just use the same clocks and resets.
Due to the sample rate depend on the share clocks, they should be registered together as a 4-channel capture device (rarely used), or just one of them can be registered separately as a 2-channel device. BTW, can I use the 0x12250000 about the property of reg for device 0 or 0x12250010 for device 1 to choose which device to be used in DT?

Best regards,
Xingyu Wu

maintainer
#10 lore raw

Re: 回复: [PATCH v1 2/2] ASoC: starfive: Add PDM controller support

Quoted 12 lines · Xingyu Wu
Quoted 11 lines · Xingyu Wu

Review

Quoted 2 lines
(quoted diff) +1 -0
+	if (!device_property_read_u8(&pdev->dev, "starfive,pdm-modulex",

&using_modulex))

sound/soc/starfive/jh8100_pdm.c line 325

Quoted 2 lines
sound/soc/starfive/jh8100_pdm.c new file +2 -0
+		if (using_modulex == 1)
+			base += JH8100_PDM_MODULEX_SHIFT; /* Use module 1 */

This really looks like you've got one hardware block with two devices in it, either the address ranges registered for the devices in DT should be separate and you shouldn't need this property or you should have one component registering both PDM interfaces.

Quoted 7 lines

Yeah, They like two independent device and have different register to configure, but just use the same clocks and resets. Due to the sample rate depend on the share clocks, they should be registered together as a 4-channel capture device (rarely used), or just one of them can be registered separately as a 2-channel device. BTW, can I use the 0x12250000 about the property of reg for device 0 or 0x12250010 for device 1 to choose which device to be used in DT?

Ah, so it's actually a small MFD but given that it's two audio blocks possibly not worth registering as such. I'd register two stereo DAIs to one component and then use the DAI ID to figure out which registers to write to. Four channel mode might need a property to put everything as one DAI and not register the second one, or it might just be OK to let the first DAI be 4 channel with runtime error checking.

Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.