Skip to content

Commit

Permalink
audio: th1520: enable soundcard feature
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
David Li committed Jun 25, 2024
1 parent ff9e431 commit d858ff2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
41 changes: 39 additions & 2 deletions arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -701,7 +738,7 @@
};
};

&light_i2s {
&ap_i2s {
status = "okay";
};

Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/boot/dts/thead/th1520.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
1 change: 1 addition & 0 deletions arch/riscv/configs/th1520_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions sound/soc/xuantie/th1520-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/version.h>
#include <sound/dmaengine_pcm.h>
#include <sound/pcm_params.h>

Expand Down Expand Up @@ -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)

Check failure on line 242 in sound/soc/xuantie/th1520-i2s.c

View workflow job for this annotation

GitHub Actions / checkpatch

WARNING: LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged

Check failure on line 242 in sound/soc/xuantie/th1520-i2s.c

View workflow job for this annotation

GitHub Actions / checkpatch

WARNING: Comparisons should place the constant on the right side of the test
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)

Check failure on line 252 in sound/soc/xuantie/th1520-i2s.c

View workflow job for this annotation

GitHub Actions / checkpatch

WARNING: LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged

Check failure on line 252 in sound/soc/xuantie/th1520-i2s.c

View workflow job for this annotation

GitHub Actions / checkpatch

WARNING: Comparisons should place the constant on the right side of the test
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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/xuantie/th1520-i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d858ff2

Please sign in to comment.