Hello @jonathanh.
My current tegra210-porg-p3448-common.dts. I put this clock “TEGRA210_CLK_PLL_P” on the sound node because my codec audio is 24Mhz, this makes sense?
diff --git a/tegra210-porg-p3448-common.dtsi.old b/tegra210-porg-p3448-common.dtsi
index 2a7d844..5940ff3 100644
--- a/tegra210-porg-p3448-common.dtsi.old
+++ b/tegra210-porg-p3448-common.dtsi
@@ -75,6 +75,16 @@
};
};
+ clocks {
+ sgtl5000_mclk: sgtl5000_mclk {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <24000000>;
+ clock-output-names = "sgtl5000-mclk";
+ status = "okay";
+ };
+ };
+
rollback-protection {
status = "okay";
};
@@ -385,38 +395,41 @@
compatible = "nvidia,tegra-audio-t210ref-mobile-rt565x";
nvidia,model = "tegra-snd-t210ref-mobile-rt565x";
- clocks = <&tegra_car TEGRA210_CLK_PLL_A>,
+ clocks = <&tegra_car TEGRA210_CLK_PLL_P>,
+ <&tegra_car TEGRA210_CLK_PLL_A>,
<&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA210_CLK_EXTERN1>;
- clock-names = "pll_a", "pll_a_out0", "extern1";
- assigned-clocks = <&tegra_car TEGRA210_CLK_EXTERN1>,
+ clock-names = "pll_p","pll_a", "pll_a_out0", "extern1";
+ assigned-clocks = <&tegra_car TEGRA210_CLK_PLL_P>,
+ <&tegra_car TEGRA210_CLK_EXTERN1>,
<&tegra_car TEGRA210_CLK_PLL_A_OUT0>,
<&tegra_car TEGRA210_CLK_PLL_A>;
- assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
- assigned-clock-rates = <12288000>, <49152000>, <368640000>;
+ assigned-clock-parents = <&tegra_car TEGRA210_CLK_PLL_P>,<&tegra_car TEGRA210_CLK_PLL_A_OUT0>;
+ assigned-clock-rates = <24000000>,<12288000>, <49152000>, <368640000>;
nvidia,num-codec-link = <4>;
nvidia,audio-routing =
- "x Headphone", "x OUT",
- "x IN", "x Mic",
- "y Headphone", "y OUT",
- "y IN", "y Mic",
- "a IN", "a Mic",
- "b IN", "b Mic";
+ "x Headphone", "x HP_OUT",
+ "x MIC_IN", "x Mic",
+ "x ADC", "x Mic Bias",
+ "x LINE_IN", "x Line In",
+ "x Line Out", "x LINE_OUT";
nvidia,xbar = <&tegra_axbar>;
mclk-fs = <256>;
hdr40_snd_link_i2s: i2s_dai_link1: nvidia,dai-link-1 {
- link-name = "spdif-dit-0";
+ link-name = "fe-pi-audio-z-v2";
cpu-dai = <&tegra_i2s4>;
- codec-dai = <&spdif_dit0>;
+ codec-dai = <&sgtl5000>;
cpu-dai-name = "I2S4";
- codec-dai-name = "dit-hifi";
+ codec-dai-name = "sgtl5000";
format = "i2s";
- bitclock-slave;
- frame-slave;
+ bitclock-slave;
+ frame-slave;
+ bitclock-master;
+ frame-master;
bitclock-noninversion;
frame-noninversion;
bit-format = "s16_le";
@@ -766,6 +779,20 @@
tegra_nct72: temp-sensor@4c {
status = "disabled";
};
+
+ sgtl5000: sgtl5000@0a {
+ compatible = "fsl,sgtl5000";
+ reg = <0x0a>;
+ clocks = <&sgtl5000_mclk>;
+ micbias-resistor-k-ohms = <2>;
+ micbias-voltage-m-volts = <3000>;
+ VDDA-supply = <&hdr40_vdd_3v3>;
+ /*VDDIO-supply = <&hdr40_vdd_3v3>;*/
+ VDDIO-supply = <&p3449_vdd_1v8>;
+ status = "okay";
+ };
+
+
};
hdr40_i2c1: i2c@7000c400 { };
(END)
I made some changes in “tegra_machine_driver_mobile.c” .
diff --git a/tegra_machine_driver_mobile.c.old b/tegra_machine_driver_mobile.c
index b999724..7b9d6bf 100644
--- a/tegra_machine_driver_mobile.c.old
+++ b/tegra_machine_driver_mobile.c
@@ -297,6 +297,8 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
int err;
struct snd_soc_pcm_runtime *rtd;
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
+
srate = (machine->rate_via_kcontrol) ?
tegra_machine_srate_values[machine->rate_via_kcontrol] :
rate;
@@ -375,7 +377,48 @@ 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 = rate;
+ dai_params->channels_min = channels;
+ dai_params->formats = formats;
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
+ }
+
+
return 0;
}
static int tegra_machine_pcm_hw_params(struct snd_pcm_substream *substream,
@@ -384,7 +427,7 @@ static int tegra_machine_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_card *card = rtd->card;
int err;
-
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
err = tegra_machine_dai_init(rtd, params_rate(params),
params_channels(params),
1ULL << params_format(params));
@@ -468,7 +511,7 @@ static int tegra_machine_compr_set_params(struct snd_compr_stream *cstream)
dev_err(card->dev, "compr ops not set\n");
return -EINVAL;
}
-
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
err = tegra_machine_dai_init(rtd, codec_params.sample_rate,
codec_params.ch_out,
SNDRV_PCM_FMTBIT_S16_LE);
@@ -505,7 +548,7 @@ 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,
+ err = snd_soc_dai_set_sysclk(rtd->codec_dai, SGTL5000_SYSCLK, 24000000,
SND_SOC_CLOCK_IN);
if (err) {
dev_err(dev, "failed to set sgtl5000 sysclk!\n");
@@ -515,6 +558,23 @@ static int tegra_machine_fepi_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
+static int tegra_machine_sgtl5000_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct device *dev = rtd->card->dev;
+ int err;
+
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
+
+ err = snd_soc_dai_set_sysclk(rtd->codec_dai, SGTL5000_SYSCLK, 24000000,
+ 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;
@@ -598,7 +661,7 @@ static struct snd_soc_compr_ops tegra_machine_compr_ops = {
static void set_dai_ops(struct tegra_machine *machine)
{
int i;
-
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
/* set ADMAIF dai_ops */
for (i = machine->soc_data->admaif_dai_link_start;
i <= machine->soc_data->admaif_dai_link_end; i++)
@@ -653,7 +716,7 @@ static int add_dai_links(struct platform_device *pdev)
ret = codec_init(machine);
if (ret < 0)
return ret;
-
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
set_dai_ops(machine);
return 0;
@@ -695,6 +758,8 @@ static int tegra_machine_driver_probe(struct platform_device *pdev)
int ret = 0;
const struct of_device_id *match;
+ printk(KERN_ERR "%s - debug sgtl5000\n", __func__);
+
card->dev = &pdev->dev;
/* parse card name first to log errors with proper device name */
ret = snd_soc_of_parse_card_name(card, "nvidia,model");
(END)
I put some debug messages on the driver “tegra_machine_driver_mobile.c”, and I realized that the function “tegra_machine_dai_init” is not being called. What do you think? Any suggestion? Do I need to enable this “CONFIG_SND_SOC_TEGRA210_ADSP_ALT” ?
~$ dmesg | grep sgtl5000
[ 1.996913] sgtl5000 0-000a: sgtl5000 revision 0x11
[ 1.997439] sgtl5000 0-000a: Using internal LDO instead of VDDD: check ER1
[ 2.032852] tegra_machine_driver_probe - debug sgtl5000
[ 2.038511] tegra-asoc: sound: add_dai_links - debug1 sgtl5000
[ 2.044347] set_dai_ops - debug sgtl5000