Skip to content

Commit c4160ef

Browse files
committed
Add audio driver for Starfive JH7100 SOC
Signed-off-by: Michael Yan <michael.yan@starfivetech.com> Signed-off-by: Jenny Zhang <jenny.zhang@starfivetech.com> Signed-off-by: Walker Chen <walker.chen@starfivetech.com>
1 parent ee7beb5 commit c4160ef

18 files changed

+4419
-0
lines changed

arch/riscv/boot/dts/starfive/jh7100-common.dtsi

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,20 @@
413413
slew-rate = <0>;
414414
};
415415
};
416+
417+
pwmdac_pins: pwmdac_0 {
418+
pwmdac_pins {
419+
pinmux = <GPIOMUX(23, GPO_PWMDAC_LEFT_OUT,
420+
GPO_ENABLE, GPI_NONE)>,
421+
<GPIOMUX(24, GPO_PWMDAC_RIGHT_OUT,
422+
GPO_ENABLE, GPI_NONE)>;
423+
bias-disable;
424+
drive-strength = <35>;
425+
input-disable;
426+
input-schmitt-disable;
427+
slew-rate = <0>;
428+
};
429+
};
416430
};
417431

418432
&i2c0 {
@@ -568,3 +582,9 @@
568582
dr_mode = "host";
569583
status = "okay";
570584
};
585+
586+
&pwmdac {
587+
pinctrl-names = "default";
588+
pinctrl-0 = <&pwmdac_pins>;
589+
status = "okay";
590+
};

arch/riscv/boot/dts/starfive/jh7100.dtsi

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@
229229
snps,block-size = <4096 4096 4096 4096>;
230230
snps,priority = <0 1 2 3>;
231231
snps,axi-max-burst-len = <128>;
232+
status = "okay";
233+
dma-coherent;
232234
};
233235

234236
crypto: crypto@100d0000 {
@@ -277,6 +279,14 @@
277279
#clock-cells = <1>;
278280
};
279281

282+
audioclk: clock-controller@10480000 {
283+
compatible = "starfive,jh7100-audclk";
284+
reg = <0x0 0x10480000 0x0 0x10000>;
285+
clocks = <&osc_sys>, <&osc_aud>;
286+
clock-names = "osc_sys", "osc_aud";
287+
#clock-cells = <1>;
288+
};
289+
280290
otp: otp@11810000 {
281291
compatible = "starfive,fu740-otp";
282292
reg = <0x0 0x11810000 0x0 0x10000>;
@@ -652,5 +662,137 @@
652662
dsp@0 {
653663
};
654664
};
665+
666+
i2sadc0: i2sadc0@10400000 {
667+
compatible = "snps,designware-i2sadc0";
668+
reg = <0x0 0x10400000 0x0 0x1000>;
669+
interrupt-parent = <&plic>;
670+
clocks = <&clkgen JH7100_CLK_APB1_BUS>;
671+
clock-names = "i2sclk";
672+
#sound-dai-cells = <0>;
673+
dmas = <&dma2p 28>;
674+
dma-names = "rx";
675+
};
676+
677+
i2svad: i2svad@10420000 {
678+
compatible = "starfive,sf-i2svad";
679+
reg = <0x0 0x10420000 0x0 0x1000> ;
680+
interrupt-parent = <&plic>;
681+
interrupts = <60>, <61>;
682+
interrupt-names = "spintr", "slintr";
683+
clocks = <&audioclk JH7100_CLK_APB_I2SVAD>;
684+
clock-names = "i2svad_apb";
685+
resets = <&audrst JH7100_AUDRSTN_APB_I2SVAD>,
686+
<&audrst JH7100_AUDRSTN_I2SVAD_SRST>;
687+
reset-names = "apb_i2svad", "i2svad_srst";
688+
#sound-dai-cells = <0>;
689+
};
690+
691+
i2sdac0: i2sdac0@10450000 {
692+
compatible = "snps,designware-i2sdac0";
693+
reg = <0x0 0x10450000 0x0 0x1000>;
694+
interrupt-parent = <&plic>;
695+
clocks = <&audioclk JH7100_CLK_DAC_MCLK>,
696+
<&audioclk JH7100_CLK_I2S0_BCLK>,
697+
<&audioclk JH7100_CLK_I2S0_LRCLK>,
698+
<&audioclk JH7100_CLK_APB_I2S0>;
699+
clock-names = "dac_mclk", "i2sdac0_bclk", "i2sdac0_lrclk", "i2sdac_apb";
700+
resets = <&audrst JH7100_AUDRSTN_APB_I2SDAC>,
701+
<&audrst JH7100_AUDRSTN_I2SDAC_SRST>;
702+
reset-names = "apb_i2sdac", "i2sdac_srst";
703+
#sound-dai-cells = <0>;
704+
dmas = <&dma2p 30>;
705+
dma-names = "tx";
706+
};
707+
708+
i2sdac1: i2sdac1@10460000 {
709+
compatible = "snps,designware-i2sdac1";
710+
reg = <0x0 0x10460000 0x0 0x1000>;
711+
interrupt-parent = <&plic>;
712+
clocks = <&audioclk JH7100_CLK_DAC_MCLK>,
713+
<&audioclk JH7100_CLK_I2S1_BCLK>,
714+
<&audioclk JH7100_CLK_I2S1_LRCLK>,
715+
<&audioclk JH7100_CLK_APB_I2S1>;
716+
clock-names = "dac_mclk", "i2sdac1_bclk", "i2sdac1_lrclk", "i2s1_apb";
717+
resets = <&audrst JH7100_AUDRSTN_APB_I2S1>,
718+
<&audrst JH7100_AUDRSTN_I2S1_SRST>;
719+
#sound-dai-cells = <0>;
720+
dmas = <&dma2p 31>;
721+
dma-names = "tx";
722+
};
723+
724+
i2sdac16k: i2sdac16k@10470000 {
725+
compatible = "snps,designware-i2sdac16k";
726+
reg = <0x0 0x10470000 0x0 0x1000>;
727+
interrupt-parent = <&plic>;
728+
clocks = <&clkgen JH7100_CLK_APB1_BUS>;
729+
clock-names = "i2sclk";
730+
#sound-dai-cells = <0>;
731+
dmas = <&dma2p 29>;
732+
dma-names = "tx";
733+
};
734+
735+
spdif_transmitter: spdif_transmitter {
736+
compatible = "linux,spdif-dit";
737+
#sound-dai-cells = <0>;
738+
};
739+
740+
spdif_receiver: spdif_receiver {
741+
compatible = "linux,spdif-dir";
742+
#sound-dai-cells = <0>;
743+
};
744+
745+
pwmdac: pwmdac@10440000 {
746+
compatible = "starfive,pwmdac";
747+
reg = <0x0 0x10440000 0x0 0x1000>;
748+
clocks = <&clkgen JH7100_CLK_AUDIO_ROOT>,
749+
<&clkgen JH7100_CLK_AUDIO_SRC>,
750+
<&clkgen JH7100_CLK_AUDIO_12288>,
751+
<&audioclk JH7100_CLK_DMA1P_AHB>,
752+
<&audioclk JH7100_CLK_APB_PWMDAC>,
753+
<&audioclk JH7100_CLK_DAC_MCLK>;
754+
clock-names = "audio_root", "audio_src", "audio_12288", "dma1p_ahb", "pwmdac_apb", "dac_mclk";
755+
resets = <&audrst JH7100_AUDRSTN_APB_BUS>,
756+
<&audrst JH7100_AUDRSTN_DMA1P_AHB>,
757+
<&audrst JH7100_AUDRSTN_APB_PWMDAC>;
758+
reset-names = "apb_bus", "dma1p_ahb", "apb_pwmdac";
759+
dmas = <&dma2p 23>;
760+
dma-names = "tx";
761+
#sound-dai-cells = <0>;
762+
};
763+
764+
pwmdac_codec: pwmdac-transmitter {
765+
compatible = "linux,pwmdac-dit";
766+
#sound-dai-cells = <0>;
767+
};
768+
769+
dmic_codec: dmic_codec {
770+
compatible = "dmic-codec";
771+
#sound-dai-cells = <0>;
772+
};
773+
774+
sound:snd-card{
775+
compatible = "simple-audio-card";
776+
simple-audio-card,name = "Starfive-Multi-Sound-Card";
777+
#address-cells = <1>;
778+
#size-cells = <0>;
779+
780+
/* pwmdac */
781+
simple-audio-card,dai-link@0 {
782+
reg = <0>;
783+
status = "okay";
784+
format = "left_j";
785+
bitclock-master = <&sndcpu0>;
786+
frame-master = <&sndcpu0>;
787+
788+
sndcpu0: cpu {
789+
sound-dai = <&pwmdac>;
790+
};
791+
792+
codec {
793+
sound-dai = <&pwmdac_codec>;
794+
};
795+
};
796+
};
655797
};
656798
};

sound/soc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ source "sound/soc/sh/Kconfig"
8383
source "sound/soc/sof/Kconfig"
8484
source "sound/soc/spear/Kconfig"
8585
source "sound/soc/sprd/Kconfig"
86+
source "sound/soc/starfive/Kconfig"
8687
source "sound/soc/sti/Kconfig"
8788
source "sound/soc/stm/Kconfig"
8889
source "sound/soc/sunxi/Kconfig"

sound/soc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ obj-$(CONFIG_SND_SOC) += pxa/
4949
obj-$(CONFIG_SND_SOC) += qcom/
5050
obj-$(CONFIG_SND_SOC) += rockchip/
5151
obj-$(CONFIG_SND_SOC) += samsung/
52+
obj-$(CONFIG_SND_SOC) += starfive/
5253
obj-$(CONFIG_SND_SOC) += sh/
5354
obj-$(CONFIG_SND_SOC) += sof/
5455
obj-$(CONFIG_SND_SOC) += spear/

sound/soc/starfive/Kconfig

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Copyright (C) 2021 StarFive Technology Co., Ltd.
3+
4+
config SND_STARFIVE_SPDIF
5+
tristate "starfive spdif"
6+
select SND_SOC_GENERIC_DMAENGINE_PCM
7+
select REGMAP_MMIO
8+
help
9+
Say Y or M if you want to add support for codecs attached to the
10+
I2S interface on VIC vic_starlight board. You will also need to select
11+
the drivers for the rest of VIC audio subsystem.
12+
13+
config SND_STARFIVE_SPDIF_PCM
14+
bool "PCM PIO extension for spdif driver"
15+
depends on SND_STARFIVE_SPDIF
16+
help
17+
Say Y or N if you want to add a custom ALSA extension that registers
18+
a PCM and uses PIO to transfer data.
19+
20+
config SND_STARFIVE_PWMDAC
21+
tristate "starfive pwmdac Device Driver"
22+
select SND_SOC_GENERIC_DMAENGINE_PCM
23+
help
24+
Say Y or M if you want to add support for sf pwmdac driver.
25+
26+
config SND_STARFIVE_PWMDAC_PCM
27+
bool "PCM PIO extension for pwmdac driver"
28+
depends on SND_STARFIVE_PWMDAC
29+
help
30+
Say Y or N if you want to add a custom ALSA extension that registers
31+
a PCM and uses PIO to transfer data.
32+
33+
config SND_STARFIVE_PDM
34+
tristate "starfive pdm Device Driver"
35+
select REGMAP_MMIO
36+
help
37+
Say Y or M if you want to add support for sf pdm driver.
38+
39+
config SND_STARFIVE_I2SVAD
40+
tristate "starfive I2SVAD Device Driver"
41+
select SND_SOC_GENERIC_DMAENGINE_PCM
42+
help
43+
Say Y or M if you want to add support for I2SVAD driver for
44+
starfive I2SVAD device.
45+
46+
config SND_STARFIVE_I2SVAD_PCM
47+
bool "PCM PIO extension for I2SVAD driver"
48+
depends on SND_STARFIVE_I2SVAD
49+
help
50+
Say Y or N if you want to add a custom ALSA extension that registers
51+
a PCM and uses PIO to transfer data.
52+
53+
This functionality is specially suited for I2SVAD devices that don't have
54+
DMA support.
55+

sound/soc/starfive/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
#
3+
# Copyright (C) 2021 StarFive Technology Co., Ltd.
4+
#
5+
obj-$(CONFIG_SND_STARFIVE_SPDIF) += spdif.o
6+
7+
spdif-y := starfive_spdif.o
8+
spdif-$(CONFIG_SND_STARFIVE_SPDIF_PCM) += starfive_spdif_pcm.o
9+
10+
obj-$(CONFIG_SND_STARFIVE_PWMDAC) += pwmdac.o
11+
12+
pwmdac-y := starfive_pwmdac.o starfive_pwmdac_transmitter.o
13+
pwmdac-$(CONFIG_SND_STARFIVE_PWMDAC_PCM) += starfive_pwmdac_pcm.o
14+
15+
obj-$(CONFIG_SND_STARFIVE_PDM) += starfive_pdm.o
16+
17+
obj-$(CONFIG_SND_STARFIVE_I2SVAD) += i2svad.o
18+
i2svad-y := starfive_i2svad.o
19+
i2svad-$(CONFIG_SND_STARFIVE_I2SVAD_PCM) += starfive_i2svad_pcm.o

0 commit comments

Comments
 (0)