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/AM3352: TLV320AIC3100 slave mode

Part Number: AM3352
Other Parts Discussed in Thread: TLV320AIC3100

Tool/software: Linux

Hello,

We have our own board design based on am3352 processor and we use kernel 4.4.19 from TI SDK 03.01.00.06

We also have included TLV320AIC3100 codec in our design.

We want to use it in slave mode, but looking into tlv320aic31xx.c file it seems as it is always configured in master mode.

How can I configure it in slave mode? Do I need to change tlv320aic31xx.c source code?

I thought It was possible to do it via .dts file.

Best regards

  • Hi,

    This should be set in the dai link structure. For example see the static struct snd_soc_dai_link evm_dai_tlv320aic3x structure in sound/soc/davinci/davinci-evm.c. In the .dai_fmt, you should have the SND_SOC_DAIFMT_CBS_CFS value, which defines that codec is clock and frame slave.
    For all possible configurations check sound/soc/davinci/davinci-mcasp.c: switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { and configure the dai link structure according to your use case.
    Additional info can be found in processors.wiki.ti.com/.../Sitara_Linux_Audio_DAC_Example

    Hope this helps.
    Best Regards,
    Yordan
  • Hi Yordan,

    Thank you for your help. I made changes as you suggested and set .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_NB_NF.

    But when functions aic31xx_set_dai_fmt()(in tlv320aic31xx.c) and davinci_mcasp_set_dai_fmt() (in davinci-mcasp.c) are called during kernel boot and when I use aplay command, configuration parameter is still SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF. fmt parameter is 0x1305.

    Looking into davinci-evm.c evm_init() function
    /*
    * If dtb is there, the devices will be created dynamically.
    * Only register platfrom driver structure.
    */
    #if defined(CONFIG_OF)
    if (of_have_populated_dt())
    return platform_driver_register(&davinci_evm_driver);
    #endif

    it seems that configuration is made via .dts file.

    These are our .dts file settings

    sound {
    compatible = "simple-audio-card";
    simple-audio-card,name = "AM335x-EVMSK";
    simple-audio-card,widgets =
    "Headphone", "Headphone Jack";
    simple-audio-card,routing =
    "Headphone Jack", "HPL",
    "Headphone Jack", "HPR";
    simple-audio-card,format = "dsp_b";
    simple-audio-card,bitclock-master = <&sound_master>;
    simple-audio-card,frame-master = <&sound_master>;
    simple-audio-card,bitclock-inversion;

    simple-audio-card,cpu {
    sound-dai = <&mcasp0>;
    };

    sound_master: simple-audio-card,codec {
    sound-dai = <&tlv320aic3100>;
    system-clock-frequency = <24000000>;
    clock-names = "mclk";
    };
    };

    mcasp0_pins: mcasp0_pins {
    pinctrl-single,pins = <
    0x1a0 ( PIN_INPUT_PULLDOWN | MUX_MODE0 ) /* (B12) mcasp0_aclkr.mcasp0_aclkr */
    0x1a4 ( PIN_INPUT_PULLDOWN | MUX_MODE0 ) /* (C13) mcasp0_fsr.mcasp0_fsr */
    0x19c ( PIN_OUTPUT_PULLDOWN | MUX_MODE2 ) /* (C12) mcasp0_ahclkr.mcasp0_axr2 */
    0x1a8 ( PIN_INPUT_PULLDOWN | MUX_MODE0 ) /* (D13) mcasp0_axr1.mcasp0_axr1 */
    >;
    };

    &i2c0 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c0_pins>;

    status = "okay";
    clock-frequency = <400000>;

    tlv320aic3100: tlv320aic3100@18 {
    #sound-dai-cells = <0>;
    compatible = "ti,tlv320aic3100";
    reg = <0x18>;
    status = "okay";
    clock-names = "mclk";
    };
    };

    &mcasp0 {
    #sound-dai-cells = <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&mcasp0_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>;
    };

    Could please help us with this?

    Best regards
  • Hi Yordan,

    It seems that now configuration must be done in .dts file. This is an example


    sound {
    compatible = "simple-audio-card";
    simple-audio-card,name = "AM335x-EVMSK";
    simple-audio-card,widgets =
    "Headphone", "Headphone Jack";
    simple-audio-card,routing =
    "Headphone Jack", "HPL",
    "Headphone Jack", "HPR";
    simple-audio-card,format = "i2s";
    simple-audio-card,bitclock-master = <&sound_master>;
    simple-audio-card,frame-master = <&sound_master>;
    simple-audio-card,bitclock-inversion;

    sound_master: simple-audio-card,cpu {
    sound-dai = <&mcasp0>;
    };

    simple-audio-card,codec {
    sound-dai = <&tlv320aic3100>;
    system-clock-frequency = <24000000>;
    clock-names = "mclk";
    };

    The problem is that codec driver file tlv320aic31xx.c is only ready to work as master. So some changes are needed if you want to use it in slave mode.

    Best regards