Imx8 How to use DAI audio connection to Codec

We have been trying to add the SSM4567 sound driver to our custom Yocto build. The kernel driver has been added to the kernel configuration file.
Additionally, the DTSI file was modified. There is a suspicion that the DTSI changes are not working.
Could you please assist me in understanding the steps I need to take in order to make this driver work and to be recognized by Linux as a sound card?

In our system, we use iMX8QM. We designed a custom board based on the Apalis Evaluation Board V1.1, which uses the imx8qm SOM. Our custom board changes are adding a few GPIOs and adding a SSM4567.

Following are the changes related to ssm4567.

I have added ssm4567 to i2c3 and it is seen by using command line tools.

> /* Apalis I2C3 (CAM) */
> &i2c3 {
> 	pinctrl-names = "default";
> 	pinctrl-0 = <&pinctrl_lpi2c3>;
> 	#address-cells = <1>;
> 	#size-cells = <0>;
> 	clock-frequency = <100000>;
> 	
> 	ssm4567: ssm4567@34 {
> 		compatible = "ssm4567";
> 		reg = <0x34>;
> 		};
> };

SSM4567 is seen in i2c port, and it is bonded to ssm4567 driver as seen in the Linux command line.

image

I also added message prints to “ssm4567_i2c_probe” function to check if the function is called and it does not return an error. Is is called and does not return an error.

What is not working is defining the sound card on device tree,
Need some help on defining codec and DAI connections in device tree.

 sound {
compatible = "simple-audio-card";
simple-audio-card,bitclock-master = <&dailink_master>;
simple-audio-card,format = "i2s";
simple-audio-card,frame-master = <&dailink_master>;
/* simple-audio-card,mclk-fs = <1>; */
simple-audio-card,name = "ssm4567";
        status = "okay";
 
simple-audio-card,cpu {
sound-dai = <&sai1>;
};
 
dailink_master: simple-audio-card,codec {
clocks = <&mclkout0_lpcg 0>;
sound-dai = <&ssm4567-hifi>; 
};
};

“aplay -l” and alasamixer could not detect it.

b2qt-apalis-imx8:~:>alsamixer
ALSA lib ../../alsa-lib-1.2.6.1/src/confmisc.c:165:(snd_config_get_card) Cannot get card index for apalisimx8qmsgt
cannot open mixer: No such device

And some dmesg logs related :

[    2.227860] asoc-simple-card: probe of sound failed with error -22
[    2.318370] imx-audmix imx-audmix.0: failed to find SAI platform device
[    2.325248] imx-audmix: probe of imx-audmix.0 failed with error -22

Ssm4567 driver:
https://git.yoctoproject.org/linux-yocto-4.6/plain/Documentation/devicetree/bindings/sound/ssm4567.txt

Kernel config changed, added for ssm4567.
CONFIG_SND_SOC_SSM4567=y

The yocto setup uses imx8-apalis-v1.1.dtsi device tree file.
device-trees/imx8-apalis-v1.1.dtsi at toradex_5.4-2.1.x-imx · toradex/device-trees · GitHub

Toradex Apalis iMX8QM V1.1
Kernel version: 5.4.193

Thanks

Hello @ahmetg,

we researched a bit and we will try to build a patch the next days,
and compile the recommendations and sent it to you.

Best Regards,

Matthias

We achieved it to work.

Changed imx8-apalis-v1.1.dtsi file.

added ssm4567 to i2c3 connection,
enabled sai0 clocks and disabled sai1.
And set the values for DAI pins using imx8qm reference manual.

After defining a sound card using “simple-audio-card” it worked. now we can see it as a sound card with "aplay -l " command. And play a wav file using “aplay” command.
Main changes are followings, if anyone needs a similar approach.

sound {
	compatible = "simple-audio-card";
  •   simple-audio-card,name = "ssm4567-hifi";
      simple-audio-card,format = "i2s";
    
  •   simple-audio-card,frame-master = <&ssmcpu>;
    
  •   simple-audio-card,bitclock-master = <&ssmcpu>;
    
  •   simple-audio-card,widgets = "Microphone", "Speaker";
    
  •   simple-audio-card,dai-link {
    
  •   	format = "i2s";
    
  •   	cpu { 
    
  •   		sound-dai = <&sai0>; 
    
  •   	};
    
  •   	ssmcpu: codec {
    
  •   		sound-dai = <&ssm4567>;
    
  •   	};
      };
    

    };

  • ssm4567: ssm4567@34 {

  •   compatible = "ssm4567";
    
  •   reg = <0x34>;
    
  •   #sound-dai-cells = <0>;
    
  •   assigned-clocks = <&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_PLL>,
    
  •   		<&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_SLV_BUS>,
    
  •   		<&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_MST_BUS>,
    
  •   		<&mclkout0_lpcg 0>;
    
  •   assigned-clock-rates = <786432000>, <49152000>, <12288000>, <12288000>;
    
  •   pinctrl-names = "default";
    
  • };

pinctrl_sai0: sai0grp {

  •   	fsl,pins = <
    
  •   		/* Apalis DAP1_SYNC */
    
  •   		/*204 IMX8QM_SPI2_CS1_LSIO_GPIO3_IO11			0x00000021*/
    
  •   		IMX8QM_SPI2_CS1_AUD_SAI0_TXFS			0xC8000040
    
  •   		/* Apalis DAP1_BIT_CLK */
    
  •   		/*200 IMX8QM_SPI0_CS1_LSIO_GPIO3_IO06			0x00000021*/
    
  •   		IMX8QM_SPI0_CS1_AUD_SAI0_TXC			0xC8000040
    
  •   		/* Apalis DAP1_D_OUT */
    
  •   		/*196 IMX8QM_SAI1_RXC_LSIO_GPIO3_IO12			0x00000021*/
    
  •   		IMX8QM_SAI1_RXC_AUD_SAI0_TXD			0xC8000040
    
  •   		/* Apalis DAP1_D_IN */
    
  •   		/*202 IMX8QM_SAI1_RXFS_LSIO_GPIO3_IO14		0x00000021*/
    
  •   		/*hex(0b10001000000000000000000000000000) */
    
  •   		IMX8QM_SAI1_RXFS_AUD_SAI0_RXD			0xC8000040
    
  •   	>;
    

+&sai0 {

  •   #sound-dai-cells = <0>;
    
  •   pinctrl-names = "default";
    
  •   pinctrl-0 = <&pinctrl_sai0>;
    
  •   assigned-clocks = <&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_PLL>,
    
  •   	<&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_SLV_BUS>,
    
  •   	<&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_MST_BUS>,
    
  •   	<&sai1_lpcg 0>; /* FIXME: should be sai1, original code is 0 */
    
  •   /*assigned-clocks = <&clk IMX8QM_SPI0_CS1_AUD_SAI0_TXC>;*/
    
  •   /*assigned-clock-rates = <1411200>, <24576000>, <49152000>;*/
    
  •   assigned-clock-rates = <786432000>, <49152000>, <12288000>, <12288000>;
    
  •   status = "okay";
    

+};

OK great to hear that.