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

来自百问网嵌入式Linux wiki
第1行: 第1行:
{{DISPLAYTITLE:DAC的Linux驱动程序}}
+
== 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:
 +
* Which DAC features are supported by the driver
 +
* How to configure, use and debug the driver
 +
* What is the driver structure, and where the source code can be found.
  
[[Category:Linux_Operating_System]][[Category:Analog]][[Category:IIO]]
+
== Short Description ==
 +
The DAC Linux<sup>&reg;</sup> driver (kernel space) is based on the [[IIO overview|IIO]] framework.
 +
 
 +
It implements the '''IIO direct mode''', to perform single conversions independently on each channel.<br/>
 +
 
 +
== 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).
 +
<pre>
 +
Device Drivers  --->
 +
  <*> Industrial I/O support  --->
 +
      Digital to analog converters  --->
 +
        <*> STMicroelectronics STM32 DAC
 +
</pre>
 +
 
 +
=== Device tree ===
 +
Refer to the [[DAC device tree configuration]] article when configuring the DAC Linux kernel driver.
 +
 
 +
== 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]].
 +
 
 +
== 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.
 +
 
 +
Refer to [[IIO_overview#How_to_debug_with_debugfs|How to debug with debugfs]] for how to access the DAC registers.
 +
 
 +
The DAC has system wide dependencies towards other key resources:
 +
* '''runtime power management''' can be disabled, for example it may be forced '''on''' via ''power/control'' sysfs entry:
 +
{{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$}} {{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).}}
 +
 
 +
* '''clock'''<ref name="Clock overview">[[Clock overview]]</ref> usage can be verified by reading ''clk_summary'':
 +
{{Board$}} {{highlight|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'''<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:
 +
{{Board$}} {{highlight|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'''<ref name="Pinctrl_overview">[[Pinctrl overview]]</ref> usage can be verified by reading ''pinmux-pins'':
 +
{{Board$}} cd /sys/kernel/debug/pinctrl/soc\:pin-controller@50002000/
 +
{{Board$}} {{highlight|cat pinmux-pins}} | grep dac
 +
pin 4 (PA4): device 40017000.dac function {{highlight|analog}} group PA4
 +
pin 5 (PA5): device 40017000.dac function {{highlight|analog}} group PA5  # check pins are assigned to DAC and configured as "analog"
 +
 
 +
== Source code location ==
 +
The DAC source code is composed of:
 +
* {{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.c | stm32-dac driver}} to handle the resources available for each DAC such as channel configuration or output buffer handling (power-down mode).
 +
 
 +
==References==
 +
<references />
 +
 
 +
<noinclude>
 +
[[Category:IIO]]
 +
{{PublicationRequestId | 9338 | 2018-10-22 | AnneJ}}
 +
{{ArticleBasedOnModel | Linux driver article model}}
 +
</noinclude>

2020年5月6日 (三) 23:23的版本

Article purpose

This article introduces the Linux® driver for the DAC[1] internal peripheral:

  • Which DAC features are supported by the driver
  • How to configure, use and debug the driver
  • What is the driver structure, and where the source code can be found.

Short Description

The DAC Linux® driver (kernel space) is based on the IIO framework.

It implements the IIO direct mode, to perform single conversions independently on each channel.

Configuration

Kernel configuration

Activate the DAC[1] Linux® driver in the kernel configuration using the Linux Menuconfig tool: Menuconfig or how to configure kernel (enable CONFIG_STM32_DAC).

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

Device tree

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

How to use

In "IIO direct mode", conversions can be done directly via sysfs. See How to do a simple DAC conversion using the sysfs interface.

How to trace and debug

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

Refer to How to debug with debugfs for how to access the DAC registers.

The DAC has system wide dependencies towards other key resources:

  • runtime power management can be disabled, for example it may be forced on via power/control sysfs entry:
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 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).
  • clock[2] usage can be verified by reading clk_summary:
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] tree and usage usage can be verified (e.g. use count, open count and regulator reference voltage) as follows:
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] usage can be verified by reading 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

The DAC source code is composed of:

References

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