https://wiki.st.com/stm32mpu-ecosystem-v2/index.php?title=ADC_Linux_driver&feed=atom&action=history
ADC Linux driver - Revision history
2024-03-29T07:36:25Z
Revision history for this page on the wiki
MediaWiki 1.31.16
https://wiki.st.com/stm32mpu-ecosystem-v2/index.php?title=ADC_Linux_driver&diff=66299&oldid=prev
Jean Christophe Trotin at 14:59, 16 January 2020
2020-01-16T14:59:23Z
<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 14:59, 16 January 2020</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1" >Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"><noinclude></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">{{ArticleBasedOnModel | [[Linux driver article model]]}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">{{ArticleMainWriter | FabriceG}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">{{ReviewersList | ArnaudP, OlivierM}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">{{ArticleApprovedVersion | FabriceG | OlivierM, ArnaudP | No previous approved version | AnneJ - 23Oct'18 - 9337 | 05Nov'18}}</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">[[Category:IIO]]</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></noinclude></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Article purpose ==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Article purpose ==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This article introduces the Linux<sup>&reg;</sup> driver for the ADC<ref name="ADC internal peripheral">[[ADC internal peripheral]]</ref> internal peripheral:</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>This article introduces the Linux<sup>&reg;</sup> driver for the ADC<ref name="ADC internal peripheral">[[ADC internal peripheral]]</ref> internal peripheral:</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l85" >Line 85:</td>
<td colspan="2" class="diff-lineno">Line 77:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==References==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==References==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><references /></div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><references /></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><noinclude></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:IIO]]</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">{{PublicationRequestId | 9337 | 2018-10-23 | AnneJ}}</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">{{ArticleBasedOnModel | Linux driver article model}}</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></noinclude></ins></div></td></tr>
</table>
Jean Christophe Trotin
https://wiki.st.com/stm32mpu-ecosystem-v2/index.php?title=ADC_Linux_driver&diff=53556&oldid=prev
Fabrice Gasnier: Reverted edits by Mk Sundaram (talk) to last revision by Fgasni00
2019-02-19T08:54:58Z
<p>Reverted edits by Registered User (-) to last revision by Registered User</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 08:54, 19 February 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l12" >Line 12:</td>
<td colspan="2" class="diff-lineno">Line 12:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* How to configure, use and debug the driver  </div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* How to configure, use and debug the driver  </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* What is the driver structure, and where the source code can be found.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* What is the driver structure, and where the source code can be found.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">**[http://www.google.com www.google.com]STMicroelectronics**</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Short description ==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Short description ==</div></td></tr>
</table>
Fabrice Gasnier
https://wiki.st.com/stm32mpu-ecosystem-v2/index.php?title=ADC_Linux_driver&diff=52784&oldid=prev
Mk Sundaram: /* Article purpose */
2019-02-14T05:41:45Z
<p><span dir="auto"><span class="autocomment">Article purpose</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 05:41, 14 February 2019</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l12" >Line 12:</td>
<td colspan="2" class="diff-lineno">Line 12:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* How to configure, use and debug the driver  </div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* How to configure, use and debug the driver  </div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* What is the driver structure, and where the source code can be found.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* What is the driver structure, and where the source code can be found.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">**[http://www.google.com www.google.com]STMicroelectronics**</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Short description ==</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Short description ==</div></td></tr>
</table>
Mk Sundaram
https://wiki.st.com/stm32mpu-ecosystem-v2/index.php?title=ADC_Linux_driver&diff=41125&oldid=prev
Fgasni00 at 08:28, 5 November 2018
2018-11-05T08:28:07Z
<p></p>
<p><b>New page</b></p><div><noinclude><br />
{{ArticleBasedOnModel | [[Linux driver article model]]}}<br />
{{ArticleMainWriter | FabriceG}}<br />
{{ReviewersList | ArnaudP, OlivierM}}<br />
{{ArticleApprovedVersion | FabriceG | OlivierM, ArnaudP | No previous approved version | AnneJ - 23Oct'18 - 9337 | 05Nov'18}}<br />
[[Category:IIO]]<br />
</noinclude><br />
<br />
== Article purpose ==<br />
This article introduces the Linux<sup>&reg;</sup> driver for the ADC<ref name="ADC internal peripheral">[[ADC internal peripheral]]</ref> internal peripheral:<br />
* Which ADC features are supported by the driver<br />
* How to configure, use and debug the driver <br />
* What is the driver structure, and where the source code can be found.<br />
<br />
== Short description ==<br />
The ADC Linux<sup>&reg;</sup> driver (kernel space) is based on the [[IIO overview|IIO]] framework.<br />
It supports two modes:<br />
# '''IIO direct mode''': single capture on a channel (using interrupts)<br />
# '''IIO triggered buffer mode''': capture on one or more channels (preferably using DMA).<br/>It uses the hardware triggers available in IIO. See [[TIM Linux driver]] and [[LPTIM Linux driver]].<br />
<br />
== Configuration ==<br />
=== Kernel configuration ===<br />
Activate the ADC<ref name="ADC internal peripheral"/> Linux<sup>&reg;</sup> driver in the kernel configuration using the Linux Menuconfig tool: [[Menuconfig or how to configure kernel]] (enable both CONFIG_STM32_ADC_CORE and CONFIG_STM32_ADC).<br />
<pre><br />
Device Drivers ---><br />
<*> Industrial I/O support ---><br />
Analog to digital converters ---><br />
<*> STMicroelectronics STM32 adc core<br />
<*> STMicroelectronics STM32 adc<br />
</pre><br />
<br />
=== Device tree ===<br />
Refer to the [[ADC device tree configuration]] article when configuring the ADC Linux kernel driver.<br />
<br />
== How to use ==<br />
In "'''IIO direct mode'''", the conversion result can be read directly from '''sysfs''' (refer to<br />
[[How to use the IIO user space interface#How to do a simple ADC conversion using the sysfs interface|How to do a simple ADC conversion using the sysfs interface]]).<br />
<br />
In "'''IIO triggered buffer mode'''", the configuration must be performed using '''sysfs''' first. Then, '''character device''' (/dev/iio:deviceX) is used to read data (refer to [[How to use the IIO user space interface#Convert one or more channels using triggered buffer mode|Convert one or more channels using triggered buffer mode]]).<br />
<br />
== How to trace and debug ==<br />
Refer to [[IIO_overview#How_to_trace_with_dynamic_debug|How to trace with dynamic debug]] for how to '''enable the debug logs''' in the driver and in the framework.<br />
<br />
Refer to [[IIO_overview#How_to_debug_with_debugfs|How to debug with debugfs]] for how to '''access the ADC registers'''.<br />
<br />
The ADC has system wide dependencies towards other key resources:<br />
* '''runtime power management''' can be disabled, for example it may be forced '''on''' via ''power/control'' sysfs entry:<br />
{{Board$}} cd /sys/devices/platform/soc/48003000.adc/48003000.adc:adc@0<br />
{{Board$}} cat power/autosuspend_delay_ms<br />
2000<br />
{{Board$}} cat power/control<br />
auto # kernel is allowed to automatically suspend the ADC device after autosuspend_delay_ms<br />
{{Board$}} {{highlight|echo on > power/control}} # force the kernel to resume the ADC device (e.g. keep clocks and regulators enabled)<br />
{{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).}}<br />
<br />
* '''clock'''<ref name="Clock overview">[[Clock overview]]</ref> usage can be verified by reading ''clk_summary'':<br />
{{Board$}} {{highlight|cat /sys/kernel/debug/clk/clk_summary}} | grep adc<br />
adc12_k 1 1 0 24000000 0 0<br />
adc12 1 1 0 196607910 0 0<br />
<br />
* '''regulator'''<ref name="Regulator overview">[[Regulator overview]]</ref> tree and usage can be verified (e.g. use count, open count or regulator reference voltage) as follows:<br />
{{Board$}} {{highlight|cat /sys/kernel/debug/regulator/regulator_summary}}<br />
regulator use open bypass voltage current min max<br />
-------------------------------------------------------------------------------<br />
v3v3 4 5 0 3300mV 0mA 3300mV 3300mV<br />
vdda 1 2 0 2900mV 0mA 2900mV 2900mV <br />
40017000.dac 0mV 0mV<br />
48003000.adc 0mV 0mV<br />
<br />
* '''pinctrl'''<ref name="Pinctrl_overview">[[Pinctrl overview]]</ref> usage can be verified by reading ''pinmux-pins'':<br />
{{Board$}} cd /sys/kernel/debug/pinctrl/soc\:pin-controller@50002000/<br />
{{Board$}} {{highlight|cat pinmux-pins}} | grep adc<br />
pin 92 (PF12): device 48003000.adc function {{highlight|analog}} group PF12 # check pin is assigned to ADC and is configured as "analog"<br />
<br />
* '''interrupts''' can be verified by reading "interrupts":<br />
{{Board$}} {{highlight|cat /proc/interrupts}}<br />
CPU0 CPU1<br />
56: 2 0 dummy 0 Edge 48003000.adc:adc@0<br />
<br />
== Source code location ==<br />
The ADC source code is composed of:<br />
* {{CodeSource | Linux kernel | drivers/iio/adc/stm32-adc-core.c | stm32-adc-core driver}} to handle common resources such as clock (selection, prescaler), [[Regulator overview|regulator]] used as reference voltage, interrupt and common registers.<br />
* {{CodeSource | Linux kernel | drivers/iio/adc/stm32-adc.c | stm32-adc driver}} to handle the resources available for each ADC such as channel configuration and buffer handling.<br />
<br />
==References==<br />
<references /></div>
Fgasni00