Audio codec interfacing issue with NXP's i.mx6ULL EVK SAI3

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

Audio codec interfacing issue with NXP's i.mx6ULL EVK SAI3

5,495 Views
srishan
Contributor III

Dear Technical support team,

Firstly I would like to thank for all your quick responses for my queries posted adn really appreciate the same.

I am using NXP i.MX6ULL EVK with NXP's fsl-yocto-L4.9.11_1.0.0.tar yocto BSP's, and trying to interface with TLV320AIC3105 using SAI3 interface, as part of the initial audio codec bringup am unable to get the playback up and running (unable to get MCLK, BCLK, LRCLK and data on SAI_TXD_LCD_DATA15), with SAI3 port being configured as I2S port to TLV320AIC3105 with I2C2 as the control interface

I have even tried following the below community links which uses SSI interfaces, I also tried using WM8960 as the reference it didn't help me,

https://community.nxp.com/thread/323017
https://community.nxp.com/thread/380454
https://community.nxp.com/thread/454745
https://community.nxp.com/thread/462200
https://community.nxp.com/message/970452?commentID=970452#comment-970452
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/286072.html

Mainly I am unable to verify the i2c read/write transfers to TLV320AIC3105 with 4.7k pullup resistors being added

1. Could you please let me know how the i2c controller module/ i2c adapter driver can be tested?, I tried the attached devmem2 it failed to work

root@imx6ull14x14evk:/# devmem2 0x21A0000
/dev/mem opened.
Error at line 86, file devmem2.c (1) [Operation not permitted]
root@imx6ull14x14evk:/#

whereas, I was able to access other register using devmem for example as shown below
root@imx6ull14x14evk:/# devmem2 0x21EC08C w 0x00008200
/dev/mem opened.
Memory mapped at address 0x76f80000.
Value at address 0x21EC08C (0x76f8008c): 0x8000
Written 0x8200; readback 0x8000  

2. As part of the first stage bringup can the I2c read/write can be verified with just only the reset and i2c_scl and i2c SDA using i2c tools -  ie., i2cdetect, i2cset, i2cget, i2cdump without connecting MCLK, BCLK, LRCLK, and DATA_IN and DATA_out from processor?

3. If we are interfacing when only with SAI3 interface, do we really need to consider asrc-controller = <&asrc>; and gpr = <&gpr 4 0x100000 0x100000>; related configuration?? as I have not included this configuration in my DTS and machine driver file?

4. Where can I find SAI related register info in I.mX6ull technical refernce manual?

5. When I type amixer I see, "amixer: Mixer default load error: No such device or address" may I know whay am seeing this issue?

6.  Could you please help me to provide with solutions for the issue numbers listed below?

7. Could you please verify the machine driver file attached and confirm whether that works for fsl-yocto-L4.9.11?

I have hereby attached the device tree file, machine driver file and codec driver file and the portion of the schematics and devmem2 appln for directly read and write to the I2C2 controller module and SAI3 controller module


DT configuration:

    pinctrl_sai3: sai3grp {
        fsl,pins = <
            MX6UL_PAD_LCD_DATA13__SAI3_TX_BCLK      0x130b0
            MX6UL_PAD_LCD_DATA12__SAI3_TX_SYNC      0x130b0
            MX6UL_PAD_LCD_DATA15__SAI3_TX_DATA      0x110b0
            MX6UL_PAD_LCD_DATA14__SAI3_RX_DATA      0x130b0
            MX6UL_PAD_LCD_DATA09__SAI3_MCLK            0x130b0
        >;
    };


    pinctrl_i2c2: i2c2grp {
        fsl,pins = <
            MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0
            MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0
        >;
    };

/*TO BE CHECKED LATER*/
        reg_3p3v: regulator@2 {
            compatible = "regulator-fixed";
            reg = <2>;
            regulator-name = "3P3V";
            regulator-min-microvolt = <3300000>;
            regulator-max-microvolt = <3300000>;
            regulator-boot-on;
            regulator-always-on;
        };

        reg_1p8v: regulator@3 {
            compatible = "regulator-fixed";
            reg = <0>;
            regulator-name = "1P8V";
            regulator-min-microvolt = <1800000>;
            regulator-max-microvolt = <1800000>;
            regulator-boot-on;
            regulator-always-on;
        };
    };

    sound {
        compatible = "fsl,imx-audio-tlv320";
        model = "imx-tlv320";
        cpu-dai = <&sai3>;
        audio-codec = <&tlv320aic3105>;
        /*asrc-controller = <&asrc>;*/        /*TO BE CHECKED LATER */
        /*codec-master;*/                     /*TO BE CHECKED LATER */
        /*gpr = <&gpr 4 0x100000 0x100000>;*/     /*TO BE CHECKED LATER */
        audio-routing =

                "Headphone Jack",    "HPLOUT",
                "Headphone Jack",    "HPROUT",
                "LINE1L",        "Mic Jack",
                "LINE2L",        "Mic Jack";

        /*mux-int-port = <2>;*/            /*TO BE CHECKED LATER */
        /*mux-ext-port = <5>; */        /*TO BE CHECKED LATER */
    };

&i2c2 {
    clock_frequency = <100000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c2>;
    status = "okay";

    codec: wm8960@1a {
        compatible = "wlf,wm8960";
        reg = <0x1a>;
        clocks = <&clks IMX6UL_CLK_SAI2>;
        clock-names = "mclk";
        wlf,shared-lrclk;
    };

    tlv320aic3105: tlv320aic3x@18 {
        compatible = "ti,tlv320aic3x";
        reg = <0x18>;
        gpio-reset = <&gpio5 4 GPIO_ACTIVE_LOW>;
        clocks = <&clks IMX6UL_CLK_SAI3>;
        ai3x-micbias-vg = <2>;     /* MICBIAS_2_5V */
        /* clock-names = "mclk"; */                 /*TO BE CHECKED LATER*/
        status = "okay";

        clock-frequency = <12000000>;               /*TO BE CHECKED LATER*/
        /* Regulators */
        DRVDD-supply = <&reg_3p3v>;                 /*TO BE CHECKED LATER*/
        AVDD-supply = <&reg_3p3v>;                  /*TO BE CHECKED LATER*/
        IOVDD-supply = <&reg_3p3v>;                 /*TO BE CHECKED LATER*/
        DVDD-supply = <&reg_1p8v>;                  /*TO BE CHECKED LATER*/
    };

logs:

root@imx6ull14x14evk:/# i2cdetect -y -a -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
root@imx6ull14x14evk:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: imxtlv320 [imx-tlv320], device 0: HiFi tlv320aic3x-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@imx6ull14x14evk:/#
root@imx6ull14x14evk:/# aplay -Dplughw:0,0 a2002011001-e02-8kHz.wav
Playing WAVE 'a2002011001-e02-8kHz.wav' : Signed 16 bit Little Entlv320aic3x-codec 1-0018: Unable to sync registers 0x1-0x2. -11 -------------------> ISSUE NO. 1
dian, Rate 8000 Hz, Stereo
aplay: pcm_write:2023: write error: Input/output error
root@imx6ull14x14evk:/#
root@imx6ull14x14evk:/# aplay a2002011001-e02-8kHz.wav                                                                                         
tlv320aic3x-codec 1-0018: Unable to sync registers 0x4-0x8. -6 -----------------------------------------------> ISSUE NO. 2
Playing WAVE 'a2002011001-e02-8kHz.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
^CAborted by signal Interrupt...
aplay: pcm_write:2023: write error: Interrupted system call
root@imx6ull14x14evk:/#
root@imx6ull14x14evk:/#
root@imx6ull14x14evk:/# amixer
amixer: Mixer default load error: No such device or address --------------------------------------------------------------> ISSUE NO. 3
root@imx6ull14x14evk:/#
root@imx6ull14x14evk:/# i2cget -f -y 1 0x18 0x5 --------------------------------------------------------------> ISSUE NO. 4
Error: Read failed
 
root@imx6ull14x14evk:/# cat /proc/asound/cards
 0 [imxtlv320      ]: imx-tlv320 - imx-tlv320
                      imx-tlv320
root@imx6ull14x14evk:/# cat /proc/asound/devices
  0: [ 0]   : control
 16: [ 0- 0]: digital audio playback                    
 24: [ 0- 0]: digital audio capture                     
 33:        : timer                                    
root@imx6ull14x14evk:/# cat /proc/asound/card0/id       
imxtlv320                                               
root@imx6ull14x14evk:/#
root@imx6ull14x14evk:/# i2cdump -f -y 1 0x18 --------------------------------------------------------------> ISSUE NO. 5
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
root@imx6ull14x14evk:/#


Kindly do the needful, as early as possible, as I am stuck with this from past two weeks wondering whether I can really get clues from anywhere?
Eagerly Many thanks in advance,

Labels (3)
0 Kudos
10 Replies

3,537 Views
igorpadykov
NXP Employee
NXP Employee

Hi Sri

for i2c test one also can try unit tests

imx-test
www.nxp.com/lgfiles/NMG/MAD/YOCTO/imx-test-5.7.tar.gz

Example sai2 with wm8960 :

imx6ul-14x14-evk.dts\dts\boot\arm\arch - linux-imx - i.MX Linux kernel 

Linux audio support is described in Chapter 28 Advanced Linux Sound Architecture

(ALSA) System on a Chip (ASoC) Sound Driver attached Linux Manual.

I believe asrc is needed for sound drivers.

SAI is described in Chapter 45 Synchronous Audio Interface (SAI) i.MX6ULL Reference Manual

http://www.nxp.com/docs/en/reference-manual/IMX6ULLRM.pdf 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

3,537 Views
srishan
Contributor III

In wm8960, Does MCLK is generated by codec or SAI2 controller?

0 Kudos

3,536 Views
igorpadykov
NXP Employee
NXP Employee

MCLK is generated by SAI2

0 Kudos

3,537 Views
srishan
Contributor III

May I know atleast who is generating the BCLK, LRCLK is that SAI3 or WM8960 incase of I.MX6ull evk?

Kindly do the needful as early as possible

0 Kudos

3,537 Views
igorpadykov
NXP Employee
NXP Employee

Hi Sri

please check sect.45.3.1 SAI clocking i.MX6ULL Reference Manual 

http://www.nxp.com/docs/en/reference-manual/IMX6ULLRM.pdf 

If generated internally, clocks produced from SAx_CLK_ROOT.

Best regards
igor

0 Kudos

3,537 Views
srishan
Contributor III

Before I get into the depth of SAI clocking whatever you have suggested below, May I know who is generating the BCLK, LRCLK is that SAI3 or WM8960 incase of I.MX6ull evk?

please check sect.45.3.1 SAI clocking i.MX6ULL Reference Manual 

http://www.nxp.com/docs/en/reference-manual/IMX6ULLRM.pdf 

If generated internally, clocks produced from SAx_CLK_ROOT.

Also requesting you to share the SAI2 register settings after validating wm8960 in i.mx6ull evk, as I dont have the debugger right now

Requesting to respond quickly

0 Kudos

3,537 Views
srishan
Contributor III

Hi Igor,

Thanks for your quick responses,

I have hereby attached the waveforms and the audio wav files 

1. I see the mclk is 12.92Mhz is this correct, where we are doing this configuration in device tree for SAI2?

2. Could you please let me know why I am seeing the bitclock as 1.47Mhz instead of as it was supposed to be 16x2x8Khz = 256Khz for 16khz wavfile and 16x2x16 = 512Khz

3. AND the wclk was supposed to be 8khz when I play 8Khz wav file and 16Khz when i play 16khz wav file, but why I am seeing wclk as 44.09Khz for both 8khz and 16Khz wav file when it is played?

4. Kindly do the needful as early as possible, as am unable to get MCLK as high priority with SAi3 being interfaced to tlv320aic3105 codec, am wondering what could be the issue?

5. Is codec is generating the WCLK and BCLK after once SAI2 generates MCLK in case of WM8960?

6. Could you please confirm the below drive strength values related info tlv320aic3105 codec is correct for driving SAI3 signals?

    pinctrl_sai3: sai3grp {
        fsl,pins = <
            MX6UL_PAD_LCD_DATA13__SAI3_TX_BCLK      0x130b0
            MX6UL_PAD_LCD_DATA12__SAI3_TX_SYNC      0x130b0
            MX6UL_PAD_LCD_DATA15__SAI3_TX_DATA      0x110b0 
            MX6UL_PAD_LCD_DATA14__SAI3_RX_DATA      0x130b0
            MX6UL_PAD_LCD_DATA09__SAI3_MCLK            0x130b0
        >;
    };

Many thanks in advance,

Eagerly awaiting for your replies  

0 Kudos

3,537 Views
srishan
Contributor III

Dear Igor ,

Could you please any inputs w.r.t the above query?

Kindly do the needful as early as possible

As am stuck with this issue from past 2 weeks still am unable to get the MCLK from SAI3

Eagerly awaiting for your replies

Many Thanks in advance

0 Kudos

3,537 Views
igorpadykov
NXP Employee
NXP Employee

Hi Shan

sai2 is used on i.MX6ULL EVK, dts file below

imx6ull-14x14-evk.dts\dts\boot\arm\arch - linux-imx - i.MX Linux kernel 

So you can check its registers with jtag with demo images from

i.MX Software|NXP 

Then compare them with sai3 settings.

Best regards
igor

3,537 Views
srishan
Contributor III

Dear Igor,

As I dont have the jtag with me right now, meanwhile I ll try to procure the same

Requesting you to provide concrete inputs for the below:

For time being, I am trying to use as the reference sgtl5000 (imx6ul-tx6ul.dtsi:246:      "simple-audio-card";), as the reference, so that I can try to use the generic machine driver configurations as used for sgtl5000 for tlv320aic3105 also, so that it tries me to avoid writing separate machine driver file for ex: imx-tlv320 or so

1.

sound {
compatible = "karo,imx6ul-tx6ul-sgtl5000",
"simple-audio-card";
simple-audio-card,name = "imx6ul-tx6ul-sgtl5000-audio";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&codec_dai>;
simple-audio-card,frame-master = <&codec_dai>;
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Line", "Line In",
"Line", "Line Out",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
"MIC_IN", "Mic Jack",
"Mic Jack", "Mic Bias",
"Headphone Jack", "HP_OUT";

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

codec_dai: simple-audio-card,codec {
sound-dai = <&sgtl5000>;
};
};

clocks {
mclk: mclk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <26000000>;
};
};


sgtl5000: codec@0a {
compatible = "fsl,sgtl5000";
reg = <0x0a>;
#sound-dai-cells = <0>;
VDDA-supply = <&reg_2v5>;
VDDIO-supply = <&reg_3v3>;
clocks = <&mclk>;
};


sgtl5000: codec@0a {
compatible = "fsl,sgtl5000";
reg = <0x0a>;
#sound-dai-cells = <0>;
VDDA-supply = <&reg_2v5>;
VDDIO-supply = <&reg_3v3>;
clocks = <&mclk>; -------------------------------------->Could you please let me know is this MCLK is generated by SAI2 or by SGTL5000 codec ??
};

-------------------------------------------------------------------

2.

My SAI3 with the machine driver related configurations for tlv320aic3105 , may I know what am I doing wrong w.r.t the below configurations w.r.t SAI3 to get the MCLK as the first step

sound {
compatible = "simple-audio-card";
simple-audio-card,name = "OnboardTLV320AIC3105";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&dailink_master>;
simple-audio-card,frame-master = <&dailink_master>;
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Line", "Line In",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
"Headphone Jack", "HPLOUT",
"Headphone Jack", "HPROUT",
"Mic Jack", "Mic Bias",
"LINE1L", "Line In",
"LINE2L", "Line In";

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

dailink_master: simple-audio-card,codec {
sound-dai = <&codec>;
system-clock-frequency = <12000000>;
};
};

&sai3 {
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>;
status = "okay";
};

pinctrl_sai3: sai3grp {
fsl,pins = <
#if 1
MX6UL_PAD_LCD_DATA13__SAI3_TX_BCLK 0x130b0
MX6UL_PAD_LCD_DATA12__SAI3_TX_SYNC 0x130b0
MX6UL_PAD_LCD_DATA15__SAI3_TX_DATA 0x110b0 /*if this doesn't work revert back to 0x130b0 */
MX6UL_PAD_LCD_DATA14__SAI3_RX_DATA 0x130b0
MX6UL_PAD_LCD_DATA09__SAI3_MCLK 0x130b0
#endif
>;
};

codec: tlv320@18 {
compatible = "ti,tlv320aic3x";
#sound-dai-cells = <0>;
reg = <0x18>;
/*gpio-reset = <&gpio5 4 GPIO_ACTIVE_LOW>;*/
ai3x-micbias-vg = <2>;

AVDD-supply = <&sound_3v3>;
IOVDD-supply = <&sound_3v3>;
DRVDD-supply = <&sound_3v3>;
DVDD-supply = <&sound_1v8>;

clocks = <&mclk>;

};

clocks {
mclk: mclk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <26000000>;
};
};

root@imx6ull14x14evk:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: OnboardTLV320AI [OnboardTLV320AIC3105], device 0: 2030000.sai-tlv320aic3x-hifi tlv320aic3x-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
root@imx6ull14x14evk:/# aplay a2002011001-e02-8kHz.wav
printing before writing /reading ldac_reg 28
aic3x_mute LDAC_VOL NOT MUTE!!!!!!!!!!!!!!! 28
printing before writing /reading rdac_reg 28
aic3x_mute RDAC_VOL NOT MUTE!!!!!!!!!!!!!!! 28
Playing WAVE 'a2002011001-e02-8kHz.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo

-------------------------------------------------------------------

3. Can you please share  me sai3 settings, that you have used with sgtl5000?

Kindly do the needful as early as possible

Many Thanks in advance,

Eagerly awaiting for your replies

0 Kudos