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

来自百问网嵌入式Linux wiki
 
(未显示同一用户的7个中间版本)
第1行: 第1行:
 
== Article purpose ==
 
== Article purpose ==
This article introduces the Linux<sup>&reg;</sup> driver for the DAC<ref name="DAC internal peripheral">[[DAC internal peripheral]]</ref> internal peripheral:
+
本文介绍了用于DAC  driver for the DAC<ref name="DAC internal peripheral">[[DAC internal peripheral]]</ref> 内部外围设备的Linux<sup>&reg;</sup>驱动程序:
* Which DAC features are supported by the driver
+
* 驱动程序支持哪些DAC功能
* How to configure, use and debug the driver
+
* 如何配置,使用和调试驱动程序
* What is the driver structure, and where the source code can be found.
+
* 驱动程序的结构是什么,以及在哪里可以找到源代码
  
 
== Short Description ==
 
== Short Description ==
The DAC Linux<sup>&reg;</sup> driver (kernel space) is based on the [[IIO overview|IIO]] framework.
+
DAC Linux<sup>&reg;</sup> 驱动程序(内核空间)基于 [[IIO overview|IIO]] 框架。
 
+
它实现了'''IIO直接模式''',以在每个通道上独立执行单个转换。<br/>
It implements the '''IIO direct mode''', to perform single conversions independently on each channel.<br/>
 
  
 
== Configuration ==
 
== Configuration ==
 
=== Kernel configuration ===
 
=== Kernel configuration ===
Activate the DAC<ref name="DAC internal peripheral"/> Linux<sup>&reg;</sup> driver in the kernel configuration using the Linux Menuconfig tool: [[Menuconfig or how to configure kernel]] (enable CONFIG_STM32_DAC).
+
使用Linux Menuconfig工具在内核配置中激活DAC <ref name="DAC internal peripheral"/> Linux<sup>&reg;</sup> 驱动程序: [[Menuconfig or how to configure kernel]] (启用CONFIG_STM32_DAC).
 
<pre>
 
<pre>
 
Device Drivers  --->
 
Device Drivers  --->
第21行: 第20行:
  
 
=== Device tree ===
 
=== Device tree ===
Refer to the [[DAC device tree configuration]] article when configuring the DAC Linux kernel driver.
+
配置DAC Linux内核驱动程序时,请参考[[DAC device tree configuration]] 文章。
  
 
== How to use ==
 
== How to use ==
In "IIO direct mode", conversions can be done directly via sysfs. See [[How to use the IIO user space interface#How to do a simple DAC conversion using the sysfs interface|How to do a simple DAC conversion using the sysfs interface]].
+
在“ IIO直接模式”下,可以直接通过sysfs完成转换。 请参阅 [[How to use the IIO user space interface#How to do a simple DAC conversion using the sysfs interface|How to do a simple DAC conversion using the sysfs interface]]
  
 
== How to trace and debug ==
 
== How to trace and debug ==
Refer to [[IIO_overview#How_to_trace_with_dynamic_debug|How to trace with dynamic debug]] for how to enable debug logs in the driver and in the Framework.
+
有关如何在驱动程序和框架中启用调试日志的信息,请参考[[IIO_overview#How_to_trace_with_dynamic_debug|How to trace with dynamic debug]]
  
Refer to [[IIO_overview#How_to_debug_with_debugfs|How to debug with debugfs]] for how to access the DAC registers.
+
有关如何访问DAC寄存器的信息,请参考[[IIO_overview#How_to_debug_with_debugfs|How to debug with debugfs]]
  
The DAC has system wide dependencies towards other key resources:
+
DAC对其他关键资源具有系统范围的依赖性:
* '''runtime power management''' can be disabled, for example it may be forced '''on''' via ''power/control'' sysfs entry:
+
* 可以禁用'''运行时电源管理''',例如,可以通过“ power / control” sysfs条目将其强制为'''on'''
 
  {{Board$}} cd /sys/devices/platform/soc/40017000.dac/40017000.dac\:dac@1/
 
  {{Board$}} cd /sys/devices/platform/soc/40017000.dac/40017000.dac\:dac@1/
 
  {{Board$}} cat power/autosuspend_delay_ms
 
  {{Board$}} cat power/autosuspend_delay_ms
第39行: 第38行:
 
  auto                                    # kernel is allowed to automatically suspend the ADC device after autosuspend_delay_ms
 
  auto                                    # kernel is allowed to automatically suspend the ADC device after autosuspend_delay_ms
 
  {{Board$}} {{highlight|echo on > power/control}}        # force the kernel to resume the DAC device (e.g. keep clocks and regulators enabled)
 
  {{Board$}} {{highlight|echo on > power/control}}        # force the kernel to resume the DAC device (e.g. keep clocks and regulators enabled)
{{Info| It might be useful to disable runtime power management, in order to dump registers by any means or to check clock and regulator usage (see example below).}}
+
{{Info| 禁用运行时电源管理可能很有用,以便通过任何方式转储寄存器或检查时钟和调节器的使用情况(请参见下面的示例)。}}
  
* '''clock'''<ref name="Clock overview">[[Clock overview]]</ref> usage can be verified by reading ''clk_summary'':
+
* 可以通过阅读“ clk_summary”来验证'''clock'''<ref name="Clock overview">[[Clock overview]]</ref> 的使用情况:
 
  {{Board$}} {{highlight|cat /sys/kernel/debug/clk/clk_summary}} | grep dac
 
  {{Board$}} {{highlight|cat /sys/kernel/debug/clk/clk_summary}} | grep dac
 
         dac12_k                        0        0        0      32000          0 0
 
         dac12_k                        0        0        0      32000          0 0
 
                       dac12          1        2        0    98303955          0 0
 
                       dac12          1        2        0    98303955          0 0
  
* '''regulator'''<ref name="Regulator overview">[[Regulator overview]]</ref> tree and usage usage can be verified (e.g. use count, open count and regulator reference voltage) as follows:
+
* '''regulator'''<ref name="Regulator overview">[[Regulator overview]]</ref> 树和使用情况可以通过以下方式进行验证(例如,使用计数,开路计数和调节器参考电压):
 
  {{Board$}} {{highlight|cat /sys/kernel/debug/regulator/regulator_summary}}
 
  {{Board$}} {{highlight|cat /sys/kernel/debug/regulator/regulator_summary}}
 
   regulator                      use open bypass voltage current    min    max
 
   regulator                      use open bypass voltage current    min    max
第55行: 第54行:
 
           48003000.adc                                              0mV    0mV
 
           48003000.adc                                              0mV    0mV
  
* '''pinctrl'''<ref name="Pinctrl_overview">[[Pinctrl overview]]</ref> usage can be verified by reading ''pinmux-pins'':
+
* '''pinctrl'''<ref name="Pinctrl_overview">[[Pinctrl overview]]</ref> 的用法可以通过阅读“ pinmux-pins”来验证:
 
  {{Board$}} cd /sys/kernel/debug/pinctrl/soc\:pin-controller@50002000/
 
  {{Board$}} cd /sys/kernel/debug/pinctrl/soc\:pin-controller@50002000/
 
  {{Board$}} {{highlight|cat pinmux-pins}} | grep dac
 
  {{Board$}} {{highlight|cat pinmux-pins}} | grep dac
第62行: 第61行:
  
 
== Source code location ==
 
== Source code location ==
The DAC source code is composed of:
+
DAC源代码包括:
* {{CodeSource | Linux kernel | drivers/iio/dac/stm32-dac-core.c | stm32-dac-core driver}} to handle common resources  such as [[Clock overview|clock]] or [[Regulator overview|regulator]] used as reference voltage and common registers.
+
* {{CodeSource | Linux kernel | drivers/iio/dac/stm32-dac-core.c | stm32-dac-core driver}} 处理诸如用作参考电压的 [[Clock overview|clock]] [[Regulator overview|regulator]] 等公共资源和公共寄存器。
* {{CodeSource | Linux kernel | drivers/iio/dac/stm32-dac.c | stm32-dac driver}} to handle the resources available for each DAC such as channel configuration or output buffer handling (power-down mode).
+
* {{CodeSource | Linux kernel | drivers/iio/dac/stm32-dac.c | stm32-dac driver}}来处理每个DAC可用的资源,例如通道配置或输出缓冲区处理(掉电模式)。
  
 
==References==
 
==References==
 
<references />
 
<references />
 
<noinclude>
 
[[Category:IIO]]
 
{{PublicationRequestId | 9338 | 2018-10-22 | AnneJ}}
 
{{ArticleBasedOnModel | Linux driver article model}}
 
</noinclude>
 

2020年11月9日 (一) 15:09的最新版本

Article purpose

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

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

Short Description

DAC Linux® 驱动程序(内核空间)基于 IIO 框架。 它实现了IIO直接模式,以在每个通道上独立执行单个转换。

Configuration

Kernel configuration

使用Linux Menuconfig工具在内核配置中激活DAC [1] Linux® 驱动程序: Menuconfig or how to configure kernel (启用CONFIG_STM32_DAC).

Device Drivers  --->
   <*> Industrial I/O support  --->
      Digital to analog converters  --->
         <*> STMicroelectronics STM32 DAC

Device tree

配置DAC Linux内核驱动程序时,请参考DAC device tree configuration 文章。

How to use

在“ IIO直接模式”下,可以直接通过sysfs完成转换。 请参阅 How to do a simple DAC conversion using the sysfs interface

How to trace and debug

有关如何在驱动程序和框架中启用调试日志的信息,请参考How to trace with dynamic debug

有关如何访问DAC寄存器的信息,请参考How to debug with debugfs

DAC对其他关键资源具有系统范围的依赖性:

  • 可以禁用运行时电源管理,例如,可以通过“ power / control” sysfs条目将其强制为on
Board $> cd /sys/devices/platform/soc/40017000.dac/40017000.dac\:dac@1/
Board $> cat power/autosuspend_delay_ms
2000
Board $> cat power/control
auto                                     # kernel is allowed to automatically suspend the ADC device after autosuspend_delay_ms
Board $> echo on > power/control         # force the kernel to resume the DAC device (e.g. keep clocks and regulators enabled)
Info.png 禁用运行时电源管理可能很有用,以便通过任何方式转储寄存器或检查时钟和调节器的使用情况(请参见下面的示例)。
  • 可以通过阅读“ clk_summary”来验证clock[2] 的使用情况:
Board $> cat /sys/kernel/debug/clk/clk_summary | grep dac
       dac12_k                        0        0        0       32000          0 0
                      dac12           1        2        0    98303955          0 0
  • regulator[3] 树和使用情况可以通过以下方式进行验证(例如,使用计数,开路计数和调节器参考电压):
Board $> cat /sys/kernel/debug/regulator/regulator_summary
 regulator                      use open bypass voltage current     min     max
-------------------------------------------------------------------------------
    v3v3                          4    5      0  3300mV     0mA  3300mV  3300mV
       vdda                       1    2      0  2900mV     0mA  2900mV  2900mV
          40017000.dac                                              0mV     0mV
          48003000.adc                                              0mV     0mV
  • pinctrl[4] 的用法可以通过阅读“ pinmux-pins”来验证:
Board $> cd /sys/kernel/debug/pinctrl/soc\:pin-controller@50002000/
Board $> cat pinmux-pins | grep dac
pin 4 (PA4): device 40017000.dac function analog group PA4
pin 5 (PA5): device 40017000.dac function analog group PA5   # check pins are assigned to DAC and configured as "analog"

Source code location

DAC源代码包括: