From d858ff20f2b0b1c2cf27cc8966c03fde3813b809 Mon Sep 17 00:00:00 2001 From: David Li Date: Tue, 25 Jun 2024 17:49:13 +0800 Subject: [PATCH] audio: th1520: enable soundcard feature enable TH1520-Sound-Card feature simple-audio-card,dai-link@0 { /* I2S - HDMI*/ reg = <0>; format = "i2s"; cpu { sound-dai = <&ap_i2s 1>; }; codec { sound-dai = <&hdmi_codec>; }; }; simple-audio-card,dai-link@1 { /* I2S - AUDIO SYS CODEC 7210*/ reg = <1>; format = "i2s"; cpu { sound-dai = <&i2s1 0>; }; codec { sound-dai = <&es7210_audio_codec>; }; }; simple-audio-card,dai-link@2 { /* I2S - AUDIO SYS CODEC 8156*/ reg = <2>; format = "i2s"; cpu { sound-dai = <&i2s1 0>; }; codec { sound-dai = <&es8156_audio_codec>; }; }; Signed-off-by: David Li --- .../boot/dts/thead/th1520-lichee-pi-4a.dts | 41 ++++++++++++++++++- arch/riscv/boot/dts/thead/th1520.dtsi | 2 +- arch/riscv/configs/th1520_defconfig | 1 + sound/soc/xuantie/th1520-i2s.c | 13 +++++- sound/soc/xuantie/th1520-i2s.h | 2 +- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts index c1f680b3eee79..54eedfa230c56 100644 --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts @@ -32,7 +32,7 @@ i2c4 = &i2c4; i2c5 = &audio_i2c0; i2c6 = &audio_i2c1; - light_i2s = &light_i2s; + ap_i2s = &ap_i2s; i2s0 = &i2s0; i2s1 = &i2s1; i2s2 = &i2s2; @@ -201,6 +201,43 @@ sound-name-prefix = "DUMMY"; }; + th1520_sound: soundcard@1 { + compatible = "simple-audio-card"; + simple-audio-card,name = "TH1520-Sound-Card"; + #address-cells = <1>; + #size-cells = <0>; + + simple-audio-card,dai-link@0 { + reg = <0>; + format = "i2s"; + cpu { + sound-dai = <&ap_i2s 1>; + }; + codec { + sound-dai = <&hdmi_codec>; + }; + }; + simple-audio-card,dai-link@1 { + reg = <1>; + format = "i2s"; + cpu { + sound-dai = <&i2s1 0>; + }; + codec { + sound-dai = <&es7210_audio_codec>; + }; + }; + simple-audio-card,dai-link@2 { + reg = <2>; + format = "i2s"; + cpu { + sound-dai = <&i2s1 0>; + }; + codec { + sound-dai = <&es8156_audio_codec>; + }; + }; + }; thermal-zones { cpu-thermal { @@ -701,7 +738,7 @@ }; }; -&light_i2s { +&ap_i2s { status = "okay"; }; diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi index 36ae15a2191e0..c90f8211c6c5b 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -403,7 +403,7 @@ status = "disabled"; }; - light_i2s: light-i2s@ffe7034000 { + ap_i2s: ap-i2s@ffe7034000 { #sound-dai-cells = <1>; compatible = "xuantie,th1520-i2s"; reg = <0xff 0xe7034000 0x0 0x4000>; diff --git a/arch/riscv/configs/th1520_defconfig b/arch/riscv/configs/th1520_defconfig index 0aacb8b23d41e..9fe35b6819892 100644 --- a/arch/riscv/configs/th1520_defconfig +++ b/arch/riscv/configs/th1520_defconfig @@ -265,6 +265,7 @@ CONFIG_TH1520_PMIC_WATCHDOG=y # TH1520 audio CONFIG_SOUND=y CONFIG_SND=y +CONFIG_SND_SIMPLE_CARD=y CONFIG_SND_USB_AUDIO=m CONFIG_SND_SOC=y CONFIG_SND_SOC_XUANTIE=y diff --git a/sound/soc/xuantie/th1520-i2s.c b/sound/soc/xuantie/th1520-i2s.c index 645a585d5314c..6057bdf3d8d02 100644 --- a/sound/soc/xuantie/th1520-i2s.c +++ b/sound/soc/xuantie/th1520-i2s.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -238,12 +239,22 @@ static int th1520_i2s_set_fmt_dai(struct snd_soc_dai *cpu_dai, unsigned int fmt) pm_runtime_resume_and_get(i2s_private->dev); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) case SND_SOC_DAIFMT_CBS_CFS: +#else + // directly indicate whether the cpu-dai is clock provider + case SND_SOC_DAIFMT_CBP_CFP: +#endif cnfin |= CNFIN_I2S_RXMODE_MASTER_MODE; cnfout |= IISCNFOUT_TSAFS_I2S; cnfout &= ~IISCNFOUT_I2S_TXMODE_SLAVE; break; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) case SND_SOC_DAIFMT_CBM_CFM: +#else + // directly indicate whether the cpu-dai is clock consumer + case SND_SOC_DAIFMT_CBC_CFC: +#endif cnfin &= ~CNFIN_I2S_RXMODE_MASTER_MODE; cnfout |= IISCNFOUT_TSAFS_RIGHT_JUSTIFIED; cnfout |= IISCNFOUT_I2S_TXMODE_SLAVE; @@ -271,8 +282,6 @@ static int th1520_i2s_set_fmt_dai(struct snd_soc_dai *cpu_dai, unsigned int fmt) regmap_update_bits(i2s_private->regmap, I2S_IISCNF_OUT, IISCNFOUT_TSAFS_MSK, cnfout); - cnfin |= CNFIN_I2S_RXMODE_MASTER_MODE; - regmap_update_bits(i2s_private->regmap, I2S_IISCNF_IN, CNFIN_I2S_RXMODE_Msk, cnfin); diff --git a/sound/soc/xuantie/th1520-i2s.h b/sound/soc/xuantie/th1520-i2s.h index ae261b8e0dd8b..e628943499a1b 100644 --- a/sound/soc/xuantie/th1520-i2s.h +++ b/sound/soc/xuantie/th1520-i2s.h @@ -469,7 +469,7 @@ #define STEREO_CHANNEL 2 //for 2ch mode -#define AP_I2S "light-i2s" +#define AP_I2S "ap-i2s" #define AUDIO_I2S0 "audio-i2s0" #define AUDIO_I2S1 "audio-i2s1" #define AUDIO_I2S2 "audio-i2s2"