Dear Support,
I have following questions regarding AK4621 audio codec deployed on Mallow Board with AM62. I build the Yocto tdx-reference-multimedia-image with custom layer. It provides ak4621 codec (custom made and set explicitely to 48000 Hz) and patch the device tree as follows:
diff --git a/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi b/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
index a82bf2f7485e8..de3bdee4dfcd9 100644
--- a/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am62-verdin-dev.dtsi
@@ -11,35 +11,26 @@
/ {
sound {
compatible = "simple-audio-card";
- simple-audio-card,bitclock-master = <&codec_dai>;
- simple-audio-card,format = "i2s";
- simple-audio-card,frame-master = <&codec_dai>;
+ simple-audio-card,bitclock-master = <&codec_dai>;
+ simple-audio-card,format = "i2s";
+ simple-audio-card,frame-master = <&codec_dai>;
simple-audio-card,mclk-fs = <256>;
- simple-audio-card,name = "verdin-nau8822";
+ simple-audio-card,name = "ak4621";
simple-audio-card,routing =
- "Headphones", "LHP",
- "Headphones", "RHP",
- "Speaker", "LSPK",
- "Speaker", "RSPK",
- "Line Out", "AUXOUT1",
- "Line Out", "AUXOUT2",
- "LAUX", "Line In",
- "RAUX", "Line In",
- "LMICP", "Mic In",
- "RMICP", "Mic In";
+ "Headphones", "LOUT1",
+ "Headphones", "ROUT1",
+ "LIN1", "Line In",
+ "RIN1", "Line In";
simple-audio-card,widgets =
"Headphones", "Headphones",
- "Line Out", "Line Out",
- "Speaker", "Speaker",
- "Microphone", "Mic In",
"Line", "Line In";
codec_dai: simple-audio-card,codec {
- sound-dai = <&nau8822_1a>;
+ sound-dai = <&ak4621>;
};
- simple-audio-card,cpu {
+ cpu_dai: simple-audio-card,cpu {
sound-dai = <&mcasp0>;
};
};
};
@@ -101,17 +96,6 @@ &main_gpio0 {
&main_i2c1 {
status = "okay";
- /* Audio Codec */
- nau8822_1a: audio-codec@1a {
- compatible = "nuvoton,nau8822";
- reg = <0x1a>;
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_i2s1_mclk>;
- clock-names = "mclk";
- clocks = <&audio_refclk1>;
- #sound-dai-cells = <0>;
- };
-
/* IO Expander */
gpio_expander_21: gpio@21 {
compatible = "nxp,pcal6416";
@@ -159,6 +143,16 @@ &main_mcan0 {
/* Verdin SPI_1 */
&main_spi1 {
status = "okay";
+ /* Audio Codec */
+ ak4621: audio-codec@0 {
+ compatible = "asahi-kasei,ak4621";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2s1_mclk>;
+ clock-names = "mclk";
+ clocks = <&audio_refclk1>;
+ reg = <0>;
+ #sound-dai-cells = <0>;
+ };
};
/* Verdin UART_3 */
--
2.34.1
The codec is added via second patch. The settings in dt should be the same as with nau8822 (default to dev board), but the codec is connected via spi instead of i2c. The system recognizes the codec, “arecord -l” lists the soundcard. However, if I call “cat sys/kernel/debug/clk/clk_sumarry” I get this info:
It seems the audio_refclk is set to 12345689, which is wrong. I want to set the frequency to 12288000.
I also tried this patch to set it explicitely:
codec_dai: simple-audio-card,codec {
- sound-dai = <&nau8822_1a>;
+ sound-dai = <&ak4621>;
+ clocks = <&audio_refclk1>;
+ system-clock-frequency = <12288000>;
+ mclk-fs = <256>;
};
When I run “arecord out.wav -f S24_LE -r 48000”, it freezes and when I cancel it, it outputs pcm_error:
The user side of alsa config should be correct. From what I have understood, the problem is probably with the clock setting. My question is, does the device tree settings seem correct?
It is possible that the problem is inside the codec .c file. After some debugging, the codec’s function “ak4621_dai_set_sysclk” is run first with correct 12288000 value but then it is called once again with value of 0:
I yet don’t know why. If the device tree settings is correct, I will try to modify the codec file.
Thank you.
Best regards
Matej I.