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.

TLV320DAC32: Problem with linux driver and device tree

Part Number: TLV320DAC32

I have a problem with linux driver for tlv320dac32. As mentioned in this post https://e2e.ti.com/support/audio-group/audio/f/audio-forum/654414/linux-tlv320dac32-tlv320dac32-linux-drivers-apply I used tlv320aic3x-i2c driver for my device. I enabled it as a module in kernel config. I created device tree:

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

        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_tlv32>;
        reset-gpios = <&gpio3 20 GPIO_ACTIVE_LOW>;

        AVDD-supply = <&regulator>;
        IOVDD-supply = <&regulator>;
        DRVDD-supply = <&regulator>;
    };
};

I can see that driver is registered:

[    6.080843] i2c i2c-2: of_i2c: register /soc@0/bus@30800000/i2c@30a40000/tlv320aic3x@18
[    6.099482] i2c i2c-2: client [tlv320aic3x] registered with bus id 2-0018
[   12.267136] i2c-core: driver [tlv320aic3x] registered

And I can also detect device using i2cdetect command, but it looks like driver is never attached to a device. It looks like it does not recognize it. I put some debug printk and it looks like probe function is never called.

Is there something wrong with my configuration?

  • Hi Borys,

    Our software driver experts will take a look at your problem description. Please allow a couple of days so they provide further comments.

    Best regards,
    -Ivan Salazar
    Applications Engineer

  • Can you offer more project information? Which platform? Kernel Version?

    Per your description, you have not set the sound card in dts file. See the attachment for detail.

    sound card register.pptx

  • I'm working on IMX8MM. Kernel version 5.15.

    I had sound card set before, but it was not working so I tried smaller steps and tried only tlv320dac32 settings/driver and thought that driver would recognize device at least or I would see some messages in dmesg. Should it do something without sound card set or is it required for even probe tlv32?


    Here you have my dts with sound card:

    sound-tlv320aic3x {
        compatible = "simple-audio-card";
        simple-audio-card,name = "TLV320DAC32";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&codec1>;
        simple-audio-card,frame-master = <&codec1>;
        simple-audio-card,widgets = "Buzzer";
        simple-audio-card,routing =
            "Buzzer", "SPR";
        simple-audio-card,cpu {
        sound-dai = <&sai3>;
        };
    };
        
    codec1: simple-audio-card,codec {
        sound-dai = <&tlv320aic3x>;
        system-clock-frequency = <&clk IMX8MM_CLK_SAI3_ROOT>;
    };

    &sai3 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai3>;
        status = "okay";

        assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
        assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
        assigned-clock-rates = <12000000>;
    };

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

            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_tlv32>;
            reset-gpios = <&gpio3 20 GPIO_ACTIVE_LOW>;

            AVDD-supply = <&reg>;
            IOVDD-supply = <&reg>;
            DRVDD-supply = <&reg>;
        };
    };



  • Can you share the original dts with me? One more question, do you set the TLV320DAC32 as MASTER or SLAVE?

  • What do you mean by original dts? I have custom board and own dts. I'm including https://github.com/torvalds/linux/blob/v5.15/arch/arm64/boot/dts/freescale/imx8mm.dtsi and in other dtsi file I have i2c3 enabled:

    &i2c3 {
        clock-frequency = <100000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c3>;
        status = "okay";
    };

    About master/slave settings I haven't seen that settings in dts example or some other place and I haven't done any register read/write operations myself, I thought that's the driver job to setup device.

  • I've got some progress. I deleted,
            AVDD-supply = <&regulator>;
            IOVDD-supply = <&regulator>;
            DRVDD-supply = <&regulator>;

    part. Now I've got some error about dummy regulator:

    [   13.248007] tlv320aic3x 2-0018: supply IOVDD not found, using dummy regulator
    [   13.259241] tlv320aic3x 2-0018: supply DVDD not found, using dummy regulator
    [   13.276491] tlv320aic3x 2-0018: supply AVDD not found, using dummy regulator
    [   13.283680] tlv320aic3x 2-0018: supply DRVDD not found, using dummy regulator
    [   13.297426] tlv320aic3x 2-0018: Invalid supply voltage(s) AVDD: -22, DVDD: -22

    but device is probed and registered. I can see `UU` on address 0x18 when i2cdetect -y 2 is called

  • In your new DTS, have the sound card registered?

  • Unfortunately not. I think I have to work on sai3 part of the DTS. But at least tlv320dac32 works as expected at this point

  • imx8mm.dtsi is only the header file, which file is the DTS file?

  • sound-tlv320aic3x {
        compatible = "simple-audio-card";
        simple-audio-card,name = "TLV320DAC32";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&codec1>;
        simple-audio-card,frame-master = <&codec1>;
        simple-audio-card,widgets = "Buzzer";
        simple-audio-card,routing =
            "Buzzer", "SPR";
        simple-audio-card,cpu {
        sound-dai = <&sai3>;
        };

        codec1: simple-audio-card,codec {
        sound-dai = <&tlv320aic3x>;
        system-clock-frequency = <&clk IMX8MM_CLK_SAI3_ROOT>;
        };
    };

    Put codec 1 into sound-tlv320aic3x, and try it

  • I have my own dts file as it's a custom board. I shared already part of it above. There are no more stuff related to tlv32 or sai there

  • there is one more, but only this part would be relevant to the issue:

    &i2c3 {
        clock-frequency = <100000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c3>;
        status = "okay";
    };

  • &i2c3 {
        clock-frequency = <100000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c3>;
        status = "okay";

    #address-cells=<1>;
    #size-cells=<0>;

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

            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_tlv32>;
            reset-gpios = <&gpio3 20 GPIO_ACTIVE_LOW>;

            AVDD-supply = <&reg>;
            IOVDD-supply = <&reg>;
            DRVDD-supply = <&reg>;
        };
    };

    sound-tlv320aic3x {
        compatible = "simple-audio-card";
        simple-audio-card,name = "TLV320DAC32";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&codec1>;
        simple-audio-card,frame-master = <&codec1>;
        simple-audio-card,widgets = "Buzzer";
        simple-audio-card,routing =
            "Buzzer", "SPR";

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

        codec1: simple-audio-card,codec {
        sound-dai = <&tlv320aic3x>;
        system-clock-frequency = <&clk IMX8MM_CLK_SAI3_ROOT>;
        };

    };
    };

    try this

  • This actually helped. I had to also change widgets, because it was wrong.
    simple-audio-card,widgets =
        "Speaker", "Left HP Out";
    simple-audio-card,routing =
        "Left HP Out", "HPLOUT";

    I can see card0 under /sys/class/sound

    I do not have sound yet, but it feels like I'm almost there.

  • Looking forward to more good news from you.

  • Hi, I make it work finally. I had to change codec settings and setup clock:

    codec1: simple-audio-card,codec {
    	sound-dai = <&tlv320aic3x>;
    	clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
    };

    and also widgets routing settings:
    simple-audio-card,widgets = 
    	"Headphone", "Right HP Out";
    simple-audio-card,routing =
    	"Right HP Out", "HPROUT";


    Now I can get sound using
    speaker-test -f 1000 -t sine 


    Just one thing I had to do is increase these settings values using alsamixer
    PCM, HP, HP DAC, RIGHT HP MIXER DACR1


    Does it look okay or could I do something more in DTS? I'm not sure if my routing is good, but if it works then I think so.

  • Hi Borys,

    I'll check this with our software experts and give you some feedback early next week.

    Best regards,
    -Ivan Salazar
    Applications Engineer

  • In my view, the widgets are mainly defined in the code. They can be ignored in DTS.

    Do you have some abnormal if you removed the widgets in DTS?

  • I deleted widgets and everything works great. With widgets defined in DTS  I had message about widgets being overwritten, so you were right.

    I think this thread might be closed now.

    Once again thank you for your support.