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 28, 2024
1 parent 1470952 commit b5055ca
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
42 changes: 40 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,44 @@
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 @@ -736,7 +774,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 @@ -409,7 +409,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 @@ -268,6 +268,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
8 changes: 4 additions & 4 deletions sound/soc/xuantie/th1520-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,14 @@ 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) {
case SND_SOC_DAIFMT_CBS_CFS:
// directly indicate whether the cpu-dai is clock provider
case SND_SOC_DAIFMT_CBP_CFP:
cnfin |= CNFIN_I2S_RXMODE_MASTER_MODE;
cnfout |= IISCNFOUT_TSAFS_I2S;
cnfout &= ~IISCNFOUT_I2S_TXMODE_SLAVE;
break;
case SND_SOC_DAIFMT_CBM_CFM:
// directly indicate whether the cpu-dai is clock consumer
case SND_SOC_DAIFMT_CBC_CFC:
cnfin &= ~CNFIN_I2S_RXMODE_MASTER_MODE;
cnfout |= IISCNFOUT_TSAFS_RIGHT_JUSTIFIED;
cnfout |= IISCNFOUT_I2S_TXMODE_SLAVE;
Expand Down Expand Up @@ -271,8 +273,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 b5055ca

Please sign in to comment.