Last edited 2 years ago

SAI Linux driver

Applicable for STM32MP13x lines, STM32MP15x lines

1. Article purpose[edit source]

This article introduces the SAI Linux® driver for the SAI internal peripheral.

2. Short Description[edit source]

The SAI[1] Linux driver is an ASoC CPU DAI driver implemented in the Linux ALSA framework.

To be able to manage different audio stream sampling rates, the SAI driver requests two clocks which can be used as parent clocks of the SAI peripheral kernel clock. This peripheral kernel clock is shared by the two SAI sub-blocks, which involves that these two sub-blocks have to run with compatible sampling rates, when they are active at the same time. Details on the peripheral clock configuration is available in the SAI device tree configuration.

3. Configuration[edit source]

3.1. Kernel Configuration[edit source]

Activate the SAI[1] Linux driver in the kernel configuration using the Linux Menuconfig tool: Menuconfig or how to configure kernel.

[*] Device Drivers
    [*] Sound card support
        [*] Advanced Linux Sound Architecture
            [*] ALSA for SoC audio support
                STMicroelectronics STM32 SOC audio support
	             [*] STM32 SAI interface (Serial Audio Interface) support

3.2. Device tree[edit source]

Refer to the SAI device tree configuration article when configuring the SAI Linux kernel driver.

4. How to use[edit source]

The SAI Linux driver can be accessed from userland through an ALSA device. Refer to ALSA overview for information on how to list and use ALSA devices.

5. How to trace and debug[edit source]

The debugfs and procfs file system can be checked to get information on the SAI driver and the resources it uses. A non-exhaustive list of these file system entries is provided below. Refer to ALSA overview for more details on debugging tools.

  • debugfs entries:
$ cat /sys/kernel/debug/regmap/xxx.audio-controller/registers
  • procfs entries:
$ cat /proc/interrupts

6. Source code location[edit source]

The STM32 SAI peripheral includes two independent audio subblocks that share common resources. The driver source code reflects this architecture.

sound/soc/stm/stm32_sai.c : handles common resources such as clock, interrupt, reset and shared register.

sound/soc/stm/stm32_sai_sub.c : handles the resources dedicated to each subblock.

7. References[edit source]