iMX8MM stuck with audio codec MAX9867

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMX8MM stuck with audio codec MAX9867

Jump to solution
1,438 Views
dpog
Contributor IV

I'm trying to integrate a MAX9867 audio codec in our custom imx8m mini board, but I'm stuck when trying to test the audio output with ALSA speaker-test:

root@evalboard:~# speaker-test

speaker-test 1.2.6

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
[ 18.948357] max9867 1-0018: ASoC: error at snd_soc_dai_hw_params on max9867-aif1: -22
[ 18.960141] 30050000.sai-max9867-aif1: ASoC: error at __soc_pcm_hw_params on 30050000.sai-max9867-aif1: -22
ALSA lib ../../../alsa-lib-1.2.6.1/src/pcm/pcm_direct.c:1284:(snd1_pcm_direct_initialize_slave) unable to install hw params
ALSA lib ../../../alsa-lib-1.2.6.1/src/pcm/pcm_dmix.c:1044:(snd_pcm_dmix_open) unable to initialize slave
Playback open error: -22,Invalid argument
root@evalboard:~#

 

my device tree looks as follows, I'm not quite sure what to do with the fsl,dataline, so it's commented out:

sound_card: sound-card {
    compatible = "simple-audio-card";
    simple-audio-card,name = "max9867";
    simple-audio-card,format = "i2s";
    simple-audio-card,frame-master = <&dailink_master>;
    simple-audio-card,bitclock-master = <&dailink_master>;

    dailink_master: simple-audio-card,codec {
        clocks = <&clk IMX8MM_CLK_SAI5_ROOT>;
        sound-dai = <&audio_codec>;
    };

    simple-audio-card,cpu {
        sound-dai = <&sai5>;
    };
};
 
&i2c2 {
    clock-frequency = <400000>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_i2c2>;
    status = "okay";

    audio_codec: audio_codec@18 {
        #sound-dai-cells = <0>;
        compatible = "maxim,max9867";
        clocks = <&clk IMX8MM_CLK_SAI5_ROOT>;
        reg = <0x18>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai5_mclk>;
        status = "okay";
    };
};

&sai5 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai5>;

    // fsl,dataline = <1 0xff 0xff 2 0xff 0x11>;
};
 
pinctrl_sai5: sai5grp {
    fsl,pins = <
        MX8MM_IOMUXC_SAI3_RXD_SAI5_RX_DATA0     0x1f
        MX8MM_IOMUXC_SAI5_RXD3_SAI5_TX_DATA0    0x30
        MX8MM_IOMUXC_SAI2_RXC_SAI5_TX_BCLK      0x1f
        MX8MM_IOMUXC_SAI5_RXD1_SAI5_TX_SYNC     0x1f
    >;
};

pinctrl_sai5_mclk: sai5mclkgrp {
    fsl,pins = <
        MX8MM_IOMUXC_SAI2_MCLK_SAI5_MCLK        0x1f
    >;
};
 
Am I missing some dt configurations or are wrong ones set?
Labels (1)
0 Kudos
Reply
1 Solution
1,192 Views
dpog
Contributor IV
Sorry for my delayed reply, I lost track of this thread. The issue was resolved by changing the hardware, apparently there was an error in the design that switched two clock signals. We wired them correctly and got the output from the speakers.

View solution in original post

0 Kudos
Reply
8 Replies
1,322 Views
JorgeCas
NXP TechSupport
NXP TechSupport

We do not have an specific device tree configuration to the MAX9867 codec, did you check with vendor for a device tree example?

We have a device tree from the EVK board and also the simple-card.yaml that you could use as a reference for your design.

Best regards.

0 Kudos
Reply
1,294 Views
dpog
Contributor IV
I used the example given in the kernel docs. The codec seems to be working, when I change some settings in alsamixer I hear clicking noises on the speakers.

So I'm guessing the problem might be the SAI, do I need to configure it to use I2S? Or is it done by the simple-card format?

Best regards
0 Kudos
Reply
1,286 Views
JorgeCas
NXP TechSupport
NXP TechSupport

The device tree has the necessary configuration to use the corresponding driver and be correctly detected and used on the OS.

Are you able to see the sent data to the codec when you hear the noises from the speaker?

Best regards.

0 Kudos
Reply
1,193 Views
dpog
Contributor IV
Sorry for my delayed reply, I lost track of this thread. The issue was resolved by changing the hardware, apparently there was an error in the design that switched two clock signals. We wired them correctly and got the output from the speakers.
0 Kudos
Reply
1,396 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello, I hope you are doing well.

I suggest you take a look at Chapter 16 Porting Audio Codecs i.MX Porting Guide.

Best regards.

0 Kudos
Reply
1,384 Views
dpog
Contributor IV
Hi, I did take a look, but it was of no help. For the max9867 i cannot use the imx-wm8962.c, so I took the simple-audio-card as it is done in the imx8mm-evk.dtsi. I also checked the drivers, they all load as expected, the error happens at runtime, most likely when executing ioctl(4, SNDRV_PCM_IOCTL_HW_PARAMS, 0xfff......) : EINVAL

Best regards
0 Kudos
Reply
1,375 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

If you are using a different codec, it is needed to adapt the driver architecture accordingly. The exact adaptation depends on the codec chosen. Please try to check the codec-specific software from the codec vendor.

Best regards.

 

0 Kudos
Reply
1,353 Views
dpog
Contributor IV
The hw_params problem were resolved by adding
assigned-clocks = <&clk IMX8MM_CLK_SAI5>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
assigned-clock-rates = <24576000>;
to the sai5 node.

But still there is no output. Do I need to configure the SAI to work in I2S-Mode? Have not found anything related, so I'm just guessing right now
0 Kudos
Reply