Device tree audio codec steup

Hi

We are adding an audio codec to our design NX module design. I have created the device tree, but having a problem the assignment of #sound-dai-cells = <?>

We are using i2s as shown below:
tegra_i2s3: i2s@2901200 {
compatible = “nvidia,tegra210-i2s”;
reg = <0x0 0x2901200 0x0 0x100>;
nvidia,ahub-i2s-id = <2>;
clocks = <&bpmp_clks TEGRA194_CLK_I2S3>,
<&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
<&bpmp_clks TEGRA194_CLK_I2S3_SYNC_INPUT>,
<&bpmp_clks TEGRA194_CLK_SYNC_I2S3>,
<&bpmp_clks TEGRA194_CLK_I2S3_SYNC_INPUT>;
clock-names = “i2s”, “i2s_clk_parent”, “ext_audio_sync”,
“audio_sync”, “clk_sync_input”;
assigned-clocks =
<&bpmp_clks TEGRA194_CLK_I2S3>;
assigned-clock-parents =
<&bpmp_clks TEGRA194_CLK_PLLA_OUT0>;
assigned-clock-rates = <1536000>;
fsync-width = <31>;
status = “disabled”;
};

I am including the above definition (tegra_i2s3) into the following sound node (see the ***):
mysound {
compatible = “simple-audio-card”;
simple-audio-card,name = “My-Sound-Card”;
simple-audio-card,format = “i2s”;
simple-audio-card,widgets =
“Microphone”, “Microphone Jack”,
“Headphone”, “Headphone Jack”,
“Speaker”, “External Speaker”;
simple-audio-card,routing =
“MIC_IN”, “Microphone Jack”,
“Headphone Jack”, “HP_OUT”,
“External Speaker”, “LINE_OUT”;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <8>;

            /* CPU DAI interface */
            simple-audio-card,cpu {
                    #sound-dai-cells = <1>;
                    ***sound-dai = <&tegra_i2s3>;   //This is the I2S interface***
                    system-clock-frequency = <19200000>;
            };

            /* Codec interface */
            simple-audio-card,codec {
                    sound-dai = <&headset0>;
                    bitclock-master;
                    frame-master;
                    clocks = <11289600>; // mdm <&osc>;
            };

During boot, the following error is found in dmesg:

[ 5.773335] OF: /mysound/simple-audio-card,cpu: arguments longer than property
[ 5.779252] asoc-simple-card mysound: parse error -22
[ 5.784418] asoc-simple-card: probe of mysound failed with error -22

I have tried changing the value in the statement “#sound-dai-cells = <1>;” from 3 to 1 then 2 and also 4, but the above error persists.

Can you provide help on the assignment of the #sound-dai-cells?
Is the structure of my device tree correct to assign the i2s bus to the mysound property?

Thanks,
Malcolm

Have you checked NVIDIA Jetson Linux Driver Package Software Features : Audio Setup and Development | NVIDIA Docs >

I have read through it, but still not helping to achieve getting the audio codec running. I find that the document gives good snippets of code, but it hasn’t tied everything together for me. The device tree configuration is new to me, so I am likely missing some of the fundamentals to create a device tree.

I have defined the following in the “sound {”:
// CPU DAI interface
simple-audio-card,cpu {
sound-dai = <&tegra_i2s3>;
#sound-dai-cells = <1>;
system-clock-frequency = <19200000>;
};

            // Codec interface
            simple-audio-card,codec {
                    sound-dai = <&flexcodec1>;  
                    bitclock-master;
                    frame-master;
                    clocks = <11289600>;  
            };
            simple-audio-card,dia-link-3 {
            };

A couple of specific questions:

  1. How ( or which dtsi file) should the dia-link-3 be used to tie the codec and I2C interface? This is one of the pieces of code that isn’t clear to me in the documentation. Do we need to include the dia-link-3 as I have in the above example or how is it included as this the part that binds the codec and I2S as a “card”? Should it be used in the dtsi file which defines “sound {” ?

  2. What is the #sound-dai-cells = <2> used for? What does it define? the number of dai links? I was getting an error saying that the sound-dia-cells was not define in i2s@2901200. I added the definition into:

    tegra_i2s3: i2s@2901200 {
    compatible = “nvidia,tegra210-i2s”;
    #sound-dai-cells = <2>;

Then I get the error in below in dmesg:

[ 8.980564] OF: /sound/simple-audio-card,cpu: arguments longer than property
[ 8.980587] asoc-simple-card sound: parse error -22
But it errors whether I change the value from = <0>, or <1>

What does the #sound-dai-cells = define?

Thanks,
Malcolm

Hi Malcolm,

Please refer to custom audio card and machine driver update sections to understand how to add a custom audio card.

The DT binding references you mentioned above are not correct. For example, simple-audio-card bindings are not supported. You need to use bindings related to Tegra machine driver.

Also, what is the audio codec you are looking to add support for? You need to include relevant bindings as well.

Go through above mentioned sections in detail and add any follow up questions if you have.

Thanks,
Sameer.

Thanks for your input. We are developing on the NX module. I have changed the machine driver to use the codec names and added in the init function as documented in the link.

There are a couple of questions I have:

  1. When I made the changes, I added a debug statement dev_dbg(&pdev->dev, “MM Probing device sound \n”); into the probe code, but I don’t see the message in dmesg.
    I included #define DEBUG 1. What can I do to debug the driver and be able to see the error or debug messages?

  2. I assigned the clocks below in the sound node as:
    assigned-clocks = <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>, <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
    assigned-clock-parents = <&bpmp_clks TEGRA194_CLK_PLLA1_OUT1>, <&bpmp_clks TEGRA194_CLK_PLLA1_OUT1>;
    assigned-clock-rates = <0>, <12288000>;

Is the clock assignment correct? Is bpmp clocks correct for the NX? I see some assignments use tegra_car. What is the difference?

  1. I see the codecs as shown:
    cat /sys/kernel/debug/asoc/codecs
    [sudo] password for test:
    nau8825.8-001b
    nau8825.8-001a

  2. I see the dais as shown:
    sudo cat /sys/kernel/debug/asoc/dais
    nau8825-hifi
    nau8825-hifi
    What code creates the nau8825-hifi dai? We have 2 codecs in our system.

  3. I added select SND_SOC_NAU8825" to the config SND_SOC_TEGRA210_AUDIO_ALT. As shown in the document. The question I have is the document it mentions “Jetson Xavier NX
    SND_SOC_TEGRA_T186REF_MOBILE_ALT” but I don’t see anything in the Kconfig in our BSP. Is SND_SOC_TEGRA210_AUDIO_ALT correct for our NX module? If we should be using
    SND_SOC_TEGRA_T186REF_MOBILE_ALT, how is that included?

Thanks for your help.
Malcolm

Also. I don’t see any clock when I scope out the AUD_MCLK from the NX pin 211 of the NX module.

Thanks Sameer.

I have also found that adding codec-dai = <&flexcodec1a>; to the dai-link below causes the AUD_MCLK to stop working:

            nvidia,dai-link-3 {
                    link-name = "spdif-dit-2";
                    cpu-dai = <&tegra_i2s3>;
                    codec-dai =  <&flexcodec1a>; 
                    cpu-dai-name = "I2S3";
                    codec-dai-name = "dit-hifi";
                    format = "i2s";
                    bit-format = "s16_le";
                    srate = <48000>;
                    num-channel = <2>;
                    ignore_suspend;
                    name-prefix = "z";
                    status = "okay";
            };

This is the nau8825@1a definition:

            flexcodec1a: nau8825@1a{ 
                  compatible = "nuvoton,nau8825";
                  #address-cells = <1>;
                  #size-cells = <0>;
                  reg = <0x1a>;
                  mclk = <12280000>;
                  label = "code1";
        };

Is the flexcodec1a configured properly and is it the right assignment for codec-dai when added to the dai-link-3?

Thanks
Malcolm

Hi Malcolm,

Sorry for the delayed reply. To answer your questions,

You can use dev_err() instead of dev_dbg() to see the prints always for testing purpose. I guess you need to use CONFIG_DEBUG and recompile the drivers for dev_dbg() prints to appear in the log.

This looks incorrect. I am not sure why you had to add these bindings. TEGRA194_CLK_PLLA_OUT0 is used as parent for TEGRA194_CLK_AUD_MCLK and TEGRA194_CLK_PLLA is used as parent for TEGRA194_CLK_PLLA_OUT0. You can confirm if these settings are correct.

This is good. Your codec DAIs are registered fine.

This is added by ASoC core. Since you have two codecs, two DAIs you are able to see. I am guessing the nau8825 driver registers one DAI.

Yes, this is the correct config to be used. We will get the document fixed. Thanks for reporting.

Did you probe the signals while playback or capture was running?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.