SGTL5000 with Xavier

Hello Don,

The part under the ‘sgtl5000.7-000a@0a’ node looks correct to me and yes that’s what I would expect. However, you should not need to remove the AUD_MCLK from under the sound node and in fact I recommend that you do not do this. The reason being is that we want AUD_MCLK to be configured by the Tegra ASoC machine driver to operate at something like 256fs by default (I see the SGTL5000 driver supports a MCLK of 256fs, 384fs and 512fs).

However, to configure the MCLK for 256*fs it will require an update to the Tegra ASoC machine driver. Assuming that you are using L4T rel32.1 it would be something like …

diff --git a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
index cbe8c5ff3c6a..a8bb56e93f7f 100644
--- a/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
+++ b/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
@@ -651,6 +651,23 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
                dai_params->formats = formats;
        }
 
+       rtd = snd_soc_get_pcm_runtime(card, "sgtl5000-playback");
+       if (rtd) {
+               dai_params =
+               (struct snd_soc_pcm_stream *)rtd->dai_link->params;
+
+               dai_params->rate_min = clk_rate;
+               dai_params->channels_min = channels;
+               dai_params->formats = formats;
+
+               err = snd_soc_dai_set_sysclk(rtd->codec_dai, RT5659_SCLK_S_MCLK,
+                                            clk_out_rate, SND_SOC_CLOCK_IN);
+               if (err < 0) {
+                       dev_err(card->dev, "codec_dai clock not set\n");
+                       return err;
+               }
+       }
+
        return 0;
 }
 
@@ -793,6 +810,21 @@ static int tegra_machine_compr_set_params(struct snd_compr_stream *cstream)
 }
 #endif
 
+static int tegra_machine_sgtl5000_init(struct snd_soc_pcm_runtime *rtd)
+{
+       struct tegra_machine *machine = snd_soc_card_get_drvdata(rtd->card);
+       int err;
+
+       err = tegra_alt_asoc_utils_set_extern_parent(&machine->audio_clock,
+                                                    "pll_a_out0");
+       if (err < 0) {
+               dev_err(rtd->card->dev, "Failed to set extern clk parent\n");
+               return err;
+       }
+
+       return 0;
+}
+
 static int tegra_machine_fepi_init(struct snd_soc_pcm_runtime *rtd)
 {
        struct device *dev = rtd->card->dev;
@@ -922,6 +954,10 @@ static void dai_link_setup(struct platform_device *pdev)
                                "fe-pi-audio-z-v2")) {
                                tegra_machine_codec_links[i].init =
                                        tegra_machine_fepi_init;
+                       } else if (strstr(tegra_machine_codec_links[i].name,
+                               "sgtl5000-playback")) {
+                               tegra_machine_codec_links[i].init =
+                                       tegra_machine_sgtl5000_init;
                        }
                }
        }

Even though the above change is needed, this will not resolve the initial issue that you have reported. I assume that the issue that you initially reported still persists with the device-tree changes that you have made so far? If so, then one problem could be that the parent clock for the AUD_MCLK is not configured when the it is enabled by the SGTL5000 codec. We test with an RT5658 codec on the Jetson AGX Xavier DevKit which should work in the same way. Do you see an error on boot that is causing the probe of the SGTL5000 codec to fail?

Also it will be necessary to update the nvidia,audio-routing in device-tree to be something like …

diff --git a/common/tegra194-audio-p2822-0000.dtsi b/common/tegra194-audio-p2822-0000.dtsi
index 2708dd993bcf..f183b9353b47 100644
--- a/common/tegra194-audio-p2822-0000.dtsi
+++ b/common/tegra194-audio-p2822-0000.dtsi
@@ -75,15 +75,8 @@
                        "clk_m", "extern1";
 
                nvidia,audio-routing =
-                       "x Headphone Jack",     "x HPO L Playback",
-                       "x Headphone Jack",     "x HPO R Playback",
-                       "x IN1P",               "x Mic Jack",
-                       "x IN2P",               "x Mic Jack",
-                       "x Int Spk",            "x SPO Playback",
-                       "x DMIC L1",            "x Int Mic",
-                       "x DMIC L2",            "x Int Mic",
-                       "x DMIC R1",            "x Int Mic",
-                       "x DMIC R2",            "x Int Mic",
+                       "x Headphone",          "x HP_OUT",
+                       "x MIC_IN",             "x Mic",
                        "y Headphone",          "y OUT",
                        "y IN",                 "y Mic",
                        "z Headphone",          "z OUT",

Regards,
Jon