iMX8MP MAX98357A

Hi,

I have a custom carrier board with an imx8mp SOM installed. I am trying to get the SOM to communicate with a MAX98357a audio amplifier connected to pins 30 (BCLK), 32 (SYNC), 34 (DOUT).

I have created the following overlay however when I inspect the output of dmesg I get the following message

/plugin/;

#include <dt-bindings/clock/imx8mp-clock.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include "imx8mp-pinfunc.h"
#include "dt-bindings/pwm/pwm.h"

/ {
	compatible = "toradex,verdin-imx8mp-wifi-dev",
    	"toradex,verdin-imx8mp-wifi",
    	"toradex,verdin-imx8mp",
    	"fsl,imx8mp";
};

&{/} {
    codec_ext: max98357a {
        compatible = "maxim,max98357a";
        #sound-dai-cells = <0>;
        status = "okay";
        pinctrl-names = "default";
    };

	sound {
    	compatible = "simple-audio-card";
    	status = "okay";
    	simple-audio-card,name = "max98357a";
	
    	simple-audio-card,format = "i2s";
    	simple-audio-card,bitclock-master = <&dailink_master_cpu>;
    	simple-audio-card,frame-master = <&dailink_master_cpu>;
	
    	simple-audio-card,codec {
        	sound-dai = <&codec_ext>;
        	dai-tdm-slot-num = <2>;
        	dai-tdm-slot-width = <16>;
    	};
	
    	dailink_master_cpu: simple-audio-card,cpu {
        	sound-dai = <&sai1>;
    	}; 
    };
};

&nau8822_1a {
    status = "disabled";
};


&sai1 {
    status = "okay";
    pinctrl-0 = <&pinctrl_sai1>;
    pinctrl-names = "default";
    
    assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <12288000>;
}; 

[ 1.432728] No soundcards found.

Any help would be greatly appreciated, thank you in advance.

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your detailed question.

You are on the right track, but a few modifications are needed to allow the i.MX8MP to interface properly with the MAX98357A via I2S, especially on Verdin pin 30 (BCLK), 32 (SYNC), and 34 (DOUT). The “No soundcards found” message typically means that the audio subsystem is missing a compatible card or that clocks and pinmux are not set up correctly.

Here’s a working approach, based on a successful example with this hardware combination:

1. Use a Dummy Codec First

The MAX98357A does not require I2C control, so you can initially use the dummy codec (spdif-dit) driver for testing. After that you can further tune or revert the codec settings to "maxim,max98357a" if you wish.

Example node:

max98357a {
    compatible = "linux,spdif-dit"; // For initial testing; can switch to "maxim,max98357a"
    #sound-dai-cells = <0>;
};

Reference: Community Example

2. Set up the SAI1 Clocks

&sai1 {
    status = "okay";
    pinctrl-0 = <&pinctrl_sai1_bclk_lrclk_dout>;
    pinctrl-names = "default";

    assigned-clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1_SEL>, 
                      <&clk IMX8MP_CLK_SAI1>;
    assigned-clock-parents = <&clk IMX8MP_CLK_SAI1_ROOT>, 
                            <&clk IMX8MP_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <12288000>, <0>;
};

Reference: Community Example

3. Pin Configuration

Ensure the pins are muxed for SAI1 signals correctly:

&iomuxc {
    pinctrl_sai1_bclk_lrclk_dout: pinctrl_sai1_bclk_lrclk_dout {
        fsl,pins =
            <MX8MP_IOMUXC_SAI5_MCLK__AUDIOMIX_SAI1_TX_BCLK 0x1d6>,
            <MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_SAI1_TX_SYNC 0x1d6>,
            <MX8MP_IOMUXC_SAI5_RXFS__AUDIOMIX_SAI1_TX_DATA00 0x96>;
    };
};

Reference: Community Example

4. Complete Device Tree Overlay Example

Here is how you can bring it all together (keep your compatible settings, but update the audio and pins as below):

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx8mp-clock.h>
#include "imx8mp-pinfunc.h"

&{/} {
    max98357a: max98357a {
        compatible = "linux,spdif-dit";
        #sound-dai-cells = <0>;
    };

    sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "Audio Output via MAX98357A";
        simple-audio-card,format = "i2s";
        simple-audio-card,bitclock-master = <&dailink_master_cpu>;
        simple-audio-card,frame-master = <&dailink_master_cpu>;

        simple-audio-card,codec {
            sound-dai = <&max98357a>;
        };

        dailink_master_cpu: simple-audio-card,cpu {
            sound-dai = <&sai1>;
        };
    };
};

&sai1 {
    status = "okay";
    pinctrl-0 = <&pinctrl_sai1_bclk_lrclk_dout>;
    pinctrl-names = "default";
    assigned-clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI1_MCLK1_SEL>, <&clk IMX8MP_CLK_SAI1>;
    assigned-clock-parents = <&clk IMX8MP_CLK_SAI1_ROOT>, <&clk IMX8MP_AUDIO_PLL1_OUT>;
    assigned-clock-rates = <12288000>, <0>;
};

&iomuxc {
    pinctrl_sai1_bclk_lrclk_dout: pinctrl_sai1_bclk_lrclk_dout {
        fsl,pins =
            <MX8MP_IOMUXC_SAI5_MCLK__AUDIOMIX_SAI1_TX_BCLK 0x1d6>,
            <MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_SAI1_TX_SYNC 0x1d6>,
            <MX8MP_IOMUXC_SAI5_RXFS__AUDIOMIX_SAI1_TX_DATA00 0x96>;
    };
};

Reference: Community Example

Note: This config provides a 48kHz clock (and related rates). For other sample rates you may need to adjust the assigned clocks.

5. Disabling Default Codec

You have correctly disabled the default codec (like nau8822) with:

&nau8822_1a {
    status = "disabled";
};

Summary

  • Update the codec node to use the dummy codec for initial verification.
  • Update all SAI1 and pinmux settings as above.
  • Recompile and load your overlay.
  • After reboot, check aplay -l or arecord -l and dmesg for new soundcard.

If you follow these recommendations, your soundcard should be detected and you can proceed with audio output testing.

Related resource:
https://community.toradex.com/t/i2s-output-without-codec/26845

Best regards, Toradex AI Assistant.

Hello @DAH,

Can you please check the following setup I described in this post: Help Req for MAX98357 on custom carrier board - #7 by bruno.tx

There, the configuration is for the Verdin iMX8MM, but this should only bring slight changes to the device tree.
The other alsa configurations should still be valid for your use.

Best Regards,
Bruno

Hello @DAH,

Let me also add that our partner Carriertronic made a public guide on how to use this DAC with the Verdin iMX8MP.
This documentation is available here: 4Devs: Einstieg Tutorials und Hilfen fĂĽr Toradex und Torizon

Best Regards,
Bruno

Hi,

Thank you very much. I have managed to get my device working.

Kind Regards

1 Like