TLV320AIC3107 on an i.MX6QP (EDM1-IMX6PLUS)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TLV320AIC3107 on an i.MX6QP (EDM1-IMX6PLUS)

1,925 Views
slav_slavov
Contributor I

Our HW team decided to use the TI Audio Codec TLV320AIC3107 on one of the boards (utilizing EDM1-IMX6PLUS module from TechNexion) mainly because of the Class D amplifier. I tried to use the  /sound/soc/codecs/tlv320aic3x.c  codec and the /sound/soc/fsl/imx-tlv320aic3x.c machine driver. In the DTS file, the codec was configured to be compatible with tlv320aic3007 (3007 and 3107 are similar and the functionality I need is covered by the 3007 driver). All power supplies are connected directly to the power sources and we are using a gpio pin to drive the reset pin (gpio6 3)

The first issue was that the following message was shown during boot:

tlv320aic3x-codec 2-0018: Failed to init class D: -5

Attaching an oscilloscope to the i2c lines and the reset pin showed that the reset was always set to 0 during boot up. I found out that in the “probe” function, the reset pin was only configured to output but its value was never set. So I made the following two modifications to release the RESET in the probe function and to activate it on power down:

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 76bc41b..d805b74 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1370,6 +1370,12 @@
         regcache_cache_only(aic3x->regmap, true);
         ret = regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies),
                          aic3x->supplies);
+
+        if (gpio_is_valid(aic3x->gpio_reset)) {
+            udelay(1);
+            gpio_set_value(aic3x->gpio_reset, 0);
+        }
+
     }
 out:
     return ret;
@@ -1758,6 +1764,9 @@
         if (ret != 0)
             goto err;
         gpio_direction_output(aic3x->gpio_reset, 0);
+        gpio_set_value(aic3x->gpio_reset, 0);
+        udelay(1);
+        gpio_set_value(aic3x->gpio_reset, 1);
     }

     for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)


This removed the “Failed to init class D: -5" error message but when trying to play a simple wav file "aplay Front_Center.wav", the command just hung and never finished. Trying different settings in the DTS didn’t help and I tried to look for another machine driver. Luckily I found an alternative machine driver which worked out of the box:
https://github.com/Ansync/kernel-tgif/blob/master/sound/soc/fsl/imx-tlv320aic3x.c

The DTS settings are:

/ {
    sound {
        compatible = "fsl,imx-audio-tlv320aic3x";
        model = "tlv320aic3007";
        ssi-controller = <&EDM1_AUD_I2S_CHANNEL>;
        cpu-dai = <&EDM1_AUD_I2S_CHANNEL>;
        audio-codec = <&codec>;
        audio-routing =
            "Ext Spk", "SPOP",
            "Ext Spk", "SPOM",
            "Line Out Jack", "LLOUT",
            "Line Out Jack", "RLOUT";

        mux-int-port = <EDM1_AUD_MUX_INT>;
        mux-ext-port = <EDM1_AUD_MUX_EXT>;
    };
};


&i2c3 {
    status = "okay";

    codec: tlv320aic310x@18 {
        compatible = "ti,tlv320aic3007";
        reg = <0x18>;
        gpio-reset = <&gpio6 3 GPIO_ACTIVE_LOW>;
        clocks = <&EDM1_AUD_CLK_SRC>;
        status = "okay";
    };

};

&ssi1 {
        fsl,mode = "i2s-master";
        status = "okay";
};


Finally sound was played out of the speaker. The picture below is a snapshot of the oscilloscope screen. The signals are:
-    The Analog line is the audio output
-    Digital 4 is i2c clock
-    Digital 5 is i2c data
-    Digital 6 is the reset pin

Scope.png

0 Kudos
2 Replies

1,076 Views
nguyenmr
Contributor III

Hi Slav,

can you show me driver: /sound/soc/codecs/tlv320aic3x.c?

i use TLV320AIC3105 codec on iMX6Q, i also use your machine driver :

https://github.com/Ansync/kernel-tgif/blob/master/sound/soc/fsl/imx-tlv320aic3x.c

but when playing music, i see only have MCLK, don't have clock  on BCLK, WCLK, TXC

my issue here: https://community.nxp.com/thread/460769 

Thank you!

BR/Nguyen

0 Kudos

1,076 Views
igorpadykov
NXP Employee
NXP Employee

Hi Slav

thank for sharing this experience as it may help other customers

working with TLV320AIC3107.

Best regards
igor

0 Kudos