AM623: am6234 custom board mcasp0 can not play audio wav with codec rt5628

Part Number: AM623
Other Parts Discussed in Thread: SK-AM62B-P1

Tool/software:

Hi Expert,

Our custom board mcasp0 can not play audio wav with codec rt5628

Here are the setting we have now

 

[Device tree]

        codec_audio: sound {

                compatible = "simple-audio-card";

                simple-audio-card,name = "am62xx-G04";

                simple-audio-card,widgets =

                        "Headphone", "Headphone Jack",

                        "Line", "Line Out",

                        "Microphone", "Mic Jack",

                        "Line", "Line In";

                simple-audio-card,routing =

                        "Headphone Jack",  "HPL Mux Out",

                        "Headphone Jack",  "HPR Mux Out";

                simple-audio-card,format = "i2s";/* i2s */

                simple-audio-card,bitclock-master = <&cpu_master>;

                simple-audio-card,frame-master = <&cpu_master>;

                simple-audio-card,bitclock-inversion;

 

                cpu_master: simple-audio-card,cpu {

                        sound-dai = <&mcasp0>;

                        system-clock-direction-out;

                };

 

                sound_master: simple-audio-card,codec {

                        sound-dai = <&audio>;

                        /delete-property/ clocks; /* to remove tlv320_mclk on SK-AM62B-P1 */

                };

        };

        main_mcasp0_pins_default: main-mcasp0-default-pins {

                pinctrl-single,pins = <

                        AM62X_IOPAD(0x1a4, PIN_INPUT, 0) /* (B20) MCASP0_ACLKX.MCASP0_ACLKX */

                        AM62X_IOPAD(0x1a8, PIN_INPUT, 0) /* (D20) MCASP0_AFSX.MCASP0_AFSX */

                        AM62X_IOPAD(0x1a0, PIN_OUTPUT, 0) /* (E18) MCASP0_AXR0.MCASP0_AXR0 */

                >;

        };

&mcasp0 {

        status = "okay";

        #sound-dai-cells = <0>;

 

        pinctrl-names = "default";

        pinctrl-0 = <&main_mcasp0_pins_default>;

 

        op-mode = <0>;          /* MCASP_IIS_MODE */

        tdm-slots = <2>;

 

        serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */

               1 0 0 0

               0 0 0 0

               0 0 0 0

               0 0 0 0

        >;

        tx-num-evt = <0>;

        rx-num-evt = <0>;

};

&main_i2c0 {

        status = "okay";

        clock-frequency = <100000>;

        /* use rt5628 for audio */

        audio: audio-codec@18 {

                #sound-dai-cells = <0>;

                compatible = "realtek,rt5628";

                reg = <0x18>;

        };

};

 

[Kernel log we have]

[    1.548344] RT5628 Audio Codec probed

[    1.895897] ALSA device list:

[    1.898894]   #0: am62xx-G04

 

[SCHEMATICS]

[PINMUX]

B20

MCASP0_ACLKX

Audio

Audio out,Audio DAC ALC5629

D20

MCASP0_AFSX

Audio

E18

MCASP0_AXR0

Audio

Thanks

Daniel

  • Hi Daniel,

    What error are you seeing when you run the aplay ALSA command?

    Best Regards,

    Suren

  • Hi Suren

    aplay -Dplughw:0,0 file_example_WAV_2MG.wav

    Playing WAVE 'file_example_WAV_2MG.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

    ALSA lib pcm_params.c:2235:(snd1_pcm_hw_refine_slave) Slave PCM not usable

    aplay: set_params:1358: Broken configuration for this PCM: no configurations available

    Thanks

    Daniel

  • Hi Daniel,

    Please share the entire DTS file with your changes. 

    Also does playing a 48KHz file work fine with the current changes?

    Also can you share the output of k3conf dump clocks | grep -i mcasp0

    Best Regards,

    Suren 

  • Hi Suren 

    How to "output of k3conf dump clocks | grep -i mcasp0"?

    [Device tree]

            codec_audio: sound {

                    compatible = "simple-audio-card";

                    simple-audio-card,name = "am62xx-G04";

                    simple-audio-card,widgets =

                            "Headphone", "Headphone Jack",

                            "Line", "Line Out",

                            "Microphone", "Mic Jack",

                            "Line", "Line In";

                    simple-audio-card,routing =

                            "Headphone Jack",  "HPL Mux Out",

                            "Headphone Jack",  "HPR Mux Out";

                    simple-audio-card,format = "i2s";/* i2s */

                    simple-audio-card,bitclock-master = <&cpu_master>;

                    simple-audio-card,frame-master = <&cpu_master>;

                    simple-audio-card,bitclock-inversion;

     

                    cpu_master: simple-audio-card,cpu {

                            sound-dai = <&mcasp0>;

                            system-clock-direction-out;

                    };

     

                    sound_master: simple-audio-card,codec {

                            sound-dai = <&audio>;

                            /delete-property/ clocks; /* to remove tlv320_mclk on SK-AM62B-P1 */

                    };

            };

            main_mcasp0_pins_default: main-mcasp0-default-pins {

                    pinctrl-single,pins = <

                            AM62X_IOPAD(0x1a4, PIN_INPUT, 0) /* (B20) MCASP0_ACLKX.MCASP0_ACLKX */

                            AM62X_IOPAD(0x1a8, PIN_INPUT, 0) /* (D20) MCASP0_AFSX.MCASP0_AFSX */

                            AM62X_IOPAD(0x1a0, PIN_OUTPUT, 0) /* (E18) MCASP0_AXR0.MCASP0_AXR0 */

                    >;

            };

    &mcasp0 {

            status = "okay";

            #sound-dai-cells = <0>;

     

            pinctrl-names = "default";

            pinctrl-0 = <&main_mcasp0_pins_default>;

     

            op-mode = <0>;          /* MCASP_IIS_MODE */

            tdm-slots = <2>;

     

            serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */

                   1 0 0 0

                   0 0 0 0

                   0 0 0 0

                   0 0 0 0

            >;

            tx-num-evt = <0>;

            rx-num-evt = <0>;

    };

    &main_i2c0 {

            status = "okay";

            clock-frequency = <100000>;

            /* use rt5628 for audio */

            audio: audio-codec@18 {

                    #sound-dai-cells = <0>;

                    compatible = "realtek,rt5628";

                    reg = <0x18>;

            };

    };

    Thanks

    Daniel

  • Daniel,

    If you are using the MCASP as the master, then the PIN configurations should change to PIN_OUPUT instead of PIN_INPUT in your device tree.

    Best Regards,

    Suren

  • Hi Suren

    Do you mean all three pins set to PIN_OUTPUT ?

    Same error with the change

            main_mcasp0_pins_default: main-mcasp0-default-pins {

                    pinctrl-single,pins = <

                            AM62X_IOPAD(0x1a4, PIN_OUTPUT, 0) /* (B20) MCASP0_ACLKX.MCASP0_ACLKX */

                            AM62X_IOPAD(0x1a8, PIN_OUTPUT, 0) /* (D20) MCASP0_AFSX.MCASP0_AFSX */

                            AM62X_IOPAD(0x1a0, PIN_OUTPUT, 0) /* (E18) MCASP0_AXR0.MCASP0_AXR0 */

                    >;

            };

  • Hi Suren

    Could you help to give some suggestions?

    Thanks

    Daniel

  • Hi Daniel,

    Please share the output of aplay -l command?

    Are you able to register the soundcard. Also, are you able to probe the BCLK/WCLK ?

    Best Regards,

    Suren

  • Hi Suren

    are you able to probe the BCLK/WCLK ?  <=How can I do this?

    Thanks

    Daniel

  • Hi Daniel,

    I see you are able to register your soundcard with the changes. 

    BCLK and WCLK Points to MCASP ACLKX and FSX pins that you have interfaced to the codec. You need to probe those pins on logic analyzer/oscilloscope and see if you are seeing the clocks

    Also are you using tisdk-default-image (since you are not seeing k3conf on your end)? 

    Best Regards,

    Suren

  • Hi Suren

    BCLK and WCLK Points to MCASP ACLKX and FSX pins that you have interfaced to the codec. You need to probe those pins on logic analyzer/oscilloscope and see if you are seeing the clocks

    => no clocks on ACLKX  

    Also are you using tisdk-default-image (since you are not seeing k3conf on your end)? 

    => we are using buildroot from TI

    https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/11_01_05_03_Buildroot/exports/docs/buildroot/Building_Buildroot_Image.html

    Regards,

    Scott

  • Hi Suren

    Could you help to give some suggestions?

    Thanks

    Daniel

  • Hi Suren

    We try to add mcasp_mclk in device tree and aplay cmd looks like playing wav file but still no sound.

    the logic analyzer/oscilloscope on MCASP0_ACLKX show 12MHz.

    mcasp_mclk: mcasp-mclk {
    #clock-cells = <0>;
    compatible = "fixed-clock";
    clock-frequency = <12288000>;
    };
    codec_audio: sound {
    compatible = "simple-audio-card";
    simple-audio-card,name = "am62xx-G04";
    simple-audio-card,widgets =
    "Headphone", "Headphone Jack",
    "Line", "Line Out",
    "Microphone", "Mic Jack",
    "Line", "Line In";
    simple-audio-card,routing =
    "Headphone Jack", "HPL Mux Out",
    "Headphone Jack", "HPR Mux Out";
    simple-audio-card,format = "i2s";/* i2s */
    simple-audio-card,bitclock-master = <&cpu_master>;
    simple-audio-card,frame-master = <&cpu_master>;
    simple-audio-card,bitclock-inversion;

    cpu_master: simple-audio-card,cpu {
    sound-dai = <&mcasp0>;
    clocks = <&mcasp_mclk>;
    system-clock-direction-out;
    };

    sound_master: simple-audio-card,codec {
    sound-dai = <&audio>;
    /delete-property/ clocks; /* to remove tlv320_mclk on SK-AM62B-P1 */
    };
    };

    Regards

    Scott

  • Hi Scott,

    If you are seeing 12MHZ on ACLKX, Can you also probe FSX and AXR0 of MCASP0. 

    Please share the screenshot of each of these when you are probing.

    Also, Can you use the default TISDK to build instead of buildroot and have the k3conf utility.

    Best Regards,

    Suren

  • Hi Suren

    Here is the k3conf dump by using prebuild img. 

    The logic analyzer/oscilloscope on each three pins

    Regards,

    Scott

  • Hi Scott, 

    Where is the codec driver for RT5628 in linux? Have you enabled it?

    Best Regards,

    Suren

  • Hi Suren

    We add CONFIG_SND_SOC_RT5628 into linux build including linux-11.01.05/sound/soc/codecs/rt5628.c & rt5628.h

    Regards,

    Scott

  • Hi Scott,

    I don't see this driver in upstream Linux kernel? Are you sure you have the right driver?

    Best Regards,

    Suren

  • Hi Suren

    We add it by ourselves. is there anything we can check?

    Regards,

    Scott

  • How do you verify if the codec that you added is functional?

    Best Regards,

    Suren

  • Hi Suren

    Codec was from supplier.

    Regards,

    Scott

  • Scott,

    I want to know how do you verify the codec is working fine standalone? Does the supplier be able to help you here in testing the codec individually by playing a sound/ capturing sound.

    I will be able to help post that, if you are able to validate the codec is working fine. Can you loop back the Data Input to Data out of the codec and see if you are able to play any sound.

    Best Regards,

    Suren