Configuring an SGTL5000 codec on TX2i

I have been reading through various posts about getting the SGTL5000 audio codec to work on Jetsons, and I have been attempting to follow these and the latest (R32.3) ASoC Driver documentation (which deals explicitly with the subject), but I have hit some snags.

I have a TX2i (running R32.3.1) on a DevKit board and I have successfully reflashed the pinmux to enable AUD_MCLK on J21. I then edited the machine driver and device tree based on information I collected as closely as possible.

On recompiling tegra186-quill-p3489-1000-a00-00-ucm1.dtb, I found that I had various errors, including

./tegra186-quill-p3489-1000-a00-00-ucm1.dtb: ERROR (phandle_references): Reference to non-existent node or label “vdd_3v3”

./tegra186-quill-p3489-1000-a00-00-ucm1.dtb: ERROR (phandle_references): Reference to non-existent node or label “vdd_1v8_ap”

stemming from my device tree entry

            sgtl5000: sgtl5000@0a {
                    compatible = "fsl,sgtl5000";
                    reg = <0x0a>;
                    clock-names = "extern1";
                    micbias-resistor-k-ohms = <2>;
                    micbias-voltage-m-volts = <3000>;
                    VDDA-supply = <&vdd_3v3>;
                    VDDIO-supply = <&vdd_1v8_ap>;
                    status = "okay";

dtc seemed to generate a lot of other warnings as well, but by deleting the lines concerning the supplies which generated the errors, I was able to reflash and reboot with the new kernel and device tree. Dmesg then showed errors such as "failed to get supply VDDA’: -19.

Have I missed something out in my dts file which defines these values?

PS: The codec board I am trying to get working is the Audio Shield for the Teensy 4.0, which operates in slave mode with all clocks supplied by the TX2i, so I may also need help with that.

edit -

An additional thing I note is that the result of de-compiling tegra186-quill-p3489-1000-a00-00-ucm1.dtb has many of the text labels replaced by hexadecimal constants. Does this mean I can no longer use the text labels for clocks etc in my edits?

sound {
iommus = <0x11 0x1e>;
dma-mask = <0x0 0x5e000000>;
iommu-resv-regions = <0x0 0x0 0x0 0x40000000 0x0 0x60000000 0xffffffff 0xffffffff>;
iommu-group-id = <0x2>;
status = “okay”;
compatible = “nvidia,tegra-audio-t186ref-mobile-rt565x”;
nvidia,model = “tegra-snd-t186ref-mobile-rt565x”;
nvidia,num-codec-link = <0x1>;
clocks = <0x10 0x10f 0x10 0xf6 0x10 0x57 0x10 0x7c>;
clock-names = “pll_a”, “pll_a_out0”, “ahub”, “extern1”;
assigned-clocks = <0x10 0xf6 0x10 0x57 0x10 0x7c>;
assigned-clock-parents = <0x10 0x10f 0x10 0xf6 0x10 0xf6>;
resets = <0x10 0x92>;
reset-names = “extern1_rst”;
nvidia,audio-routing = “x Headphone”, “x HP_OUT”, “x MIC_IN”, “x Mic”, “y Headphone”, “y OUT”, “y IN”, “y Mic”, “z Headphone”, “z OUT”, “z IN”, “z Mic”, “m Headphone”, “m OUT”, “m IN”, “m Mic”, “n Headphone”, “n OUT”, “n IN”, “n Mic”, “o Headphone”, “o OUT”, “o IN”, “o Mic”, “a IN”, “a Mic”, “b IN”, “b Mic”, “c IN”, “c Mic”, “d IN”, “d Mic”, “d1 Headphone”, “d1 OUT”, “d3 Headphone”, “d3 OUT”;
nvidia,xbar = <0xb9>;
mclk-fs = <0x100>;
linux,phandle = <0x105>;
phandle = <0x105>;


If you are de-compiling and re-compiling the DTB, then using the labels will not work. To use this labels, you should sync the kernel source tree and recompile the kernel. There are some instructions available here …


OK. I did all that and updated my device tree and kernel machine driver according to various posts related to the SGTL5000 codec. I now have the Teensy 4.0 board connected to i2c0 (on J26) and i2s1 (on J21) of the DevKit. When the TX2i boots, I can see that the driver is invoked with a few errors and warnings, such as:

> > [ 14.326250] tegra-asoc: sound: Entered tegra_machine_dai_init: sgtl5000-codec
> > [ 14.337080] tegra-asoc: sound: Exited tegra_machine_dai_init: sgtl5000-codec
> > [ 14.361064] sgtl5000 1-000a: PLL not supported in slave mode
> > [ 14.372273] sgtl5000 1-000a: 278 ratio is not supported. SYS_MCLK needs to be 256, 384 or 512 * fs
> > [ 14.382459] sgtl5000 1-000a: ASoC: can’t set sgtl5000 hw params: -22
> > [ 14.409933] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -22

but otherwise, things look OK, including AUD_MCLK at 12.25 MHz going to the codec.

When I run:
amixer -c 1 cset name=“I2S2 Mux” ADMAIF2
followed by:
speaker-test -D hw:1,1 -c 1 -r 48000 -F S16_LE -t sine -f 500
I can see the i2s bitclk at 1.54 MHz, the LRclk at 48 kHz and binary data on i2s_sdout.

So everything appears to be working, except I have no sound from either the headphone or line-out outputs.

I think I might need a bit of a push over the line here to:

  • Resolve the warnings on boot
  • Set the default signal routing
  • Finally get some sound output.

Any suggestions?


Sorry for the delay. I can see that the hw_params callback for the codec is failing and it this fails then playback/capture is not going to work.

 [ 14.382459] sgtl5000 1-000a: ASoC: can’t set sgtl5000 hw params: -22

One of the previous messages indicates that the PLL for the codec is not supported in slave mode. Given that you are driving the SGTL5000 MCLK with the Tegra AUD_MCLK the Tegra audio machine driver needs to be modified to indicate the AUD_MCLK frequency so that the SGTL5000 can bypass its internal PLL. In the tegra_machine_dai_init() function, for the DAI link for the SGTL5000 you need to call snd_soc_dai_set_sysclk() and pass the aud_mclk frequency …

snd_soc_dai_set_sysclk(rtd->codec_dai, SGTL5000_SYSCLK, aud_mclk, SND_SOC_CLOCK_IN);


Thanks Jonathan,

Despite the error code -22, I managed to get the Teensy audio shield to work with my TX2i + DevKit. There is a remaining peculiarity, however, which I am wondering if you (or somebody) can help me with. Although I can successfully run the speaker-test program and can even play wav files I have generated myself, I have had no luck getting sound out of any of the portaudio example programs, despite the fact that I can see I2S data coming into the codec. Have you or anyone else got experience with portaudio on a Jetson?


Sorry for the delay. I have not personally played with portaudio and so have not tried. However. I will ask if anyone at NVIDIA has played with this or not.

Are you able to get this working on a Linux PC?


Thanks Jonathan,

There are no problems on a Linux Desktop. It’s obviously something simple because the Teensy Shield (SGTL5000) sound card works fine on the TX2i with other sound sources, but the PortAudio examples only work either while another sound is playing or if launched within a few seconds of it finishing. There is obviously some part of the sound card initialization that is not happening with PortAudio.

Just to close out on this topic, I ultimately found that portaudio does work with the SGTL5000 on the TX2i, but I had to wait a while (30 secs or so) for the library to find the right sound card for some reason. I imagine the example files weren’t written for any specific sound card, and appear to cycle through all the possibilities each time. In summary it does work, and I even had success installing Octave and using the codec via the playrec interface, which was quite impressive on an embedded system.