“DFSDM Linux driver”的版本间的差异

来自百问网嵌入式Linux wiki
第6行: 第6行:
  
 
== Short Description ==
 
== Short Description ==
The DFSDM Linux<sup>&reg;</sup> driver (kernel space) is based on the [[IIO overview|IIO]] and [[ALSA overview|ALSA]] frameworks.
+
DFSDM Linux<sup>&reg;</sup>驱动程序(内核空间)基于 [[IIO overview|IIO]] [[ALSA overview|ALSA]]框架。
It offers various modes:
+
它提供多种模式:
# '''IIO direct mode''': single capture on a channel
+
# '''IIO直接模式''': 在一个频道上进行单次捕获
# '''IIO software buffer''': capture one or more channels
+
# '''IIO软件缓冲区''': 捕获一个或多个频道
# '''IIO triggered buffer mode''': capture on one or more channels using triggers<br/>It uses hardware triggers available in IIO. See [[TIM Linux driver]] and [[LPTIM Linux driver]].
+
# '''IIO触发缓冲模式''':使用触发器在一个或多个通道上捕获<br/>它使用IIO中可用的硬件触发器。请参见[[TIM Linux driver]] and [[LPTIM Linux driver]].
  
It offers an extended API<ref name="stm32-dfsdm-adc-h">{{CodeSource | Linux kernel | include/linux/iio/adc/stm32-dfsdm-adc.h}}, DFSDM IIO custom API</ref> for audio usage which allows '''PDM microphones capture''' through a SPI interface.
+
它提供了扩展的API<ref name="stm32-dfsdm-adc-h">{{CodeSource | Linux kernel | include/linux/iio/adc/stm32-dfsdm-adc.h}}, DFSDM IIO custom API</ref> for audio usage which allows ''',它允许通过SPI接口捕获'''PDM麦克风'''。
  
 
== Configuration ==
 
== Configuration ==

2020年11月9日 (一) 15:47的版本

Article purpose

本文的目的是介绍用于DFSDM internal peripheral的Linux®驱动程序:

  • 驱动程序支持哪些DFSDM功能
  • 如何配置,使用和调试它
  • 驱动程序的结构是什么,在哪里可以找到源代码。

Short Description

DFSDM Linux®驱动程序(内核空间)基于 IIOALSA框架。 它提供多种模式:

  1. IIO直接模式: 在一个频道上进行单次捕获
  2. IIO软件缓冲区: 捕获一个或多个频道
  3. IIO触发缓冲模式:使用触发器在一个或多个通道上捕获
    它使用IIO中可用的硬件触发器。请参见TIM Linux driver and LPTIM Linux driver.

它提供了扩展的API[1] for audio usage which allows ,它允许通过SPI接口捕获PDM麦克风

Configuration

Kernel configuration

Activate the DFSDM Linux® driver in the kernel configuration by using the menuconfig tool.

IIO driver

Configuration flag: CONFIG_STM32_DFSDM_ADC

Device Drivers  --->
   <*> Industrial I/O support  --->
      Analog to digital converters  --->
         <*> STMicroelectronics STM32 dfsdm adc
         <*>   STMicroelectronics STM32 adc                        # DFSDM ADC IIO driver

When using the DFSDM ADC IIO driver (only), the user must also enable the driver for the external analog front-end (e.g. sigma delta modulator). The generic sigma delta modulators driver may be used for instance (CONFIG_SD_ADC_MODULATOR):

Device Drivers  --->
   <*> Industrial I/O support  --->
      Analog to digital converters  --->
         <*> Generic sigma delta modulator                         # sigma delta modulator driver

Audio driver

Configuration flag: CONFIG_SND_SOC_STM32_DFSDM (Note: This configuration depends on CONFIG_STM32_DFSDM_ADC)

Device Drivers  --->
   <*> Sound card support  --->
      <*>   Advanced Linux Sound Architecture  --->
         <*>   ALSA for SoC audio support  --->
            STMicroelectronics STM32 SOC audio support  --->
               <*> SoC Audio support for STM32 DFSDM               # DFSDM Audio driver for digital microphone capture

Device tree

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

How to use

IIO driver

In "IIO direct mode", the conversion result can be read directly from sysfs, see: How to do a simple ADC conversion using the sysfs interface.

In "IIO triggered buffer mode", the configuration must be performed by using sysfs first. Then, character device (/dev/iio:deviceX) is used to read data, see Convert one or more channels using triggered buffer mode.

For information on the standard IIO consumer interface, please refer to How to use IIO kernel API which gives an example of the IIO consumer kernel API.

Audio driver

The DFSDM 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.

How to trace and debug

How to monitor

The DFSDM driver uses resources such as clocks and GPIOs.

How to monitor with debugfs

The DFSDM registers are accessed using REGMAP by DFSDM Linux® driver.

It comes with 调试文件系统(debugfs) entries to dump registers:

$ cd /sys/kernel/debug/regmap/4400d000.dfsdm/
$ cat registers
000: 00000000
004: 00000000
008: 00000000

Other ways to monitor

  • Man can check the DFSDM interrupts and/or the DFSDM DMA interrupts:
$ cat /proc/interrupts
           CPU0       CPU1
...
 99:          0          0     GIC-0 142 Level     4400d000.dfsdm:filter@0
100:          0          0     GIC-0 143 Level     4400d000.dfsdm:filter@1
101:          0          0     GIC-0 144 Level     4400d000.dfsdm:filter@2
...

How to trace

IIO driver

Refer to How to trace with dynamic debug for how to enable the debug logs in the driver and in the framework.

Board $> dmesg -n8
Board $> echo "file drivers/iio/adc/stm32-dfsdm* +p" > /sys/kernel/debug/dynamic_debug/control

To enable dynamic debug at boot time, append the following arguments on the kernel command line:

loglevel=8 dyndbg="file drivers/iio/adc/stm32-dfsdm* +p"

Audio driver

Refer to ALSA_overview#How_to_trace for details on trace tools.

How to debug

Audio driver

Refer to ALSA_overview#How_to_debug for details on debugging tools.

Source code location

It is composed of:

See also sigma delta modulator driver: