This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM437x with sgtl5000 codec

Other Parts Discussed in Thread: TLV320AIC3107

Hello everyone,

I using am437x with linux 3.12.10.

For some reasons we need to use sgtl5000 on our products. but even I debugged one week on our product, the sgtl5000 still can not works OK.

I modified the device tree:

    sound {
        compatible = "ti,myd-c437x-audio";
	ti,model = "AM437x-GP-EVM";
        ti,audio-codec = <&sgtl5000>;
        ti,mcasp-controller = <&mcasp1>;
        ti,codec-clock-rate = <12000000>;
        ti,audio-routing =
            "Headphone Jack",       "HPLOUT",
	    "Headphone Jack",       "HPROUT",
	    "LINE1L",               "Line In",
	    "LINE1R",               "Line In";
    };
    // ..............
&i2c1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins>;

    // .............
    sgtl5000: sgtl5000@0a {
        compatible = "fsl,sgtl5000";
        reg = <0x0a>;
        clocks = <&func_12m_clk>;
        clock-names = "fck";

        VDDA-supply = <&evm_v3p3>;
	VDDIO-supply = <&evm_v3p3>;
        VDDD-supply = <&evm_v3p3>;
    };
};
    

And added the machine code in davinci-evm.c:

static struct snd_soc_dai_link myd_dai_sgtl5000 = {
    .name      = "sgtl5000",
    .stream_name = "SGTL5000",
    .codec_dai_name = "sgtl5000",
    .ops        = &evm_ops,
    .dai_fmt    = (SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_DSP_B |
                   SND_SOC_DAIFMT_IB_NF),
};

static const struct of_device_id davinci_evm_dt_ids[] = {
    // ....................
    /* For myd-c437x */
    {
        .compatible = "ti,myd-c437x-audio",
        .data = &myd_dai_sgtl5000,
    },
    { /* sentinel */ }
};

Now, I could find the sound card:

root@am437x-evm ~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: AM437xGPEVM [AM437x-GP-EVM], device 0: SGTL5000 sgtl5000-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

But I could not hear any sounds from headphone, and I could not capture any waveform on MCASP1_ACLKX,MCASP1_FSX,MCASP1_AXR0,MCASP1_AXR1.
The hardware design as the following:

I though the sound data was not be sent to the codec, because after several snd_pcm_writei calls in my application, the kernel function snd_pcm_playback_avail() that in pcm.h would return 0, it indicates the DMA is full.

Can anyone provide some suggestions? for example, how do I to debug the codec, or how do I to modify the codes for making the codec works fine?

Thanks!

Warm Regards,

Kinly

  • Hi Kinly,

    Have you pinmuxed the McASP pins correctly? Where does your McASP master clock come from - Y3 or AM437X clock source?

  • Hi Biser,


    Thanks for your quick reply!

    Yes I had pinmuxed in device tree like the following:

           mcasp1_pins: mcasp1_pins {
     		pinctrl-single,pins = <
     			0x10c (PIN_INPUT_PULLDOWN | MUX_MODE4)	/* mii1_crs.mcasp1_aclkx */
    			0x1a4 (PIN_INPUT_PULLDOWN  | MUX_MODE3) /* mcasp0_fsr.mcasp1_fsx */
    			0x1a8 (PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* mcasp0_axr1.mcasp1_axr0 */
    			0x1ac (PIN_INPUT_PULLDOWN  | MUX_MODE3) /* mcasp0_ahclkx.mcasp1_axr1 */
     		>;
     	};
    
    // ......................
    &mcasp1 {
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&mcasp1_pins>;
        pinctrl-1 = <&mcasp1_sleep_pins>;
    
        status = "okay";
    
        op-mode = <0>; /* MCASP_IIS_MODE */
        tdm-slots = <2>;
        /* 4 serializers */
        serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
            0 0 1 2
        >;
        tx-num-evt = <32>;
        rx-num-evt = <32>;
    };
    

    The clock comes from Y3 and the R155 is DNI.

    I had checked the but have not ideas for now.

    Thanks again.

    Kinly

  • Does this 12MHz clock from Y3 go to the AM437X too? To which pin? You need to provide this clock as the McASP master clock source.

  • Hi Biser,

    Thanks your reply very much!

    The Y3 just provide clock source for SGTL5000, does not go to the AM437X.

    There are other two crystal oscillators provide clock for AM437X:

    Sorry but I don't very understand what the means of "need to provide this clock as the McASP master clock source"? which pin in AM437X should I connect to Y3?

    Warm Regards,

    Kinly

  • Please read section 24.3.5 from the AM437X Technical Reference Manual, Rev. B. I don't think your system will work properly if you provide two separate high-frequency clock sources - from Y3 to external codec, and from AM437X internal clock source to AM437X McASP peripheral.

  • Hello Biser,

    I am facing a similar problem. Please tell me if I have understood correctly.
    The system may not work properly if two different clock sources are used. Therefore, connecting a 12MHz oscillator output to both the codec IC (TLV320AIC3107 in my case) as well as the master clock pin on AM437x should solve the problem. Is this correct?
    Also, when using I2S, AHCLKX is the master clock pin on the AM437x side, right?
  • If you are referring to the AM437X GP EVM schematic, the clock from the external 12MHz oscillator goes only to the audio codec, and AM437X bit clock and frame clock is sourced from the codec to the AM437X. The codec has an internal PLL to derive the required bit/frame frequencies from the 12MHz clock. You will notice that the 12MHz clock is not connected to AM437X.