Hello!
I have validated that the SGTL5000 codec works with the various Jetson boards using the FE-PI Audio Z V2 board [0]. The SND_SOC_TEGRA_SGTL5000 machine driver is not supported for TX2 and so I recommend that you do not use this. To enable support for this codec …
- Enable the codec under the machine driver used for Jetson TX2 (SND_SOC_TEGRA_T186REF_MOBILE_ALT)
diff --git a/sound/soc/tegra-alt/Kconfig b/sound/soc/tegra-alt/Kconfig
index 2d559708ce2e..0bd8c1248672 100644
--- a/sound/soc/tegra-alt/Kconfig
+++ b/sound/soc/tegra-alt/Kconfig
@@ -247,6 +248,7 @@ config SND_SOC_TEGRA_T186REF_MOBILE_ALT
tristate "SoC Audio support for T186Ref Mobile"
depends on SND_SOC_TEGRA_T186REF_ALT
select SND_SOC_RT5659
+ select SND_SOC_SGTL5000
help
Say Y or M here.
- Add the codec node to Jetson TX2 DT file. Please note that in the case of the FE-PI module, the SGTL5000 is clocked by an on-board 12.288MHz fixed rate clock and so a dummy clock is added to DT. This may need to change depending on what is providing the codec mclk. Furthermore, the FE-PI module is connected to the 40-pin header on TX2 and so uses I2C controller ‘i2c@c240000’. If you uses a different I2C interface then this will also need to change.
diff --git a/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi b/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
index 449be9586489..5131f69544b5 100644
--- a/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
+++ b/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
@@ -167,8 +167,30 @@
};
};
+ clocks {
+ sgtl5000_mclk: sgtl5000_mclk {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <12288000>;
+ clock-output-names = "sgtl5000-mclk";
+ status = "okay";
+ };
+ };
+
i2c@c240000 {
status = "okay";
+
+ sgtl5000: sgtl5000@0a {
+ compatible = "fsl,sgtl5000";
+ reg = <0x0a>;
+ clocks = <&sgtl5000_mclk>;
+ micbias-resistor-k-ohms = <2>;
+ micbias-voltage-m-volts = <3000>;
+ VDDA-supply = <&vdd_3v3>;
+ VDDIO-supply = <&vdd_3v3>;
+ status = "okay";
+ };
+
lp8556_backlight: lp8556-backlight-s-wqxga-10-1@2c {
status = "disabled";
disable-on-kernel-charging;
- Update the Jetson TX2 sound DT node. Please note that because the sgtl5000 is clocked by a fixed rate clock on the FE-PI board, I have configured the codec as the bitclock and frame master. If the mclk is provided by Tegra then the codec should be the bitclock and frame slave.
diff --git a/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi b/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
index 449be9586489..c6c46bd6d7bb 100644
--- a/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
+++ b/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
@@ -900,8 +922,8 @@
status = "okay";
nvidia,audio-routing =
- "x Headphone", "x OUT",
- "x IN", "x Mic",
+ "x Headphone", "x HP_OUT",
+ "x MIC_IN", "x Mic";
"y Headphone", "y OUT",
"y IN", "y Mic",
"z Headphone", "z OUT",
@@ -922,14 +944,14 @@
nvidia,xbar = <&tegra_axbar>;
rt565x_dai_link: nvidia,dai-link-1 {
- link-name = "rt565x-playback";
+ link-name = "fe-pi-audio-z-v2";
cpu-dai = <&tegra_i2s1>;
- codec-dai = <&spdif_dit0>;
+ codec-dai = <&&sgtl5000>;
cpu-dai-name = "I2S1";
- codec-dai-name = "dit-hifi";
+ codec-dai-name = "sgtl5000";
format = "i2s";
- bitclock-slave;
- frame-slave;
+ bitclock-master;
+ frame-master;
bitclock-noninversion;
frame-noninversion;
bit-format = "s16_le";
- Update the Jetson TX2 machine driver. Again because the sgtl5000 on the FE-PI module uses a fixed rate clock I need to tell the sgtl5000 driver this by calling snd_soc_dai_set_sysclk() for the codec. Finally, I also need to update the DAI params passed to the codec whenever playback/capture starts so that the codec is using the codec sample-rate, channels, etc.
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 e3428a6650af..46ce2bfda5c8 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
@@ -32,6 +32,7 @@
#include <sound/soc.h>
#include <dt-bindings/sound/tas2552.h>
#include "rt5659.h"
+#include "sgtl5000.h"
#include "tegra_asoc_utils_alt.h"
#include "tegra_asoc_machine_alt.h"
#include "tegra210_xbar_alt.h"
@@ -640,6 +641,16 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
}
}
+ rtd = snd_soc_get_pcm_runtime(card, "fe-pi-audio-z-v2");
+ 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;
+ }
+
return 0;
}
@@ -782,6 +793,21 @@ static int tegra_machine_compr_set_params(struct snd_compr_stream *cstream)
}
#endif
+static int tegra_machine_fepi_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct device *dev = rtd->card->dev;
+ int err;
+
+ err = snd_soc_dai_set_sysclk(rtd->codec_dai, SGTL5000_SYSCLK, 12288000,
+ SND_SOC_CLOCK_IN);
+ if (err) {
+ dev_err(dev, "failed to set sgtl5000 sysclk!\n");
+ return err;
+ }
+
+ return 0;
+}
+
static int tegra_machine_rt565x_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
@@ -885,13 +911,18 @@ static void dai_link_setup(struct platform_device *pdev)
tegra_machine_rt565x_init;
}
} else if (strstr(tegra_machine_codec_links[i].name,
- "dspk-playback-r"))
+ "dspk-playback-r")) {
tegra_machine_codec_links[i].init =
tegra_machine_dspk_init;
- else if (strstr(tegra_machine_codec_links[i].name,
- "dspk-playback-l"))
+ } else if (strstr(tegra_machine_codec_links[i].name,
+ "dspk-playback-l")) {
tegra_machine_codec_links[i].init =
tegra_machine_dspk_init;
+ } else if (strstr(tegra_machine_codec_links[i].name,
+ "fe-pi-audio-z-v2")) {
+ tegra_machine_codec_links[i].init =
+ tegra_machine_fepi_init;
+ }
}
}
- Finally, you need to ensure that pins for the I2S are configured for I2S. I am using the I2S controller exposes by 40-pin header. Please refer to the ‘Jetson TX2 Adaptation Guide’ [1] on how to reconfigure the pins on Jetson TX2.
Regards,
Jon
[0] https://fe-pi.com/products/fe-pi-audio-z-v2
[1] https://developer.nvidia.com/embedded/dlc/l4t-driver-package-tx2-adaptation-guide