Add PDM Microphone with device tree overlay

Hello,

we try to connect a pdm digital microphone the the apalis imx8 connected to the Pins 200 (Clock) and 202 (DAP1_D_IN).
Is that possible?
How can we adjust a device tree overlay to connect that correctly?

Software summary

Bootloader: U-Boot
Kernel version: 5.15.129-6.1.0-devel+git.d6880bf83a40 #1 SMP PREEMPT Mon Dec 4 14:11:03 UTC 2023
Kernel command line: root=PARTUUID=65183627-02 ro rootwait console=tty1 console=ttyLP1,115200 consoleblank=0 earlycon quiet fbcon=map:1 drm.edid_firmware=edid/1920x1080_50hz_123750khz.bin
Distro name: NAME=“LM OpenGL ES distro”
Distro version: VERSION_ID=6.1.0-devel-20240320071147-build.0
Hostname: apalis-imx8-lm-DBG

Hardware info


HW model: Toradex Apalis iMX8QM V1.1 on Apalis Evaluation Board
Toradex version: 0047 V1.1B
Serial number: 06738708
Processor arch: aarch64

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Yes, it is possible to connect a PDM digital microphone to the Apalis iMX8 and configure it using a device tree overlay. Below are the steps to create a device tree overlay to connect the PDM microphone to the specified pins (200 for Clock and 202 for DAP1_D_IN).

Steps to Create a Device Tree Overlay

  1. Create the Device Tree Overlay Source File:
    Create a new file, for example, pdm-mic-overlay.dts.

  2. Define the Overlay Header:
    The header should include the /plugin/; directive and the target compatible device.

    /dts-v1/;
    /plugin/;
    
    / {
        compatible = "toradex,apalis-imx8";
    };
    
  3. Define the Pin Control Node:
    Define the pin control settings for the PDM microphone pins.

    &iomuxc {
        pinctrl_pdm_mic: pdm_micgrp {
            fsl,pins = <
                MX8QM_I2S0_TXC_LSIO_GPIO3_IO20 0x1c0 /* Pin 200: Clock */
                MX8QM_I2S0_RXD_LSIO_GPIO3_IO22 0x1c0 /* Pin 202: DAP1_D_IN */
            >;
        };
    };
    
  4. Configure the Audio Interface:
    Configure the audio interface to use the PDM microphone.

    &sai1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_pdm_mic>;
        status = "okay";
    
        pdm_mic: pdm-mic {
            compatible = "pdm-microphone";
            clocks = <&clks IMX8QM_CLK_SAI1>;
            clock-names = "pdm_clk";
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_pdm_mic>;
            status = "okay";
        };
    };
    
  5. Compile the Device Tree Overlay:
    Use the Device Tree Compiler (DTC) to compile the overlay source file into a binary overlay file (.dtbo).

    dtc -I dts -O dtb -o pdm-mic-overlay.dtbo pdm-mic-overlay.dts
    
  6. Deploy the Device Tree Overlay:
    Copy the compiled .dtbo file to the boot partition of your Apalis iMX8 module.

    cp pdm-mic-overlay.dtbo /media/boot/
    
  7. Enable the Device Tree Overlay:
    Edit the overlays.txt file located on the boot partition to include the new overlay.

    echo "pdm-mic-overlay.dtbo" >> /media/boot/overlays.txt
    
  8. Sync and Reboot:
    Ensure the changes are written to the file system and reboot the board.

    sync
    reboot
    

Summary

By following these steps, you should be able to connect and configure a PDM digital microphone to the Apalis iMX8 using a device tree overlay. This configuration assumes that the PDM microphone is compatible and that the necessary drivers are available in the kernel. If additional configuration or driver support is needed, you may need to adjust the overlay or kernel configuration accordingly.

Please, also check if these links can help you solve your problem:

https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/165163/1/i.MX_Linux_Release_Notes.pdf.

Hello @abest,

Welcome to the Toradex Community!

Before answering your question, I would like to recommend that you use a newer version of the Toradex BSP as a base.
BSP 6.1.0 is the first version of BSP 6 with support for the Apalis iMX8, therefore it still contains a few problems that were fixed in subsequent releases.
You can view more details about what was fixed in the issue tracker: Toradex System/Computer on Modules - Linux BSP Release


Edit:

Unfortunately, the Apalis iMX8 does not support PDM microphones.
To use such a microphone with it, an external codec with support for PDM microphones would be needed.
Some other modules, such as the Verdin iMX8M Plus do support PDM microphones, but none that are pin-compatible with the Apalis iMX8.

Best Regards,
Bruno

Hi Bruno,

thank you for the quick response.

We intend to use the Infineon IM72D128 as PDM microphone.
I will try use your recommendations and will set up the device tree overlay for that microphone.

Best regards,
Alexander

Hello @abest,

I apologize for the confusion, my previous post is incorrect.
The Apalis iMX8 in fact does not natively support PDM microphones.

To use such microphones you would need an external codec that has support for it.

The Verdin iMX8M Plus modules do support PDM microphones, but it is not pin-compatible with the Apalis iMX8.

I will edit my previous post to reflect this lack of support so other users are not confused by this.

Best Regards,
Bruno