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

来自百问网嵌入式Linux wiki
第6行: 第6行:
  
 
== Short description ==
 
== Short description ==
The ''TIM''<ref name="TIM internal peripheral"/> Linux driver (kernel space) is based on the [[PWM overview|PWM]] and [[IIO overview|IIO]] frameworks. It provides several functionalities:
+
Linux驱动程序(内核空间)“ TIM” <ref name="TIM internal peripheral"/> 基于 [[PWM overview|PWM]] [[IIO overview|IIO]] 框架。 它提供了几种功能:
  
'''MFD driver''':
+
'''MFD驱动程序''':
* handles registers, clock and DMA<ref name="DMA internal peripheral">[[DMA_internal_peripheral]]</ref> resources
+
* 处理寄存器,时钟和DMA<ref name="DMA internal peripheral">[[DMA_internal_peripheral]]</ref>资源
* detects the TIM counter resolution, e.g. 16 or 32 bits.
+
* 检测TIM计数器分辨率,例如 16或32位。
'''PWM driver''':
+
'''PWM驱动器''':
* detects the number of TIM channels.
+
* 检测TIM通道数。
* handles '''PWM output''' channels.
+
* 处理'''PWM输出'''通道。
* handles '''PWM capture''' channels (input). Note that the PWM capture relies on DMA, which is handled by the MFD core.
+
*处理'''PWM捕捉'''通道(输入)。 请注意,PWM捕获依赖于由MFD内核处理的DMA。
'''IIO driver''':
+
'''IIO 驱动程序''':
* handles hardware '''trigger sources''' (synchronously with PWM) for other internal peripherals such as ADC<ref name="adc_internal">[[ADC internal peripheral]]</ref>, DAC<ref name="dac_internal">[[DAC internal peripheral]]</ref>, DFSDM<ref name="dfsdm_internal">[[DFSDM internal peripheral]]</ref>.
+
* 处理其他内部外围设备的硬件''触发源''(与PWM同步),例如ADC <ref name="adc_internal">[[ADC internal peripheral]]</ref>, DAC<ref name="dac_internal">[[DAC internal peripheral]]</ref>, DFSDM<ref name="dfsdm_internal">[[DFSDM internal peripheral]]</ref>.
* handles the '''quadrature encoder''' interface<ref>[https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_encoder Incremental encoder] Incremental encoder overview</ref>.
+
* 处理‘正交编码器'''quadrature encoder''' interface<ref>[https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_encoder Incremental encoder] Incremental encoder overview</ref>.
  
 
== Configuration ==
 
== Configuration ==

2020年11月10日 (二) 10:31的版本

Article purpose

本文介绍了用于TIM内部外围设备的TIM Linux® 驱动程序[1]:

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

Short description

Linux驱动程序(内核空间)“ TIM” [1] 基于 PWMIIO 框架。 它提供了几种功能:

MFD驱动程序:

  • 处理寄存器,时钟和DMA[2]资源
  • 检测TIM计数器分辨率,例如 16或32位。

PWM驱动器:

  • 检测TIM通道数。
  • 处理PWM输出通道。
  • 处理PWM捕捉通道(输入)。 请注意,PWM捕获依赖于由MFD内核处理的DMA。

IIO 驱动程序:

  • 处理其他内部外围设备的硬件触发源(与PWM同步),例如ADC [3], DAC[4], DFSDM[5].
  • 处理‘正交编码器quadrature encoder interface[6].

Configuration

Kernel configuration

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

Enable the following configurations (and their dependencies):

  • CONFIG_MFD_STM32_TIMERS
  • CONFIG_PWM_STM32
  • CONFIG_IIO_STM32_TIMER_TRIGGER
Device Drivers  --->
  -> Multifunction device drivers  --->
     <*> Support for STM32 Timers
  -> Pulse-width modulation (PWM) support  --->
     <*> STMicroelectronics STM32 PWM
  -> Industrial I/O support  --->
     -> Triggers - standalone  --->
        <*> STM32 timer trigger

Device tree

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

How to trace and debug

The TIM[1] Linux driver can access the timer registers through REGMAP.

It comes with debugfs[7] entries, which allow dumping registers:

$ cd /sys/kernel/debug/regmap
$ ls
40004000.timer  44000000.timer

$ cd 44000000.timer
$ cat registers
000: 00000081
004: 00000000
008: 00000000
00c: 00000000
...

It also comes with tracepoints[8]:

$ cd /sys/kernel/debug/tracing
$ cat available_events | grep regmap
...
regmap:regmap_reg_read
regmap:regmap_reg_write

Source code location

The TIM Linux driver source code is composed of:

References

<securetransclude src="ProtectedTemplate:PublicationRequestId" params="9233 | 2018-10-15 | AnneJ"></securetransclude> <securetransclude src="ProtectedTemplate:ArticleBasedOnModel" params="Linux driver article model"></securetransclude>