How to adapt NAU8810 or NAU8814 to TX2

There is NAU8810 driver in the kernel source code: the file is nau8810.c. Base on nau8810.c ,I wrote nau8814.c
But I don’t know how to change the dts, here is what I have changed the file:

Linux_for_Tegra/source/public/hardware/nvidia/platform/t18x/lanai/kernel-dts/common/tegra186-p3636-0001-a00-audio.dtsi

/*

  • Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
  • This program is free software; you can redistribute it and/or modify it
  • under the terms and conditions of the GNU General Public License,
  • version 2, as published by the Free Software Foundation.
  • This program is distributed in the hope it will be useful, but WITHOUT
  • ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  • FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  • more details.
  • You should have received a copy of the GNU General Public License
  • along with this program. If not, see http://www.gnu.org/licenses/.
    */

/*

  • T186 p3636-0001-a00 audio common DTSI file.
    */

include <audio/tegra-platforms-audio-dai-links.dtsi>

/ {
hda@3510000 {
status = “okay”;
};

// tegra_sound: sound {
// status = “okay”;
// compatible = “nvidia,tegra-audio-t186ref-mobile-rt565x”;
// nvidia,model = “tegra-snd-t186ref-mobile-rt565x”;
// clocks = <&tegra_car TEGRA186_CLK_PLLA>,
// <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
// <&tegra_car TEGRA186_CLK_AUD_MCLK>;
// clock-names = “pll_a”, “pll_a_out0”, “extern1”;
// assigned-clocks = <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
// <&tegra_car TEGRA186_CLK_AUD_MCLK>;
// assigned-clock-parents = <&tegra_car TEGRA186_CLK_PLLA>,
// <&tegra_car TEGRA186_CLK_PLL_A_OUT0>;
// resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
// reset-names = “extern1_rst”;
//
// mclk-fs = <256>;
//
// /* TODO Avoid rt565x_dai_link definition by modifying common base file
// * since current base does not have definition of dai link as
// * rt565x_dai_link, had to add here
// */
// hdr40_snd_link_i2s: rt565x_dai_link: nvidia,dai-link-1 { };
// };

tegra_sound: sound {
	status = "okay";
	compatible = "nvidia,tegra-audio-t186ref-mobile-nau8814";
	nvidia,model = "tegra-snd-t186ref-mobile-nau8814";
	clocks = <&tegra_car TEGRA186_CLK_PLLA>,
		 <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
		 <&tegra_car TEGRA186_CLK_AUD_MCLK>;
	clock-names = "pll_a", "pll_a_out0", "extern1";
	assigned-clocks = <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
			  <&tegra_car TEGRA186_CLK_AUD_MCLK>;
	assigned-clock-parents = <&tegra_car TEGRA186_CLK_PLLA>,
				 <&tegra_car TEGRA186_CLK_PLL_A_OUT0>;
	resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
	reset-names = "extern1_rst";

	mclk-fs = <256>;
	
	nvidia,num-codec-link = <2>;
	
	nvidia,audio-routing =		
		//"x LINE_IN",    "x Linein",
		//"x Headphone",  "x HPOUT";

// “x Headphone”, “x OUT”,
// “x IN”, “x Mic”;

// “x IN”, “x Mic”,
// “x Headphone”, “x OUT”;

// “x Headphone”, “x LHP”,
// “x Headphone”, “x RHP”,
// “x Int Spk”, “x LSPK”,
// “x Int Spk”, “x RSPK”,
//
// “y Headphone”, “y OUT”,
// “x LMICN”, “x Mic”,
// “x LMICP”, “x Mic”,
// “x RMICN”, “x Mic”,
// “x RMICP”, “x Mic”,
// “x Capture”, “x Mic”;

// “x Headphone”, “x MICN”,
// “x Headphone”, “x MICP”,

// “x Int Spk”, “x SpkP Out”,
// “x Int Spk”, “x SpkN Out”,
//
// “x Int Spk”, “x Playback”,

	"x Int Spk",   "x SPKOUTN",  
	"x Int Spk",   "x SPKOUTP",  
	
	"x ADC",		"x Mic Bias",
	
	"x MICN",		"x Mic",
	"x MICP",		"x Mic",
	"x Capture",	"x Mic";

	nvidia,xbar = <&tegra_axbar>;

	nvidia,dai-link-1{		

	};

	nvidia,dai-link-2{		
							
		link-name = "nau8814";
		cpu-dai = <&tegra_i2s3>;
		codec-dai = <&nau8814>;
		cpu-dai-name = "I2S3";
		codec-dai-name = "nau8814-hifi";
		name-prefix = "x";
		format = "i2s";
		bit-format = "s16_le";
		srate = <48000>;

// num-channel = <2>;
ignore_suspend;
status = “okay”;

// format = “i2s”;
// bitclock-slave;
// frame-slave;
// bitclock-noninversion;
// frame-noninversion;
// bit-format = “s16_le”;
// srate = <48000>;
// num-channel = <2>;
// ignore_suspend;
// status = “okay”;
};

	/* TODO Avoid rt565x_dai_link definition by modifying common base file
	 * since current base does not have definition of dai link as
	 * rt565x_dai_link,  had to add here
	 */
	hdr40_snd_link_i2s: rt565x_dai_link: nvidia,dai-link-1 { };
	nau8814_dai_link: nvidia,dai-link-2 { };
};

};

/* gen8-i2c - ID EEPROM */
i2c@c250000 {
status=“okay”;

		   nau8814: codec@1A{
			compatible = "nuvoton,nau8814";
			reg = <0x1A>;
			status = "okay";
		   };
   };

But it seems does not work,what is the problem? How to adapt the device tree? The I2C connected is i2c@c250000

Hi,

  • What is not working exactly please elaborate and share the dmesg logs.
  • Which JP release are you using?

From your DT changes perpective,

  • Please don’t edit below 2 lines,
  • Any specific reason of using dai-link-2 rather than dai-link-1 here,

But we are using nau8814 chip rather than rt565x. The reason add dai-link-2 is that dai-link-1 is for hdr40_snd_link_i2s which has been descripted below in the dts file, so I add dai-link-2 for nau8814_dai_link.
I using I2S3 to transmit PCM signal and i2c@c250000 to control the nau8814.

Machine driver only list this compatible “nvidia,tegra-audio-t186ref-mobile-rt565x” thats why you need to use that.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.