Skip to contentSkip to conversation

Add PWM-DAC audio support for StarFive JH7110 RISC-V SoC

PATCH Applied Hal Feng 3 participants 6 messages Aug 14, 2023 – Sep 13, 2023

Subsystems (6)
lore
Share & tools
lore

Hal Feng

author maintainer
#0 lore raw

v3 cover Add PWM-DAC audio support for StarFive JH7110 RISC-V SoC

This patchset adds PWM-DAC audio support for the StarFive JH7110 SoC. The PWM-DAC module does not require a hardware codec, but a dummy codec is needed for the driver. The dummy spdif codec driver, which is already upstream, is compatible with the one which JH7110 PWM-DAC needed. So we use it as the dummy codec driver for the JH7110 PWM-DAC module.

The third patch depends on tag next-20230809 in linux-next branch.

Changes since v2:
- Rebase on tag v6.5-rc6.
- Drop the component controls.
- Use dev_err_probe() instead of dev_err() in some cases.
- Add a new struct jh7110_pwmdac_cfg to save the configuration.
- Add a new function jh7110_pwmdac_init_params() to initialize the parameters.

Changes since v1:
- Rebase on tag v6.5-rc3.
- Drop patch 1 and 2.
- Drop the unneeded space and line in patch 3.
- Use the dummy spdif codec driver instead of adding a new one.
- Change "dai_link->stop_dma_first = 1" to "dai_link->trigger_stop = SND_SOC_TRIGGER_ORDER_LDC" in patch 4.
- Drop the unneeded "status = "okay;" in patch 5.
- Change some node names in patch 5.

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

Hal Feng (3):
ASoC: dt-bindings: Add StarFive JH7110 PWM-DAC controller
ASoC: starfive: Add JH7110 PWM-DAC driver
riscv: dts: starfive: Add JH7110 PWM-DAC support

 .../sound/starfive,jh7110-pwmdac.yaml         |  76 +++
 MAINTAINERS                                   |   7 +
 .../jh7110-starfive-visionfive-2.dtsi         | 141 +++++
 arch/riscv/boot/dts/starfive/jh7110.dtsi      | 159 ++++++
 sound/soc/starfive/Kconfig                    |   9 +
 sound/soc/starfive/Makefile                   |   1 +
 sound/soc/starfive/jh7110_pwmdac.c            | 529 ++++++++++++++++++
 7 files changed, 922 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/starfive,jh7110-pwmdac.yaml
 create mode 100644 sound/soc/starfive/jh7110_pwmdac.c

base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421

Signature · 7 lines
2.38.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author maintainer
#1 lore raw

PATCH v3 1/3 ASoC: dt-bindings: Add StarFive JH7110 PWM-DAC controller

Add bindings for the PWM-DAC controller on the JH7110 RISC-V SoC by StarFive Ltd.

---
 .../sound/starfive,jh7110-pwmdac.yaml         | 76 +++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/starfive,jh7110-pwmdac.yaml
Documentation/devicetree/bindings/sound/starfive,jh7110-pwmdac.yaml new file +76 -0
new file mode 100644
index 000000000000..e2b4db6aa2fb
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/starfive,jh7110-pwmdac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: StarFive JH7110 PWM-DAC Controller
+
+description:
+  The PWM-DAC Controller uses PWM square wave generators plus RC filters to
+  form a DAC for audio play in StarFive JH7110 SoC. This audio play controller
+  supports 16 bit audio format, up to 48K sampling frequency, up to left and
+  right dual channels.
+
+maintainers:
+  - Hal Feng <[email protected]>
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+    const: starfive,jh7110-pwmdac
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: PWMDAC APB
+      - description: PWMDAC CORE
+
+  clock-names:
+    items:
+      - const: apb
+      - const: core
+
+  resets:
+    maxItems: 1
+    description: PWMDAC APB
+
+  dmas:
+    maxItems: 1
+    description: TX DMA Channel
+
+  dma-names:
+    const: tx
+
+  "#sound-dai-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - dmas
+  - dma-names
+  - "#sound-dai-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    pwmdac@100b0000 {
+        compatible = "starfive,jh7110-pwmdac";
+        reg = <0x100b0000 0x1000>;
+        clocks = <&syscrg 157>,
+                 <&syscrg 158>;
+        clock-names = "apb", "core";
+        resets = <&syscrg 96>;
+        dmas = <&dma 22>;
+        dma-names = "tx";
+        #sound-dai-cells = <0>;
+    };
Signature · 7 lines
2.38.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author maintainer
#2 lore raw

PATCH v3 2/3 ASoC: starfive: Add JH7110 PWM-DAC driver

In reply to Hal Feng

Add PWM-DAC driver support for the StarFive JH7110 SoC.

---
 MAINTAINERS                        |   7 +
 sound/soc/starfive/Kconfig         |   9 +
 sound/soc/starfive/Makefile        |   1 +
 sound/soc/starfive/jh7110_pwmdac.c | 529 +++++++++++++++++++++++++++++
 4 files changed, 546 insertions(+)
 create mode 100644 sound/soc/starfive/jh7110_pwmdac.c
MAINTAINERS +7 -0
index 0903d87b17cb..686e71822383 100644
@@ -20281,6 +20281,13 @@ S:	Supported
 F:	Documentation/devicetree/bindings/mmc/starfive*
 F:	drivers/mmc/host/dw_mmc-starfive.c
 
+STARFIVE JH7110 PWMDAC DRIVER
+M:	Hal Feng <[email protected]>
+M:	Xingyu Wu <[email protected]>
+S:	Supported
+F:	Documentation/devicetree/bindings/sound/starfive,jh7110-pwmdac.yaml
+F:	sound/soc/starfive/jh7110_pwmdac.c
+
 STARFIVE JH7110 TDM DRIVER
 M:	Walker Chen <[email protected]>
 S:	Maintained
sound/soc/starfive/Kconfig +9 -0
index fafb681f8c0a..279ac5c1d309 100644
@@ -7,6 +7,15 @@ config SND_SOC_STARFIVE
 	  the Starfive SoCs' Audio interfaces. You will also need to
 	  select the audio interfaces to support below.
 
+config SND_SOC_JH7110_PWMDAC
+	tristate "JH7110 PWM-DAC device driver"
+	depends on HAVE_CLK && SND_SOC_STARFIVE
+	select SND_SOC_GENERIC_DMAENGINE_PCM
+	select SND_SOC_SPDIF
+	help
+	 Say Y or M if you want to add support for StarFive JH7110
+	 PWM-DAC driver.
+
 config SND_SOC_JH7110_TDM
 	tristate "JH7110 TDM device driver"
 	depends on HAVE_CLK && SND_SOC_STARFIVE
sound/soc/starfive/Makefile +1 -0
index f7d960211d72..9e958f70ef51 100644
@@ -1,2 +1,3 @@
 # StarFive Platform Support
+obj-$(CONFIG_SND_SOC_JH7110_PWMDAC) += jh7110_pwmdac.o
 obj-$(CONFIG_SND_SOC_JH7110_TDM) += jh7110_tdm.o
sound/soc/starfive/jh7110_pwmdac.c new file +529 -0

529 lines not on this page · raw message

Signature · 7 lines
2.38.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author maintainer
#3 lore raw

PATCH v3 3/3 riscv: dts: starfive: Add JH7110 PWM-DAC support

In reply to Hal Feng

Add PWM-DAC support for StarFive JH7110 SoC.

---
 .../jh7110-starfive-visionfive-2.dtsi         | 49 +++++++++++++++++++
 arch/riscv/boot/dts/starfive/jh7110.dtsi      | 13 +++++
 2 files changed, 62 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +49 -0
index d2f3b9eb859b..0e98fcba3203 100644
@@ -38,6 +38,33 @@ gpio-restart {
 		gpios = <&sysgpio 35 GPIO_ACTIVE_HIGH>;
 		priority = <224>;
 	};
+
+	pwmdac_codec: pwmdac-codec {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	sound-pwmdac {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "StarFive-PWMDAC-Sound-Card";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		simple-audio-card,dai-link@0 {
+			reg = <0>;
+			format = "left_j";
+			bitclock-master = <&sndcpu0>;
+			frame-master = <&sndcpu0>;
+
+			sndcpu0: cpu {
+				sound-dai = <&pwmdac>;
+			};
+
+			codec {
+				sound-dai = <&pwmdac_codec>;
+			};
+		};
+	};
 };
 
 &dvp_clk {
@@ -185,6 +212,12 @@ &i2c6 {
 	status = "okay";
 };
 
+&pwmdac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pwmdac_pins>;
+	status = "okay";
+};
+
 &qspi {
 	#address-cells = <1>;
 	#size-cells = <0>;
@@ -290,6 +323,22 @@ GPOEN_SYS_I2C6_DATA,
 		};
 	};
 
+	pwmdac_pins: pwmdac-0 {
+		pwmdac-pins {
+			pinmux = <GPIOMUX(33, GPOUT_SYS_PWMDAC_LEFT,
+					      GPOEN_ENABLE,
+					      GPI_NONE)>,
+				 <GPIOMUX(34, GPOUT_SYS_PWMDAC_RIGHT,
+					      GPOEN_ENABLE,
+					      GPI_NONE)>;
+			bias-disable;
+			drive-strength = <2>;
+			input-disable;
+			input-schmitt-disable;
+			slew-rate = <0>;
+		};
+	};
+
 	spi0_pins: spi0-0 {
 		mosi-pins {
 			pinmux = <GPIOMUX(52, GPOUT_SYS_SPI0_TXD,
arch/riscv/boot/dts/starfive/jh7110.dtsi +13 -0
index a608433200e8..d3437a2cce3f 100644
@@ -512,6 +512,19 @@ tdm: tdm@10090000 {
 			status = "disabled";
 		};
 
+		pwmdac: pwmdac@100b0000 {
+			compatible = "starfive,jh7110-pwmdac";
+			reg = <0x0 0x100b0000 0x0 0x1000>;
+			clocks = <&syscrg JH7110_SYSCLK_PWMDAC_APB>,
+				 <&syscrg JH7110_SYSCLK_PWMDAC_CORE>;
+			clock-names = "apb", "core";
+			resets = <&syscrg JH7110_SYSRST_PWMDAC_APB>;
+			dmas = <&dma 22>;
+			dma-names = "tx";
+			#sound-dai-cells = <0>;
+			status = "disabled";
+		};
+
 		usb0: usb@10100000 {
 			compatible = "starfive,jh7110-usb";
 			ranges = <0x0 0x0 0x10100000 0x100000>;
Signature · 7 lines
2.38.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer
#4 lore raw

Re: (subset) [PATCH v3 0/3] Add PWM-DAC audio support for StarFive JH7110 RISC-V SoC

In reply to Hal Feng
Quoted 9 lines · Hal Feng

This patchset adds PWM-DAC audio support for the StarFive JH7110 SoC. The PWM-DAC module does not require a hardware codec, but a dummy codec is needed for the driver. The dummy spdif codec driver, which is already upstream, is compatible with the one which JH7110 PWM-DAC needed. So we use it as the dummy codec driver for the JH7110 PWM-DAC module.

The third patch depends on tag next-20230809 in linux-next branch.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: dt-bindings: Add StarFive JH7110 PWM-DAC controller

      commit: 748c482d032ef8a607cbf696c6d31afd25293bcb
[2/3] ASoC: starfive: Add JH7110 PWM-DAC driver
      commit: d1802d59ab533f5d5fdfa3483c11ca77c5b21fdd

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

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

maintainer Applied
#5 lore raw

Re: (subset) [PATCH v3 0/3] Add PWM-DAC audio support for StarFive JH7110 RISC-V SoC

In reply to Hal Feng

From: Conor Dooley <[email protected]>

Quoted 9 lines · Hal Feng

This patchset adds PWM-DAC audio support for the StarFive JH7110 SoC. The PWM-DAC module does not require a hardware codec, but a dummy codec is needed for the driver. The dummy spdif codec driver, which is already upstream, is compatible with the one which JH7110 PWM-DAC needed. So we use it as the dummy codec driver for the JH7110 PWM-DAC module.

The third patch depends on tag next-20230809 in linux-next branch.

[...]

Applied to riscv-dt-for-next, thanks!

[3/3] riscv: dts: starfive: Add JH7110 PWM-DAC support

      https://git.kernel.org/conor/c/be326bee0937

Thanks,
Conor.