Imx7 MAX98357A Device Tree Settings

Hi all,

I am using an imx7 emmc module and on my carrier board I have the MAX98357a audio amplifier, it is connected to my processor on SAI2.

I think I have successfully built the driver for the max98357a into the Kernel.

I would like to know the device tree settings to include this device. The first entries I have tried are these:

codec: max98357a@0 {
    compatible = "maxim,max98357a";
    #sound-dai-cells = <0>;
};

 &sai2 {
     fsl,mode = "i2s-master";
     pinctrl-names = "default";
     pinctrl-0 = <&pinctrl_sai2>;
     assigned-clocks = <&clks IMX7D_SAI2_ROOT_SRC>,
               <&clks IMX7D_SAI2_ROOT_CLK>;
     assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
     assigned-clock-rates = <0>, <36864000>;
     status = "okay";
 };

This triggers an error during compilation of the dts file: FATAL ERROR: Unable to parse input tree, referring to the max98357a section.

Does anybody have any tips on how to get this working?

Eoin

Hi

I recommend reading through this and also read the referenced presentation by Thomas Petazzoni.

To configure the audio path you usually have three drivers: One for the codec, one for the cpu side HW and one which connects the two together.

Each of the driver is usually configured in a separate node in the device tree. In your case you already did that for the codec driver (max98357a@0) and the cpu driver (&sai2).

For simple cases the ‘generic simple-audio-card’ driver can be used to coordinate the codec and the cpu driver. So you would have to add an additional node which creates a new instance of the simple-audio-card driver.

Note that of course all those drivers need not only the configuration in the device tree but also need to be compiled into the kernel.


I guess that your current device tree compiler message is caused by the new max98357a@0 node which is not inside the root of the device tree. Moving the node within an existing root or create a new one would get you past that error. E.g. adding a new one:

/ {
    codec: max98357a@0 {
        compatible = "maxim,max98357a";
        #sound-dai-cells = <0>;
    };
};

Note that in our imx7 device trees we already use the label ‘codec’ and labels must be unique. So you might want to change the label name to something different, e.g. ‘codec_mono’.

Max

Thanks for the reply, my device tree looks a bit healthier now.

/ {
codec_mono: max98357a@0 {
    compatible = "maxim,max98357a";
    #sound-dai-cells = <0>;
};

	sound1 {
		compatible = "pt,pt10ex-audio";
		pt,model = "pt10ex";
		ssi-controller = <&sai2>;
		codec = <&codec_mono>;
	};

};

&sai2 {
     fsl,mode = "i2s-master";
     pinctrl-names = "default";
     pinctrl-0 = <&pinctrl_sai2>;
     assigned-clocks = <&clks IMX7D_SAI2_ROOT_SRC>,
               <&clks IMX7D_SAI2_ROOT_CLK>;
     assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
     assigned-clock-rates = <0>, <36864000>;
     status = "okay";

 };

The middle part I copied from another topic where I saw somebody trying to get this amplifier working.

I have compiled in the max98357.c driver into my kernel, but I do not understand the other driver that I need, can you tell me which extra driver I need? I did include the file imx-pt10ex,c in linux-toradex/sound/soc/fsl/, this idea I got from link text

Do I need more changes to my device tree?link text

2: https://share.toradex.com/x0ol9ysmr6p845l?direct,Thanks for the reply, my device tree looks a bit healthier now.

/ {
codec_mono: max98357a@0 {
    compatible = "maxim,max98357a";
    #sound-dai-cells = <0>;
};

	sound1 {
		compatible = "pt,pt10ex-audio";
		pt,model = "pt10ex";
		ssi-controller = <&sai2>;
		codec = <&codec_mono>;
	};

};

&sai2 {
     fsl,mode = "i2s-master";
     pinctrl-names = "default";
     pinctrl-0 = <&pinctrl_sai2>;
     assigned-clocks = <&clks IMX7D_SAI2_ROOT_SRC>,
               <&clks IMX7D_SAI2_ROOT_CLK>;
     assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
     assigned-clock-rates = <0>, <36864000>;
     status = "okay";

 };

The middle part I copied from another topic where I saw somebody trying to get this amplifier working.

I have compiled in the max98357.c driver into my kernel, but I do not understand the other driver that I need, can you tell me which extra driver I need? I did include the file imx-pt10ex,c in linux-toradex/sound/soc/fsl/, this idea I got from link text

Do I need more changes to my device tree?link text

Thanks for your Input.

but I do not understand the other driver that I need, can you tell me which extra driver I need? I did include the file imx-pt10ex,c in linux-toradex/sound/soc/fsl/, this idea I got from

I also don’t know what or if this driver is needed. I could not find this driver in our or any Kernel i checked.

Do I need more changes to my device tree?

Did you compile and test the device tree? Please check also arch/arm/boot/dts/imx7-colibri.dtsi for an example.

Best regards,
Jaski