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 ALSA no soundcards detected

Other Parts Discussed in Thread: TLV320AIC3107, TPS63031, TLV320AIC3100, TLV320AIC3110, TLV320AIC3120, TLV320AIC3111, TLV320AIC3106

Hello,

I have a custom board based on AM437x connected to TLV320AIC3107 audio codec. The schematic is attached. The level translator is used because that bank of AM437x is 1.8V. Is the schematic correct?

The problem I am facing is that Linux does not detect any sound cards. I get "ALSA devices list - No soundcards detected" error during bootup, no I2C driver is registered with the device, and there is no /proc/asound/card entry. The relevant parts of the device tree are:

refclk: oscillator {
        #clock-cells = <0>;
        compatible = "fixed-clock";
        clock-frequency = <12000000>;

sound0: sound@0 {
        compatible = "simple-audio-card";
        simple-audio-card,name = "AM437x-GP-EVM";
        simple-audio-card,widgets =
            "Headphone", "Headphone Jack",
            "Line", "Line In";
        simple-audio-card,routing =
            "Headphone Jack",    "HPLOUT",
            "Headphone Jack",    "HPROUT",
            "LINE1L",        "Line In",
            "LINE1R",        "Line In";
        simple-audio-card,format = "dsp_b";
        simple-audio-card,bitclock-master = <&sound0_master>;
        simple-audio-card,frame-master = <&sound0_master>;
        simple-audio-card,bitclock-inversion;
 
        simple-audio-card,cpu {
            sound-dai = <&mcasp1>;
            system-clock-frequency = <12000000>;
        };
 
        sound0_master: simple-audio-card,codec {
            sound-dai = <&tlv320aic3107>;
            system-clock-frequency = <12000000>;
        };
    };
 
    audio_mstrclk: mclk_osc {
        compatible = "fixed-clock";
        #clock-cells = <0>;
        clock-frequency = <12000000>;
    };

mcasp1_pins_default: mcasp1_pins_default {
        pinctrl-single,pins = <
            0x10c ( PIN_INPUT_PULLDOWN | MUX_MODE4 ) /* (B14) mii1_crs.mcasp1_aclkx */
            0x110 ( PIN_INPUT_PULLDOWN | MUX_MODE4 ) /* (B13) mii1_rx_er.mcasp1_fsx */
            0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE3 ) /* (B15) mii1_txd0.mcasp1_axr2 */
            0x144 ( PIN_INPUT_PULLDOWN | MUX_MODE4 ) /* (A16) rmii1_ref_clk.mcasp1_axr3 */
        >;
    };
    
    /* Optional sleep pin settings. Must manually enter values in     the below skeleton. */
    mcasp1_pins_sleep: mcasp1_pins_sleep {
        pinctrl-single,pins = <
            0x10c (PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (B14) mii1_crs.mcasp1_aclkx */
            0x110 (PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (B13) mii1_rx_er.mcasp1_fsx */
            0x128 (PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (B15) mii1_txd0.mcasp1_axr2 */
            0x144 (PIN_INPUT_PULLDOWN | MUX_MODE7 ) /* (A16) rmii1_ref_clk.mcasp1_axr3 */
        >;
    };

&i2c0{

tlv320aic3107: tlv320aic3107@18 {
    #sound-dai-cells = <0>;
        compatible = "ti,tlv320aic3107";
        reg = <0x18>;
        status = "okay";
 
        /* Regulators */
        IOVDD-supply = <&evm_v3_3d>; /* V3_3D -> <tps63031> EN: V1_8D -> VBAT */
        AVDD-supply = <&evm_v3_3d>; /* v3_3AUD -> V3_3D -> ... */
        DRVDD-supply = <&evm_v3_3d>; /* v3_3AUD -> V3_3D -> ... */
        DVDD-supply = <&ldo1>; /* V1_8D -> LDO1 */
 
    };
};

&mcasp1 {
    #sound-dai-cells = <0>;
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&mcasp1_pins_default>;
    pinctrl-1 = <&mcasp1_pins_sleep>;
 
    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>;
};

I checked the working of the GP-EVM. During bootup, the GP-EVM also gives the same "No soundcards detected" error. However, after booting, it creates a card0 entry in /proc/asound. How does this happen, and how can my problem be solved?

Please let me know what other information I need to provide.

Regards,

Rajat RaoAudio SubSystem.pdf

  • The software team have been notified. They will respond here.
  • Hi,

    Which kernel is this? I think you may be pointing to the wrong codec driver. Try changing

    tlv320aic3107: tlv320aic3107@18 {

       #sound-dai-cells = <0>;

           compatible = "ti,tlv320aic3107";

           reg = <0x18>;

           status = "okay";

    To

       tlv320aic3107: tlv320aic3107@18 {

       #sound-dai-cells = <0>;

           compatible = "ti,tlv320aic310x";

           reg = <0x18>;

           status = "okay";

    The driver for tlv320aic3107 is: sound/soc/codecs/tlv320aic31xx.c, and it has the following options for binding to the codec: 
       

    #if defined(CONFIG_OF)
    static const struct of_device_id tlv320aic31xx_of_match[] = {
    { .compatible = "ti,tlv320aic310x" },
    { .compatible = "ti,tlv320aic311x" },
    { .compatible = "ti,tlv320aic3100" },
    { .compatible = "ti,tlv320aic3110" },
    { .compatible = "ti,tlv320aic3120" },
    { .compatible = "ti,tlv320aic3111" },
    {},
    };
    MODULE_DEVICE_TABLE(of, tlv320aic31xx_of_match);

    Best Regards, 
    Yordan

  • Hi Yordan,

    Thank you very much, your solution solved the problem. The i2c driver registers the device and a card0 entry is created in /proc/asound.
    However, I get the following error messages:
    [ 10.084660] asoc-simple-card sound@0: ASoC: no source widget found for HPLOUT
    [ 10.175198] asoc-simple-card sound@0: ASoC: Failed to add route HPLOUT -> dik
    [ 10.184233] asoc-simple-card sound@0: ASoC: no source widget found for HPROUT
    [ 10.400231] asoc-simple-card sound@0: ASoC: Failed to add route HPROUT -> dik
    [ 10.495819] asoc-simple-card sound@0: ASoC: no sink widget found for LINE1L
    [ 10.590688] asoc-simple-card sound@0: ASoC: Failed to add route Line In -> dL
    [ 10.676719] asoc-simple-card sound@0: ASoC: no sink widget found for LINE1R
    [ 10.683737] asoc-simple-card sound@0: ASoC: Failed to add route Line In -> dR
    [ 10.926321] asoc-simple-card sound@0: ASoC: no source widget found for SWOUTP
    [ 10.933510] asoc-simple-card sound@0: ASoC: Failed to add route SWOUTP -> dir
    [ 11.124325] asoc-simple-card sound@0: ASoC: no source widget found for SWOUTM
    [ 11.215946] asoc-simple-card sound@0: ASoC: Failed to add route SWOUTM -> dir
    root@am437x-evm:~#

    I did a little reading and found that these error messages are shown because there are no power supply entries for the audio card. I have 2 questions regarding this:
    1) Can I ignore these messages? Will the sound subsystem still work?
    2) Will these messages disappear if I add a HPVDD and SPVDD entry in the dts?

    Regards,
    Rajat Rao
  • Hi Rajat,

    You can try adding the vdd entries in your dts., but from what I know, these warnings come up, because the simple-audio routing messes up...
    Inspect the simple-audio-card,widget & simple-audio-card,routing parameters. You can refer to Documentation/devicetree/bindings/sound/simple-card.txt

    Best Regards,
    Yordan
  • Hi Yordan,

    Thanks again.
    I corrected the strings and the errors disappeared.

    Regards,
    Rajat Rao
  • Hi Yordan,

    I get pcm_write and pcm_read errors when I try to play a wav file using aplay.
    I tried with "dsp_b" and "i2s" formats in the dts file. In both cases, the error I get is

    [ 449.636203] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x80 (0, 0x80, 500000 us)
    [ 449.646685] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: DAC Left event failed: -1
    [ 450.770659] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x8 (0, 0x8, 500000 us)
    [ 450.780968] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: DAC Right event failed: -1
    [ 451.903358] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x20 (0, 0x20, 500000 us)
    [ 451.913843] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: HPL Driver event failed: -1
    [ 453.034007] tlv320aic31xx-codec 0-0018: aic31xx_wait_bits: Failed! 0x25 was 0x0 expected 0x2 (0, 0x2, 500000 us)
    [ 453.044405] tlv320aic31xx-codec 0-0018: ASoC: POST_PMU: HPR Driver event failed: -1
    aplay: pcm_write:1940: write error: Input/output error.

    How can I solve this problem?

    Regards,
    Rajat Rao
  • Hi Yordan,

    Still waiting for a reply...
  • Hi,

    What is the dai_fmt used in davinci_evm.c? Can you try changing this setting?

    Also have a look at this thread:
    e2e.ti.com/.../1649193
    it can provide some ideas to debug your issue.

    Best Regards,
    Yordan
  • Hi Yordan,

    I am getting the following error:

    [    5.139804] tlv320aic31xx-codec 0-0018: Invalid DAI master/slave interface 
    [    5.312296] tlv320aic31xx-codec 0-0018: ASoC: Failed to set DAI format: -22  

    I found that this message is printed by the tlv320ic31xx driver when dai_fmt isn't set to  SND_SOC_DAIFMT_CBM_CFM.

    However, in davinci-evm.c, dai_fmt is set to

    static struct snd_soc_dai_link evm_dai_tlv320aic3x = {
    .name = "TLV320AIC3X",
    .stream_name = "AIC3X",
    .codec_dai_name = "tlv320aic3x-hifi",
    .ops            = &evm_ops,
    .init           = evm_aic3x_init,
    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
      SND_SOC_DAIFMT_IB_NF,
    };

    Why do I get the above error? How do I solve it?

    My device tree entry is identical to the one in the evm. The error doesn't show up in the evm but does on my board.

    Can you suggest a way to check if the I2C link between AM437x and TLV320 is working fine?

    I am using TI SDK2 with kernel version: 4.1.6. My device tree entry matches the davinci-evm format doesn't it? (format=dsp_b, set the codec as master, and bitclock inversion)

    Regards,

    Rajat Rao

  • Hi Yordan,

    Some updates.
    I tried setting the 0x25 register through i2cset and here is the result:

    root@am437x-evm:~# i2cset -f -y -r 0 0x18 0x25 0x80
    Value 0x80 written, readback matched
    root@am437x-evm:~# i2cget -f -y 0 0x18 0x25
    0x80

    This shows that writing to the device is working fine. However, the driver somehow complains that it read back 0x00. What might the problem be?

    Only bits 7 and 6 of register 0x25 are relevant to us and bits D3-D0 are reserved. Why is the driver trying to write 0x08, 0x20, 0x02 to this register?

    Also, please help me with the bootup error in my previous post: Invalid DAI Master/Slave format.


    Regards,
    Rajat Rao
  • Hi Yordan,

    Another update.
    I changed the device tree entry to

    compatible = "ti,tlv320aic3106";

    and things started working. I ran speaker-test and could hear the generated pink noise on headphones. I am yet to try the recording feature, but that might work too.

    Any idea how this change solved the problem?


    Regards,
    Rajat Rao