Hi,
I am trying to connect CS4270 evaluation board on NX with Jetpack4.4.1, but I have some troubles with the device-tree and the machine driver.
I have added the Codec node at i2c@31e0000 and modified the codec dai link and audio-routing at sound node as follows
diff --git a/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dts b/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dts
index b724f6279..d5a07393e 100644
--- a/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dts
+++ b/hardware/nvidia/platform/t19x/jakku/kernel-dts/tegra194-p3668-all-p3509-0000.dts
@@ -22,4 +22,50 @@
nvidia,dtbbuildtime = __DATE__, __TIME__;
compatible = "nvidia,p3449-0000+p3668-0000", "nvidia,p3449-0000+p3668-0001", "nvidia,p3509-0000+p3668-0000", "nvidia,p3509-0000+p3668-0001", "nvidia,tegra194";
+
+ hdr40_i2c1: i2c@31e0000 {
+ cs4270codec: cs4270@4c {
+ compatible = "cirrus,cs4270";
+ reg = <0x4c>;
+ };
+ };
+
+ tegra_sound: sound {
+ status = "okay";
+
+ nvidia,audio-routing =
+ "x Headphone", "x OUT",
+ "x 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 AOUTL",
+ "n Headphone", "n AOUTR",
+ "n AINL", "n Mic",
+ "n AINR", "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",
+ "d2 Headphone", "d2 OUT";
+
+ hdr40_snd_link_i2s: nvidia,dai-link-5 {
+ link-name = "cs4270-codec";
+ cpu-dai = <&tegra_i2s5>;
+ codec-dai = <&cs4270codec>;
+ cpu-dai-name = "I2S5";
+ codec-dai-name = "cs4270-hifi";
+ format = "i2s";
+ bit-format = "s16_le";
+ name-prefix = "n";
+ status = "okay";
+ };
+ };
+
};
And the machine driver was updated as follows:
diff --git a/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c b/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
index fbca4699d..dee3447b8 100644
--- a/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
+++ b/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c
@@ -311,6 +311,16 @@ static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
if (err < 0)
return err;
+ rtd = snd_soc_get_pcm_runtime(card, "cs4270-codec");
+ if (rtd) {
+ dai_params =
+ (struct snd_soc_pcm_stream *)rtd->dai_link->params;
+
+ dai_params->rate_min = srate;
+ dai_params->channels_min = channels;
+ dai_params->formats = formats;
+ }
+
rtd = snd_soc_get_pcm_runtime(card, "rt565x-playback");
if (rtd) {
dai_params =
@@ -594,6 +604,19 @@ static int tegra_machine_rt565x_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
+static int tegra_machine_cs4270_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct device *dev = rtd->card->dev;
+ int err;
+ err = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 12288000, SND_SOC_CLOCK_IN);
+ if (err) {
+ dev_err(dev, "failed to set cs4270 sysclk!\n");
+ return err;
+ }
+
+ return 0;
+}
+
static int codec_init(struct tegra_machine *machine)
{
struct snd_soc_dai_link *dai_links = machine->asoc->dai_links;
@@ -611,6 +634,8 @@ static int codec_init(struct tegra_machine *machine)
dai_links[i].init = tegra_machine_rt565x_init;
else if (strstr(dai_links[i].name, "fe-pi-audio-z-v2"))
dai_links[i].init = tegra_machine_fepi_init;
+ else if (strstr(dai_links[i].name, "cs4270-codec"))
+ dai_links[i].init = tegra_machine_cs4270_init;
}
return 0;
Changes of codec driver in kernel for dummy regulator
diff --git a/kernel/kernel-4.9/sound/soc/codecs/cs4270.c b/kernel/kernel-4.9/sound/soc/codecs/cs4270.c
index 84f86745c..04ad282c5 100644
--- a/kernel/kernel-4.9/sound/soc/codecs/cs4270.c
+++ b/kernel/kernel-4.9/sound/soc/codecs/cs4270.c
@@ -124,7 +124,7 @@ static const struct reg_default cs4270_reg_defaults[] = {
};
static const char *supply_names[] = {
- "va", "vd", "vlc"
+ "dummy"
};
/* Private data for the CS4270 */
And the kernel config was
CONFIG_SND_SOC_CS4270=m
CONFIG_REGULATOR_DUMMY=y
After the changes made above, I found the sound card jetsonxaviernxa not detected:
user@Jetson-xavier-NX:~$ cat /proc/asound/cards
0 [tegrahdaxnx ]: tegra-hda-xnx - tegra-hda-xnx
tegra-hda-xnx at 0x3518000 irq 64
dmesg showed codec dai cs4270-hifi not registered:
[ 5.570274] tegra-asoc: sound: ASoC: CODEC DAI cs4270-hifi not registered
[ 5.570665] tegra-asoc: sound: snd_soc_register_card failed (-517)
[ 5.573235] tegra-asoc: sound: ASoC: CODEC DAI cs4270-hifi not registered
[ 5.573478] tegra-asoc: sound: snd_soc_register_card failed (-517)
[ 5.899106] tegra-asoc: sound: ASoC: CODEC DAI cs4270-hifi not registered
[ 5.899357] tegra-asoc: sound: snd_soc_register_card failed (-517)
[ 6.112458] tegra-asoc: sound: ASoC: CODEC DAI cs4270-hifi not registered
[ 6.112711] tegra-asoc: sound: snd_soc_register_card failed (-517)
The complete kernel dmesg is attached here:
dmesg.txt (67.8 KB)
I wonder why the sound card jetsonxaviernxa is not detected after the modification. Is there something wrong in the device-tree or machine driver?
Thanks