AGX Orin 32GB supports the NAU8825 driver

Hi, Community:

The first time we developed our custom carrier port NAU8825 driver using the AGX Orin 32GB module, we encountered audio codec driver issues. We use the L4T R35.1.1 development kit.

The schematic diagram of the hardware we use is shown below:



  1. pinmux reuse is as follows:

  2. When loading nau8825, dmesg displays the following message:
[ 478.547356] irq: IRQ321: trimming hierarchy from :pmc@c360000
[ 478.547402] nau8825 8-001a: No ‘mclk’ clock found, assume MCLK is managed externally
  1. No sound node is generated under /dev/
  2. Here are some of my log
    dmesg.txt (70.0 KB)
    shell_log.txt (9.4 KB)
    tegra234-p3737-audio.dtsi (9.0 KB)
  3. Can you tell me, after setting the device tree, do I need to modify the machine source code in those locations or other locations? I don’t see this very clearly in Audio Setup and Development. Thank you very much!
1 Like

您好:
很期待您的回复,有些问题点不是很清楚,我是按照《 TLV320AIC3204 Driver will support for AGX Orin 64GB SOM? - Jetson & Embedded Systems / Jetson AGX Orin - NVIDIA Developer Forums》该链接的提示操作的,但是在添加完机器驱动后,编译内核时并没有编译nau8825驱动,然后我便在kernel5.10/sound/soc/tegra/目录下修改的,加载nau8825驱动时提示,没有mclk时钟,并且在/dev下没有sound节点。谢谢!

Hi,
From your log, amixer -c APE controls | grep “nau” lists the codec controls which confirms Sound card got registered.

check with # cat /proc/asound/cards

ls /dev/snd will list the sound devices

|nau8825 8-001a: No ‘mclk’ clock found, assume MCLK is managed externally|
Fix your dts file “clock_names = “mclk”;” to clock-names = “mclk”; can’t use underscore in clock names

The following information is obtained after loading the NAU8825 driver:

In addition, I have a small question to ask. mclk clock needs to be exported from the master SOC to codec CODES. How to set DTS?

Hi,
Please have the below entry in the codec dts node nau8825: nau8825.8-001a@1a { };

clocks = <&bpmp_clks TEGRA234_CLK_AUD_MCLK>;
clock-names = “mclk”;

Also enable the aud_mclk pinmux.

May I ask: about “tegra_machine_fepi_init ()” is to use the corresponding function in which file?


.set_sysclk = nau8825_set_sysclk,

I see above callback in codec driver, you can implement sysclk callback from machine driver similar to tegra_machine_fepi_init() for nau codec.

Excuse me:
1
Is this the right thing to do?

Hi,
Yes, as sound card got registered you can try playback with codec to verify the path.

Excuse me:
When using arecord recording, the input/output error is displayed, and no sound output is displayed when playing 12345.wav. Can you help me check? thank you.
3

Hi,
Did you setup ADMAIF control to connect to I2S for playback. Can you list the commands used before aplay?.

Try aplay after below command
amixer -c APE cset name=“I2S1 Mux” “ADMAIF1”
aplay -D hw:APE,0 12345.wav

Thank you very much for your help. When I setup the ADMAIF control to connect to I2S playback, I can hear the sound when playing the 12345.wav file through “aplay”; When Recording with arecord, the following information is obtained:
"Recording WAVE ‘789.wav’ : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
arecord: pcm_read:2178: read error: Input/output error“

root@ubuntu:/home/orin#
root@ubuntu:/home/orin# amixer -c APE cset name=“ADMAIF1 Mux” “I2S1”
numid=1273,iface=MIXER,name=‘ADMAIF1 Mux’
; type=ENUMERATED,access=rw------,values=1,items=81
; Item #0 ‘None’
; Item #1 ‘ADMAIF1’
; Item #2 ‘ADMAIF2’
; Item #3 ‘ADMAIF3’
; Item #4 ‘ADMAIF4’
; Item #5 ‘ADMAIF5’
; Item #6 ‘ADMAIF6’
; Item #7 ‘ADMAIF7’
; Item #8 ‘ADMAIF8’
; Item #9 ‘ADMAIF9’
; Item #10 ‘ADMAIF10’
; Item #11 ‘ADMAIF11’
; Item #12 ‘ADMAIF12’
; Item #13 ‘ADMAIF13’
; Item #14 ‘ADMAIF14’
; Item #15 ‘ADMAIF15’
; Item #16 ‘ADMAIF16’
; Item #17 ‘I2S1’
; Item #18 ‘I2S2’
; Item #19 ‘I2S3’
; Item #20 ‘I2S4’
; Item #21 ‘I2S5’
; Item #22 ‘I2S6’
; Item #23 ‘SFC1’
; Item #24 ‘SFC2’
; Item #25 ‘SFC3’
; Item #26 ‘SFC4’
; Item #27 ‘MIXER1 TX1’
; Item #28 ‘MIXER1 TX2’
; Item #29 ‘MIXER1 TX3’
; Item #30 ‘MIXER1 TX4’
; Item #31 ‘MIXER1 TX5’
; Item #32 ‘AMX1’
; Item #33 ‘AMX2’
; Item #34 ‘AMX3’
; Item #35 ‘AMX4’
; Item #36 ‘ARAD1’
; Item #37 ‘AFC1’
; Item #38 ‘AFC2’
; Item #39 ‘AFC3’
; Item #40 ‘AFC4’
; Item #41 ‘AFC5’
; Item #42 ‘AFC6’
; Item #43 ‘OPE1’
; Item #44 ‘SPKPROT1’
; Item #45 ‘MVC1’
; Item #46 ‘MVC2’
; Item #47 ‘IQC1-1’
; Item #48 ‘IQC1-2’
; Item #49 ‘IQC2-1’
; Item #50 ‘IQC2-2’
; Item #51 ‘DMIC1’
; Item #52 ‘DMIC2’
; Item #53 ‘DMIC3’
; Item #54 ‘DMIC4’
; Item #55 ‘ADX1 TX1’
; Item #56 ‘ADX1 TX2’
; Item #57 ‘ADX1 TX3’
; Item #58 ‘ADX1 TX4’
; Item #59 ‘ADX2 TX1’
; Item #60 ‘ADX2 TX2’
; Item #61 ‘ADX2 TX3’
; Item #62 ‘ADX2 TX4’
; Item #63 ‘ADX3 TX1’
; Item #64 ‘ADX3 TX2’
; Item #65 ‘ADX3 TX3’
; Item #66 ‘ADX3 TX4’
; Item #67 ‘ADX4 TX1’
; Item #68 ‘ADX4 TX2’
; Item #69 ‘ADX4 TX3’
; Item #70 ‘ADX4 TX4’
; Item #71 ‘ADMAIF17’
; Item #72 ‘ADMAIF18’
; Item #73 ‘ADMAIF19’
; Item #74 ‘ADMAIF20’
; Item #75 ‘ASRC1 TX1’
; Item #76 ‘ASRC1 TX2’
; Item #77 ‘ASRC1 TX3’
; Item #78 ‘ASRC1 TX4’
; Item #79 ‘ASRC1 TX5’
; Item #80 ‘ASRC1 TX6’
: values=17
root@ubuntu:/home/orin#
root@ubuntu:/home/orin#
root@ubuntu:/home/orin# arecord -D hw:APE,0 -c 1 -r 48000 -f S16_LE -d 15 789.wav
Recording WAVE ‘789.wav’ : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
arecord: pcm_read:2178: read error: Input/output error
root@ubuntu:/home/orin#

This is my DTS file
tegra234-p3737-audio.dtsi (8.9 KB)

The use of “cat /sys/kernel/debug/tracing/trace_pipe” command without any output, has been stuck in there
7
8

This is my pinconf-groups file
pinconf-groups.txt (60.6 KB)

Hi,
I do not know the specific reason for this problem, and I am looking forward to your reply.

Hi,
The command provided is only for playback. Please use the below controls for recording.

amixer -c APE cset name=“ADMAIF1 Mux” “I2S1”
arecord -D hw:APE,0 -c 1 -r 48000 -f S16_LE -d 15 789.wav

Hi,
I follow the above command to operate, but still “arecord: pcm_read:2178: read error: Input/output error” error message, thank you!


2

Hi,
Then you might need to check the routing and widgets config in DTS.

	nvidia-audio-card,widgets =

// “Microphone”, “nau Mic”,
“Headphone”, “nau Headphone”,
“Line”, “nau Line In”,
“Line”, “nau Line Out”;
nvidia-audio-card,routing =
“nau Headphone”, “nau HPOL”,
“nau Headphone”, “nau HPOR”,
“nau DDACL”, “nau Playback”,
“nau DDACR”, “nau Playback”,
// “nau DACL Mux”, “nau Mic”,
// “nau DACR Mux”, “nau Mic”,
// “nau MICBIAS”, “nau Mic”,
“nau Capture”, “nau ADC”;

I see capture related configs are commented. Can you cross check on the above entries in DT.

Hi,
I changed both widgets and routing and got the same error. Here is a screenshot of my DTS and codec-driven widgets

static const struct snd_soc_dapm_widget nau8825_dapm_widgets = {
SND_SOC_DAPM_AIF_OUT(“AIFTX”, “Capture”, 0, NAU8825_REG_I2S_PCM_CTRL2,
15, 1),

SND_SOC_DAPM_INPUT("MIC"),
SND_SOC_DAPM_MICBIAS("MICBIAS", NAU8825_REG_MIC_BIAS, 8, 0),

SND_SOC_DAPM_PGA("Frontend PGA", NAU8825_REG_POWER_UP_CONTROL, 14, 0,
	NULL, 0),

SND_SOC_DAPM_ADC_E("ADC", NULL, SND_SOC_NOPM, 0, 0,
	nau8825_adc_event, SND_SOC_DAPM_POST_PMU |
	SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("ADC Clock", NAU8825_REG_ENA_CTRL, 7, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("ADC Power", NAU8825_REG_ANALOG_ADC_2, 6, 0, NULL,
	0),

/* ADC for button press detection. A dapm supply widget is used to
 * prevent dapm_power_widgets keeping the codec at SND_SOC_BIAS_ON
 * during suspend.
 */
SND_SOC_DAPM_SUPPLY("SAR", NAU8825_REG_SAR_CTRL,
	NAU8825_SAR_ADC_EN_SFT, 0, NULL, 0),

SND_SOC_DAPM_PGA_S("ADACL", 2, NAU8825_REG_RDAC, 12, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("ADACR", 2, NAU8825_REG_RDAC, 13, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("ADACL Clock", 3, NAU8825_REG_RDAC, 8, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("ADACR Clock", 3, NAU8825_REG_RDAC, 9, 0, NULL, 0),

SND_SOC_DAPM_DAC("DDACR", NULL, NAU8825_REG_ENA_CTRL,
	NAU8825_ENABLE_DACR_SFT, 0),
SND_SOC_DAPM_DAC("DDACL", NULL, NAU8825_REG_ENA_CTRL,
	NAU8825_ENABLE_DACL_SFT, 0),
SND_SOC_DAPM_SUPPLY("DDAC Clock", NAU8825_REG_ENA_CTRL, 6, 0, NULL, 0),

SND_SOC_DAPM_MUX("DACL Mux", SND_SOC_NOPM, 0, 0, &nau8825_dacl_mux),
SND_SOC_DAPM_MUX("DACR Mux", SND_SOC_NOPM, 0, 0, &nau8825_dacr_mux),

SND_SOC_DAPM_PGA_S("HP amp L", 0,
	NAU8825_REG_CLASSG_CTRL, 1, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("HP amp R", 0,
	NAU8825_REG_CLASSG_CTRL, 2, 0, NULL, 0),

SND_SOC_DAPM_PGA_S("Charge Pump", 1, NAU8825_REG_CHARGE_PUMP, 5, 0,
	nau8825_pump_event, SND_SOC_DAPM_POST_PMU |
	SND_SOC_DAPM_PRE_PMD),

SND_SOC_DAPM_PGA_S("Output Driver R Stage 1", 4,
	NAU8825_REG_POWER_UP_CONTROL, 5, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("Output Driver L Stage 1", 4,
	NAU8825_REG_POWER_UP_CONTROL, 4, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("Output Driver R Stage 2", 5,
	NAU8825_REG_POWER_UP_CONTROL, 3, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("Output Driver L Stage 2", 5,
	NAU8825_REG_POWER_UP_CONTROL, 2, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("Output Driver R Stage 3", 6,
	NAU8825_REG_POWER_UP_CONTROL, 1, 0, NULL, 0),
SND_SOC_DAPM_PGA_S("Output Driver L Stage 3", 6,
	NAU8825_REG_POWER_UP_CONTROL, 0, 0, NULL, 0),

SND_SOC_DAPM_PGA_S("Output DACL", 7,
	NAU8825_REG_CHARGE_PUMP, 8, 1, nau8825_output_dac_event,
	SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_PGA_S("Output DACR", 7,
	NAU8825_REG_CHARGE_PUMP, 9, 1, nau8825_output_dac_event,
	SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),

/* HPOL/R are ungrounded by disabling 16 Ohm pull-downs on playback */
SND_SOC_DAPM_PGA_S("HPOL Pulldown", 8,
	NAU8825_REG_HSD_CTRL, 0, 1, NULL, 0),
SND_SOC_DAPM_PGA_S("HPOR Pulldown", 8,
	NAU8825_REG_HSD_CTRL, 1, 1, NULL, 0),

/* High current HPOL/R boost driver */
SND_SOC_DAPM_PGA_S("HP Boost Driver", 9,
	NAU8825_REG_BOOST, 9, 1, NULL, 0),

/* Class G operation control*/
SND_SOC_DAPM_PGA_S("Class G", 10,
	NAU8825_REG_CLASSG_CTRL, 0, 0, NULL, 0),

SND_SOC_DAPM_OUTPUT("HPOL"),
SND_SOC_DAPM_OUTPUT("HPOR"),

};

static const struct snd_soc_dapm_route nau8825_dapm_routes = {
{“Frontend PGA”, NULL, “MIC”},
{“ADC”, NULL, “Frontend PGA”},
{“ADC”, NULL, “ADC Clock”},
{“ADC”, NULL, “ADC Power”},
{“AIFTX”, NULL, “ADC”},

{"DDACL", NULL, "Playback"},
{"DDACR", NULL, "Playback"},
{"DDACL", NULL, "DDAC Clock"},
{"DDACR", NULL, "DDAC Clock"},
{"DACL Mux", "DACL", "DDACL"},
{"DACL Mux", "DACR", "DDACR"},
{"DACR Mux", "DACL", "DDACL"},
{"DACR Mux", "DACR", "DDACR"},
{"HP amp L", NULL, "DACL Mux"},
{"HP amp R", NULL, "DACR Mux"},
{"Charge Pump", NULL, "HP amp L"},
{"Charge Pump", NULL, "HP amp R"},
{"ADACL", NULL, "Charge Pump"},
{"ADACR", NULL, "Charge Pump"},
{"ADACL Clock", NULL, "ADACL"},
{"ADACR Clock", NULL, "ADACR"},
{"Output Driver L Stage 1", NULL, "ADACL Clock"},
{"Output Driver R Stage 1", NULL, "ADACR Clock"},
{"Output Driver L Stage 2", NULL, "Output Driver L Stage 1"},
{"Output Driver R Stage 2", NULL, "Output Driver R Stage 1"},
{"Output Driver L Stage 3", NULL, "Output Driver L Stage 2"},
{"Output Driver R Stage 3", NULL, "Output Driver R Stage 2"},
{"Output DACL", NULL, "Output Driver L Stage 3"},
{"Output DACR", NULL, "Output Driver R Stage 3"},
{"HPOL Pulldown", NULL, "Output DACL"},
{"HPOR Pulldown", NULL, "Output DACR"},
{"HP Boost Driver", NULL, "HPOL Pulldown"},
{"HP Boost Driver", NULL, "HPOR Pulldown"},
{"Class G", NULL, "HP Boost Driver"},
{"HPOL", NULL, "Class G"},
{"HPOR", NULL, "Class G"},

};
Can you help me sort out the problem? Thank you very much.

Test after adding below entry in nvidia-audio-card,routing

“nau MIC”, “nau Mic”,

Hi,
Add “nau MIC” ,“nau Mic” according to your idea, after , no error will be reported during recording, but when the file is played, the file has no sound. My knowledge of this area is relatively weak, and I don’t know what the specific problem is.


5

Hi,
Is your captured file plays for the same duration you captured?. Can you confirm what is the data pattern in the capture file. is it all zero or some junk values?

If captured file duration is proper, then you need to check if codec mixer controls like volume or gain missing