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.

Linux/TDA2SX: Device tree configuration for Binding TLV320AIC3x with mcasp

Part Number: TDA2SX
Other Parts Discussed in Thread: TLV320AIC34

Tool/software: Linux

Hello all,

                         We are working on a custom board based on tda2sx.We have connect TLV320AIC3x to mcasp4 and mcasp7.What all configuration are needed in the device tree? I've come this far.But not sure if its correct or not.


        snd2: sound@1 {
               compatible = "simple-audio-card";
               simple-audio-card,name = "DRA7xx-EVM-snd2";
               simple-audio-card,widgets =
                       "Microphone",            "Mic Jack",
                       "Line",                  "Line In",
                       "Line",                  "Line Out",
                       "Headphone",             "HP Jack",
                       "Speaker",               "Speaker External";
               simple-audio-card,routing =
                       "HP Jack",               "HPLOUT",
                       "HP Jack",               "HPROUT",
                       "HP Jack",               "HPLCOM",
                       "HP Jack",               "HPRCOM",
                       "Speaker External",      "LLOUT",
                       "Speaker External",      "RLOUT",
                       "LINE2L",                "Line In",
                       "LINE2R",                "Line In";

               simple-audio-card,format = "i2s";
              /* simple-audio-card,bitclock-master = <&sound1_master>;
               simple-audio-card,frame-master = <&sound1_master>;
               simple-audio-card,bitclock-inversion;*/
               sound1_master: simple-audio-card,cpu {
                        sound-dai = <&mcasp7>;
                      system-clock-frequency = <19200000>;
               };

               simple-audio-card,codec {
                       sound-dai = <&tlv320aic34_a>;
                       bitclock-master;
                       frame-master;
                       bitclock-inversion;
                       system-clock-frequency = <19200000>;
                    /*  system-clock-frequency = <19200000>;*/
               };
        };
        snd3: sound@2 {
               compatible = "simple-audio-card";
               simple-audio-card,name = "DRA7xx-EVM-snd3";
               simple-audio-card,widgets =
                       "Microphone", "Mic Jack",
                       "Line",                  "Line In",
                       "Line",                  "Line Out",
                       "Headphone",             "HP Jack",
                       "Speaker",               "Speaker External";
               simple-audio-card,routing =
                       "Line Out",              "MONO_LOUT",
                       "Speaker External",      "LLOUT",
                       "Speaker External",      "RLOUT",
                       "LINE1L",                "Line In",
                       "LINE1R",                "Line In",
                       "MIC3L",                 "Mic Jack",
                       "MIC3R",                 "Mic Jack";
               simple-audio-card,format = "i2s";
              /* simple-audio-card,bitclock-master = <&sound2_master>;
               simple-audio-card,frame-master = <&sound2_master>;
               simple-audio-card,bitclock-inversion;*/

               sound2_master: simple-audio-card,cpu {
                        sound-dai = <&mcasp4>;
                      system-clock-frequency = <19200000>;
               };

               simple-audio-card,codec {
                       sound-dai = <&tlv320aic34_b>;
                       bitclock-master;
                       frame-master;
                       bitclock-inversion;
                       system-clock-frequency = <19200000>;
                    /*  system-clock-frequency = <19200000>;*/
               };
        };

/**cut here***/

/**pinmux**/

aic34_mcasp7: aic34_mcasp7 {
                 pinctrl-single,pins = <
                        0x29C (PIN_OUTPUT | MUX_MODE4) /*default ws 3*/ /* xref_clk2.mcasp7_ahclkx - MCLK */
                        0x2EC (PIN_OUTPUT | MUX_MODE1)  /* mcasp1_axr14.mcasp7_aclkx - BCLK */
                        0x2F0 (PIN_OUTPUT | MUX_MODE1)  /* mcasp1_axr15.mcasp7_fsx - WCLK */
                        0x2E8 (PIN_INPUT_PULLUP | MUX_MODE1)  /* mcasp1_axr13.mcasp7_axr1 - DIN */
                        0x2E4 (PIN_OUTPUT | MUX_MODE1)  /* mcasp1_axr12.mcasp7_axr0 - DOUT */
                        >;
        };

        aic34_mcasp4: aic34_mcasp4 {
                 pinctrl-single,pins = <
                        0x2A0 (PIN_OUTPUT | MUX_MODE3)  /* xref_clk3.mcasp4_ahclkx - MCLK */
                        0x334 (PIN_OUTPUT | MUX_MODE0)  /* mcasp4_aclkx.mcasp4_aclkx - BCLK */
                        0x338 (PIN_OUTPUT | MUX_MODE0)  /* mcasp4_fsx.mcasp4_fsx - WCLK */
                        0x340 (PIN_INPUT_PULLUP | MUX_MODE0)  /* mcasp4_axr1.mcasp4_axr1 - DIN */
                        0x33C (PIN_OUTPUT | MUX_MODE0)  /* mcasp4_axr0.mcasp4_axr0 - DOUT */
                        0x3C0 (PIN_OUTPUT_PULLUP | MUX_MODE14)  /* gpio7_14 - DOUT */
                        0x158 (PIN_OUTPUT_PULLUP | MUX_MODE14)  /* gpio3_29 - DOUT */
                        0x190 (PIN_OUTPUT_PULLUP | MUX_MODE14)  /* gpio4_11 - DOUT */
                >;
        };

/***i2c**/

&i2c3 {
    status = "okay";
    clock-frequency = <400000>;

    /*      Audio Codec for ITS, FS:NIRAJ   */

    tlv320aic34_a: tlv320aic34_a@1a {
                #sound-dai-cells = <0>;
                compatible = "ti,tlv320aic3x";
                reg = <0x1a>;
                adc-settle-ms = <40>;
                ai3x-micbias-vg = <1>;          /* 2.0V */
        gpio-reset = <&gpio2 26 GPIO_ACTIVE_LOW>;
                status = "okay";

                /* Regulators */
                AVDD-supply = <&evm_3v3_sw>;
                IOVDD-supply = <&evm_3v3_sw>;
                DRVDD-supply = <&evm_3v3_sw>;
                DVDD-supply = <&aic_dvdd>;
        };

    tlv320aic34_b: tlv320aic34_b@1b {
                #sound-dai-cells = <0>;
                compatible = "ti,tlv320aic3x";
                reg = <0x1b>;
                adc-settle-ms = <40>;
                ai3x-micbias-vg = <1>;          /* 2.0V */
        gpio_reset = <&gpio2 27 GPIO_ACTIVE_LOW>;
                status = "okay";

                /* Regulators */
                AVDD-supply = <&evm_3v3_sw>;
                IOVDD-supply = <&evm_3v3_sw>;
                DRVDD-supply = <&evm_3v3_sw>;
                DVDD-supply = <&aic_dvdd>;
        };

};


/* Mcasp6 ITS end */
/* Mcasp7 ITS */
&mcasp7 {
        #sound-dai-cells = <0>;

        status = "okay";

        pinctrl-names = "default";
        pinctrl-0 = <&aic34_mcasp7>;

        op-mode = <0>;          /* MCASP_IIS_MODE */
        tdm-slots = <2>;
        /* 4 serializer */
        serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
                1 2 0 0
        >;
        tx-num-evt = <32>;
        rx-num-evt = <32>;
};
/* Mcasp 7 ITS end */

/* Mcasp 4 ITS */
&mcasp4 {
        #sound-dai-cells = <0>;

        status = "okay";

        pinctrl-names = "default";
        pinctrl-0 = <&aic34_mcasp4>;

        op-mode = <0>;          /* MCASP_IIS_MODE */
        tdm-slots = <2>;
        /* 4 serializer */
        serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
                1 2 0 0
        >;
        tx-num-evt = <32>;
        rx-num-evt = <32>;
};

&atl {
    assigned-clocks = <&abe_dpll_sys_clk_mux>,
              <&atl_gfclk_mux>,
              <&dpll_abe_ck>,
              <&dpll_abe_m2x2_ck>,
              <&atl_clkin1_ck>,
              <&atl_clkin2_ck>;
    assigned-clock-parents = <&sys_clkin2>, <&dpll_abe_m2_ck>;
    assigned-clock-rates = <0>, <0>, <180633600>, <361267200>,
                <11289600>, <11289600>;

    status = "okay";

    atl2 {
        bws = <DRA7_ATL_WS_MCASP2_FSX>;
        aws = <DRA7_ATL_WS_MCASP3_FSX>;
    };
};

                                    I could not find any sample device tree configuration.When i boot with the above configuration i get the below logs:

tlv320aic3x-codec 2-001a: ASoC: Failed to set DAI format: -22
asoc-simple-card sound@1: tlv320aic3x-hifi <-> 48478000.mcasp mapping ok
------------[ cut here ]------------
WARNING: CPU: 0 PID: 222 at drivers/bus/omap_l3_noc.c:147 0xc01fc70c()
44000000.ocp:L3 Custom Error: MASTER MPU TARGET L4_PER2_P3 (Read): Data Access in User mode during Functional access
Modules linked in: snd_soc_simple_card(+) bc_example(O) pvrsrvkm(O) snd_soc_davinci_mcasp dwc3_omap extcon rtc_omap snd_soc_edma snd_soc_tlv320aic3x snd_soc_omap ch7026_vga omap_rng rng_core snd_soc_core snd_pcm_dmaengine snd_pcm omap_remoteproc snd_timer remoteproc snd virtio virtio_ring soundcore ipv6
CPU: 0 PID: 222 Comm: systemd-udevd Tainted: G        W  O    4.4.84 #4
Hardware name: Generic DRA74X (Flattened Device Tree)
Backtrace:  
Function entered at [<c00124a8>] from [<c0012694>]
 r7:00000093 r6:200f0193 r5:00000000 r4:c05f6dfc

/***cut here***/

I noticed several crashes related to msasp . Kindly help me solve this issue

davinci-mcasp 48474000.mcasp: ERRATA i868 workaround is enabled
clock: dpll_abe_ck failed transition to 'locked'
clock: dpll_abe_ck failed transition to 'locked'

Full log:

Ams_1.txt

Regards,

Murugan S

  • Hi Murugan,

    I see that you have the codec as the master - you have to make sure that the codec is actually providing the clocks to McASP. Your pinmux settings doesn't look correct, BCLK and FSYNC are configured as output (which is correct for McASP as master) instead of input (which is correct for codec as master).

    Also, is there a reason why below properties are set in the codec node and not in the sound card node:

                   simple-audio-card,codec {
                           sound-dai = <&tlv320aic34_a>;
                           bitclock-master;
                           frame-master;
                           bitclock-inversion;

    The dpll_abe_ck issue is likely the reason of the crashes that you're observing, but since there is another E2E ticket on that topic. I'll provide my inputs there.

  • Hi Misael,

                                   Thanks for your inputs.It helped alot.My intention is to make SoC as master and codec as slave.That is why i kept BCLK and FSYNC  configured as output. What other changes should I make to use McASP as master?

    Regards,

    Murugan S

  • Hi Misael,

     About this part:

                                      simple-audio-card,codec {
                           sound-dai = <&tlv320aic34_a>;
                           bitclock-master;
                           frame-master;
                           bitclock-inversion;

                                                        I'm not sure about the effect of these configurations.Are these configurations wrong?

    Regards,

    Murugan S

  • Yes, they will make codec master for BCLK and FSYNC. I'd recommend to use the simple-card properties instead:

    simple-audio-card,bitclock-master = <&sound1_master>;
    simple-audio-card,frame-master = <&sound1_master>;
    ...
    sound1_master: simple-audio-card,cpu {
      [mcasp properties here]
    };

    Basically, revert back to the original dts configuration which is for McASP as master.