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.

TLV320ADC3140: [ALSA] creating dai link between cpu-dai and multiple codecs

Part Number: TLV320ADC3140
Other Parts Discussed in Thread: TLV320ADC5140

Hello, 

I am working on a custom design using two TLV320ADC3140 codecs, in this setup one of the codecs shall be configured to be the bus master, while the other codec and the DSP are bus slaves. 

How is it possible to describe such dai link in ALSA and use the ti tlv320adc codec drivers, I could only see examples where a single codec connected to a single cpu.  

  • You will need to define the two devices in the DTS tree as two dai_links, one set as master, the other as slave. As example, here is the DTS for a BeagleBone Black:

    sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "TI BeagleBone Black";
        /*
         * you might need to add:
         * simple-audio-card,widgets
         * simple-audio-card,routing
         */
     
        simple-audio-card,dai-link@0 {              /* First audio device in master mode */
            format = "dsp_a";                      /* Set McASP for TDM bus */      
            bitclock-master = <&sound0_0_master>;  /* Configure device for BCLK master */     
            frame-master = <&sound0_0_master>;     /* Configure device for FSYNC master */   
            sound0_0_master: cpu {
                sound-dai = <&mcasp0>;
                clocks = <&clk_mcasp0>;
                dai-tdm-slot-num = <8>;
                dai-tdm-slot-width = <32>;
                dai-tdm-slot-tx-mask = <1 1 1 1 1 1 1 1>;
                dai-tdm-slot-rx-mask = <1 1 1 1 1 1 1 1>;
            };
     
            codec {
                sound-dai = <&tlv320adc3140 0>;
                dai-tdm-slot-num = <8>;
                dai-tdm-slot-width = <32>;
                dai-tdm-slot-tx-mask = <1 1 1 1 0 0 0 0>;  /* Use first four channels in TDM bus */
                dai-tdm-slot-rx-mask = <1 1 1 1 0 0 0 0>;
            };
        };
     
        simple-audio-card,dai-link@1 {               /* Second audio device in slave mode*/
            format = "dsp_a";                       /* Set McASP for TDM bus */
        sound0_1_slave: cpu {                   /* Defaults to slave. */
                sound-dai = <&mcasp0>;
                clocks = <&clk_mcasp0>;
                dai-tdm-slot-num = <8>;
                dai-tdm-slot-width = <32>;
                dai-tdm-slot-tx-mask = <1 1 1 1 1 1 1 1>;
                dai-tdm-slot-rx-mask = <1 1 1 1 1 1 1 1>;
            };
     
            codec {
                sound-dai = <&tlv320adc3140>;
                dai-tdm-slot-num = <8>;
                dai-tdm-slot-width = <32>;
                dai-tdm-slot-tx-mask = <0 0 0 0 1 1 1 1>;   /* Use last four channels of TDM bus */
                dai-tdm-slot-rx-mask = <0 0 0 0 1 1 1 1>;
            };
        };
    };
    Best regards,
      Pedro
  • Hello Pedro, 

    Thanks for your answer, can you help me understand how this will be seen from the kernel perspective ? will I be able to see one or two PCM streams realized based on this configuration, also when will the DSP send the corresponding configurations to the CODECs over I2C ? is it at the probing stage at start up or it's going to be every time I start using the stream for example using arecord?

  • The above DTS configures two dai links that share one TDM bus with 8 channels. One TLV320ADCx140 device occupies the first four channels, while the second occupies the last four channels. Correspondingly, one device is master of the clocks, while the other is slave.

    Each device will have to have a separate I2C address by setting the ADDR1_MISO pin high on one device and low on the other.  Then the address is assigned on DTS to one peripheral, as follows:

    &i2c2 {
      pinctrl-names = "default";
      pinctrl-0 = <&i2c2_pins>;
      status = "okay";
      clock-frequency = <100000>;
      tlv320adc5140: tlv320adc5140@4c {
        compatible = "ti,tlv320adc5140 0";
       #sound-dai-cells = <0>;
       reg = <0x4c>;
       ti,mic-bias-source = <6>;
      };
      tlv320adc5140: tlv320adc5140@4c {
        compatible = "ti,tlv320adc5140 1";
        #sound-dai-cells = <0>;
       reg = <0x4d>;
       ti,mic-bias-source = <6>;
      };
    };
    Here is the DTS and ALSA documentation. Here is an example of using Sitara with an audio DAC. Please note that a lot of these settings are highly dependent on how your system is configured, how the pins are mapped to each device, and the connections between processors and ADCs. Thus,  we recommend reading the linux documentation to determine the best settings.
    best regards,
      Pedro