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: TLV320AIC3204 driver

Part Number: AM3352
Other Parts Discussed in Thread: TLV320AIC3204, , TLV320AIC3106

Tool/software: Linux

Dear TI Team,

We are design a AI Smart Speaker project. We are used AM3352 and TLV320AIC3204 parts on our boards. We are used Kernel version at 4.4.30 and added "CONFIG_SND_SOC_TLV320AIC32X4" for TLV320AIC3204 audio on defconfig file and build into kernel driver( not kernel module). Beside that, I revise DTS file to integrate it to ALSA audio-simple-codec. Attached below is my dts file. 

- After booting, I type "aplay -l" command, log is:

 root@beaglebone:~# aplay -l

aplay: device_list:268: no soundcards found...

- Dmesg | grep tlv to see log:

 [ 2.327225] tlv320aic32x4 1-0018: Failed getting the mclk. The current implementation does not support the usage of this codec without mclk.

 I also try passing this error by using patch file at the link: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-June/094297.html. But, it seems to not be working for this case.

 

- Could you help to answer my question as below:

  + How can I enable tlv320aic32x4 driver in kernel source?
  + The DTS file is so important. Can you give me some examples of writting DTS file to resolve this problem?

Please see my dts file as below:

* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;

#include "am33xx.dtsi"
#include "am335x-bone-common.dtsi"

/* pruss: pick one: */

/*
* /etc/modprobe.d/pruss-blacklist.conf
*
* blacklist uio_pruss
*/

/* #include "am33xx-pruss-rproc.dtsi" */

/*
* /etc/modprobe.d/pruss-blacklist.conf
*
* blacklist pruss
* blacklist pruss_intc
* blacklist pru-rproc
*/

/* #include "am33xx-pruss-uio.dtsi" */

/ {
model = "TI AM335x BeagleBone Black";
compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
};

&ldo3_reg {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
};

&mmc1 {
vmmc-supply = <&vmmcsd_fixed>;
};

&mmc2 {
vmmc-supply = <&vmmcsd_fixed>;
pinctrl-names = "default";
pinctrl-0 = <&emmc_pins>;
bus-width = <8>;
status = "okay";
};

&cpu0_opp_table {
/*
* All PG 2.0 silicon may not support 1GHz but some of the early
* BeagleBone Blacks have PG 2.0 silicon which is guaranteed
* to support 1GHz OPP so enable it for PG 2.0 on this board.
*/
oppnitro@1000000000 {
opp-supported-hw = <0x06 0x0100>;
};
};

&am33xx_pinmux {
mcasp0_pins: mcasp0_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x9A8, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr1.mcasp0_axr1 AM335X_MCASP0_AXR1 */
AM33XX_IOPAD(0x998, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0.mcasp0_axr0 AM335X_MCASP0_AXR0 */
AM33XX_IOPAD(0x994, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx AM335X_MCASP0_FSX */
AM33XX_IOPAD(0x990, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx AM335X_MCASP0_ACLKX */
>;
};

i2c2_pins: pinmux_i2c2_pins {
pinctrl-single,pins = <
0x150 0x72 /*spi0_scl.i2c2_sda,SLEWCTRL_SLOW | INPUT_PULLUP |MODE2*/
0x154 0x72 /*spi0_d0.i2c2_scl,SLEWCTRL_SLOW | INPUT_PULLUP | MODE2*/
>;
};

i2c1_pins: pinmux_i2c1_pins {
pinctrl-single,pins = <
0x168 (PIN_INPUT_PULLUP | MUX_MODE3) /* uart0_ctsn.i2c1_sda AM335X_I2C1_SDA */
0x16C (PIN_INPUT_PULLUP | MUX_MODE3) /* uart0_rtsn.i2c1_scl AM335X_I2C1_SCL */
>;
};
};

&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&i2c1_pins>;

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

tlv320aic32x4: tlv320aic32x4@18 {
#sound-dai-cells = <0>;
compatible = "ti,tlv320aic32x4";
reg = <0x18>;
};
};

&mcasp0 {
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&mcasp0_pins>;
status = "okay";
op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>; /* Indicates number of channels transmitted or received over one serializer. */
serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */
1 2 0 0
>;
tx-num-evt = <32>;
rx-num-evt = <32>;
};

/ {
sound {
compatible = "simple-audi-ocard";
simple-audio-card,name = "tlv320aic32x4";
simple-audio-card,widgets =
"Headphone", "Headphone Jack",
"Line", "Line In";
simple-audio-card,routing =
"Headphone Jack", "HPL",
"Headphone Jack", "HPR",
"IN1_L", "Line In",
"IN1_R", "Line In";
simple-audio-card,format = "i2s";
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 = <&tlv320aic32x4>;
system-clock-frequency = <12000000>;
};
};

};

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

    THINH Nguyen said:
    We are used Kernel version at 4.4.30

    I would suggest you to use AM335x TI PSDK. The most close kernel version (4.4.32) comes with AM335x TI PSDK v3.02. Also if possible, I would recommend you to switch to the latest AM335x TI PSDK v4.01, which comes with kernel 4.9.41.

    THINH Nguyen said:
      + How can I enable tlv320aic32x4 driver in kernel source?

    This driver is enabled by default in PSDK 4.01 kernel:

    linux-4.9.41/sound/soc/codecs/Makefile

    linux-4.9.41/sound/soc/codecs/Kconfig

    linux-4.9.41/sound/soc/codecs/tlv320aic32x4.c

    linux-4.9.41/sound/soc/codecs/tlv320aic32x4.h

    linux-4.9.41/include/sound/tlv320aic32x4.h

    linux-4.9.4/Documentation/devicetree/bindings/sound/tlv320aic32x4.txt

    You can refer to that 4.9.41 kernel for reference.

    THINH Nguyen said:
      + The DTS file is so important. Can you give me some examples of writting DTS file to resolve this problem?

    You can refer to the below PSDK 4.01 AM335x DTS files for examples (TLV320AIC3106 is used on AM335x TI boards):

    linux-4.9.41/arch/arm/boot/dts/am335x-evm.dts

    linux-4.9.41/arch/arm/boot/dts/am335x-evmsk.dts

    See also below DTS files:

    linux-4.9.41/arch/arm/boot/dts/am335x-wega.dtsi

    linux-4.9.41/arch/arm/boot/dts/am335x-pepper.dts

    linux-4.9.41/arch/arm/boot/dts/am335x-sl50.dts

    Regards,
    Pavel

  • Hi Pavel,

    Thanks so much for your support.

    We will try to do that and let you know result later.

    Thanks and Best Regard.
    Thinh Nguyen.
  • Hi Pavel,

    I used to the latest AM335x TI PSDK v4.01, which comes with kernel 4.9.41 as your recommendation.

    - After booting, the TLV320AIC module seem to detect:

    root@beaglebone:~# aplay -l

    **** List of PLAYBACK Hardware Devices ****

    card 0: TLV320AIC32X4 [TI TLV320AIC32X4], device 0: AIC32X tlv320aic32x4-hifi-0 []

     Subdevices: 0/1

     Subdevice #0: subdevice #0

    - I try to set I2S MODE via I2C bus but it failed. Logs is:

    root@beaglebone:~# i2cset -y 2 0x18 0x22 0x20

    Error: Could not set address to 0x18: Device or resource busy

    - How do i set I2S Mode interface with TLV320AIC?

    - I supplied 11,2898 MHz clock to TLV320AIC MCLK pin. I want to set WCLK is 44,1 KHz, BCLK is 1,4112 MHz (16 bit stereo, 2 channels). How do i set WCLK and BCLK?

    - Please see log file as below:

    root@beaglebone:~# dmesg | grep tlv

    [   18.095176] tlv320aic32x4 2-0018: Failed getting the mclk. The current implementation does not support the usage ofk

    [   23.028420] davinci_evm sound: tlv320aic32x4-hifi <-> 48038000.mcasp mapping ok

    root@beaglebone:~# dmesg | grep sound

    [   22.405119] davinci_evm sound: ASoC: DAPM unknown pin MONO_LOUT

    [   22.602224] davinci_evm sound: ASoC: DAPM unknown pin HPLCOM

    [   22.807010] davinci_evm sound: ASoC: DAPM unknown pin HPRCOM

    [   23.028420] davinci_evm sound: tlv320aic32x4-hifi <-> 48038000.mcasp mapping ok

    [   23.150948] davinci_evm sound: ASoC: no source widget found for HPLOUT

    [   23.157679] davinci_evm sound: ASoC: Failed to add route HPLOUT -> direct -> Headphone Jack

    [   23.166157] davinci_evm sound: ASoC: no source widget found for HPROUT

    [   23.172745] davinci_evm sound: ASoC: Failed to add route HPROUT -> direct -> Headphone Jack

    [   23.181163] davinci_evm sound: ASoC: no sink widget found for LINE1L

    [   23.187569] davinci_evm sound: ASoC: Failed to add route Line In -> direct -> LINE1L

    [   23.195371] davinci_evm sound: ASoC: no sink widget found for LINE1R

    [   23.201776] davinci_evm sound: ASoC: Failed to add route Line In -> direct -> LINE1R

    root@beaglebone:~# aplay -l

    **** List of PLAYBACK Hardware Devices ****

    card 0: TLV320AIC32X4 [TI TLV320AIC32X4], device 0: AIC32X tlv320aic32x4-hifi-0 []

     Subdevices: 1/1

     Subdevice #0: subdevice #0

    - Please see my dts file as below:

    /*

    * Copyright (C) 2012 Texas Instruments Incorporated - 

    *

    * This program is free software; you can redistribute it and/or modify

    * it under the terms of the GNU General Public License version 2 as

    * published by the Free Software Foundation.

    */

    /dts-v1/;

    #include "am33xx.dtsi"

    #include "am335x-bone-common.dtsi"

    /* pruss: pick one: */

    /*

    * /etc/modprobe.d/pruss-blacklist.conf

    *

    * blacklist uio_pruss

    */

    /* #include "am33xx-pruss-rproc.dtsi" */

    /*

    * /etc/modprobe.d/pruss-blacklist.conf

    *

    * blacklist pruss

    * blacklist pruss_intc

    * blacklist pru-rproc

    */

    /* #include "am33xx-pruss-uio.dtsi" */

    / {

    model = "TI AM335x BeagleBone Black";

    compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";

    };

    &ldo3_reg {

    regulator-min-microvolt = <1800000>;

    regulator-max-microvolt = <1800000>;

    regulator-always-on;

    };

    &mmc1 {

    vmmc-supply = <&vmmcsd_fixed>;

    };

    &mmc2 {

    vmmc-supply = <&vmmcsd_fixed>;

    pinctrl-names = "default";

    pinctrl-0 = <&emmc_pins>;

    bus-width = <8>;

    status = "okay";

    };

    &cpu0_opp_table {

    /*

    * All PG 2.0 silicon may not support 1GHz but some of the early

    * BeagleBone Blacks have PG 2.0 silicon which is guaranteed

    * to support 1GHz OPP so enable it for PG 2.0 on this board.

    */

    oppnitro@1000000000 {

    opp-supported-hw = <0x06 0x0100>;

    };

    };

    &am33xx_pinmux {

    mcasp0_pins: mcasp0_pins {

    pinctrl-single,pins = <

    AM33XX_IOPAD(0x9ac, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_ahcklx.mcasp0_ahclkx */

    AM33XX_IOPAD(0x994, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx */

    AM33XX_IOPAD(0x990, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx */

    AM33XX_IOPAD(0x998, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0.mcasp0_axr0 */

    AM33XX_IOPAD(0x9a8, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr1.mcasp0_axr1 */

    >;

    };

    };

    &i2c2 {

    pinctrl-names = "default";

    pinctrl-0 = <&i2c2_pins>;

    status = "okay";

    clock-frequency = <100000>;

    tlv320aic32x4: tlv320aic32x4@18 {

    #sound-dai-cells = <0>;

    compatible = "ti,tlv320aic32x4";

    reg = <0x18>;

    };

    };

    &mcasp0 {

    #sound-dai-cells = <0>;

    pinctrl-names = "default";

    pinctrl-0 = <&mcasp0_pins>;

    status = "okay";

    op-mode = <0>; /* MCASP_IIS_MODE */

    tdm-slots = <2>; /* Indicates number of channels transmitted or received over oneserializer. */

    serial-dir = </* 0: INACTIVE, 1: TX, 2: RX */

    1 0 0 0

    >;

    tx-num-evt = <32>;

    rx-num-evt = <32>;

    };

    / {

    sound {

    compatible = "ti,tlv320aic32x4-evm-audio";

    ti,model = "TI TLV320AIC32X4";

    ti,audio-codec = <&tlv320aic32x4>;

    ti,mcasp-controller = <&mcasp0>;

    ti,codec-clock-rate = <24000000>;

    ti,widgets =

    "Headphone", "Headphone Jack",

    "Line", "Line In";

    ti,audio-routing =

    "Headphone Jack",       "HPLOUT",

    "Headphone Jack",       "HPROUT",

    "LINE1L",               "Line In",

    "LINE1R",               "Line In";

    };

    };

  • THINH Nguyen said:

    - I try to set I2S MODE via I2C bus but it failed. Logs is:

    root@beaglebone:~# i2cset -y 2 0x18 0x22 0x20

    Error: Could not set address to 0x18: Device or resource busy

    - How do i set I2S Mode interface with TLV320AIC?

    I would suggest you first to try with i2cdetect tool. Check also if the AM335x I2C and external AIC32x codec clocks are enabled.

    Regarding I2C tools usage, you can check the below wiki pages:

    THINH Nguyen said:

    &i2c2 {

    pinctrl-names = "default";

    pinctrl-0 = <&i2c2_pins>;

    status = "okay";

    clock-frequency = <100000>;

    tlv320aic32x4: tlv320aic32x4@18 {

    #sound-dai-cells = <0>;

    compatible = "ti,tlv320aic32x4";

    reg = <0x18>;

    };

    };

    You are missing "status=okay" and x-supply entries. Refer to am335x-evmsk.dts and tlv320aic32x4.txt files.

    Regards,
    Pavel

  • THINH Nguyen said:
    I supplied 11,2898 MHz clock to TLV320AIC MCLK pin. I want to set WCLK is 44,1 KHz, BCLK is 1,4112 MHz (16 bit stereo, 2 channels). How do i set WCLK and BCLK?

    From what I understand, you need to supply MCLK/BCLK/WCLK from AM335x McASP to AIC32x codec? In this case McASP is master, AIC32x is slave.

    Regards,
    Pavel

  • For more info regarding master/slave configuration of the McASP clock signals, refer to the below doc:

    www.ti.com/.../sprac09a.pdf

    5.2 Data Format and Clocking
  • Hi Pavel,

    Thanks for your strong support.

    My board is worked well .

    Thanks.
    thinh Nguyen