Registered User mNo edit summary |
Registered User mNo edit summary Tag: 2017 source edit |
||
(36 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude>{{ApplicableFor | <noinclude>{{ApplicableFor | ||
|MPUs list=STM32MP13x, STM32MP15x | |MPUs list=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | ||
|MPUs checklist=STM32MP13x,STM32MP15x | |MPUs checklist=STM32MP13x,STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | ||
}}</noinclude> | }}</noinclude> | ||
== Article purpose == | == Article purpose == | ||
The purpose of this article is to explain how to configure the analog-to-digital converter [[ADC_internal_peripheral|ADC internal peripheral]] using the [[Device tree|device tree]] mechanism, relying on the bindings documentation | The purpose of this article is to explain how to configure the analog-to-digital converter [[ADC_internal_peripheral|ADC internal peripheral]] using the [[Device tree|device tree]] mechanism, relying on the bindings documentation that is the description of the required and optional device-tree properties. | ||
The peripheral can be assigned to different contexts/software components, depending on the final product needs. Refer to [[How to assign an internal peripheral to | The peripheral can be assigned to different contexts/software components, depending on the final product needs. Refer to [[How to assign an internal peripheral to an execution context]] for guidelines on this configuration. | ||
The device tree to configure depends on the context/component to which the ADC peripheral is assigned: | The device tree file to configure depends on the context/component to which the ADC peripheral is assigned: | ||
* U-Boot (Boot time context): refer to [[U-Boot_overview|U-Boot overview]] | * U-Boot (Boot time context): refer to [[U-Boot_overview|U-Boot overview]]. | ||
* Linux® OS (Runtime context): refer to the [[IIO overview|IIO framework]]. | * Linux® OS (Runtime context): refer to the [[IIO overview|IIO framework]].https://wiki.st.com/stm32mpu/wiki/I3C_overview#STM32_I-internal_peripheral_controllertors | ||
== DT bindings documentation == | == DT bindings documentation == | ||
Line 18: | Line 18: | ||
This hardware description is a combination of the '''STM32 microprocessor''' device tree files (''.dtsi'' extension) and '''board''' device tree files (''.dts'' extension). See the [[Device tree]] for an explanation of the device tree file split. | This hardware description is a combination of the '''STM32 microprocessor''' device tree files (''.dtsi'' extension) and '''board''' device tree files (''.dts'' extension). See the [[Device tree]] for an explanation of the device tree file split. | ||
'''STM32CubeMX''' can be used to generate the board device tree. Refer to [[#How_to_configure_the_DT_using_STM32CubeMX|How to configure the DT using STM32CubeMX]] for more details. | |||
{{ | {{ | ||
ImageMap|Image:ADC DT configuration.png {{!}} frame {{!}} center{{!}} ADC DT configuration | ImageMap|Image:ADC DT configuration.png {{!}} frame {{!}} center{{!}} ADC DT configuration | ||
Line 32: | Line 32: | ||
=== DT configuration (STM32/SoC level) === | === DT configuration (STM32/SoC level) === | ||
An ADC peripheral provides one or more | An ADC peripheral provides one or more ADCs. Some hardware common resources are managed in the ADC peripheral, whatever the number of ADC sub-blocks. In the following chapters, the ADC peripheral is called "'''ADC block'''", while "'''ADC'''" refers to an ADC peripheral sub-block. | ||
The ADC DT nodes are structured as follows: | The ADC DT nodes are structured as follows: | ||
* The '''DT root node''' describes the ADC block parameters such as register areas, clocks and interrupts. | * The '''DT root node''' describes the ADC block parameters such as register areas, clocks and interrupts. | ||
* The '''DT child | * The '''DT child nodes''' describe the ADCs independently. | ||
===={{MicroprocessorDevice | device=13}}==== | |||
The ADC nodes are declared in stm32mp131.dtsi<ref name="stm32mp131_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/st/stm32mp131.dtsi | STM32MP131 device tree file}}</ref> and in | |||
stm32mp133.dtsi<ref name="stm32mp133_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/st/stm32mp133.dtsi | STM32MP133 device tree file}}</ref>. | |||
adc_1: adc@address { | |||
compatible = "st,stm32mp13-adc-core"; | |||
... {{highlight|/* common resources in 'adc_1' root node. */}} | |||
adc1: adc@0 { | |||
compatible = "st,stm32mp13-adc"; | |||
... {{highlight|/* private resources in 'adc1' child node. */}} | |||
}; | |||
}; | |||
adc_2: adc@address { | |||
compatible = "st,stm32mp13-adc-core"; | |||
... {{highlight|/* common resources in 'adc_2' root node. */}} | |||
adc2: adc@0 { | |||
compatible = "st,stm32mp13-adc"; | |||
... {{highlight|/* private resources in 'adc2' child node. */}} | |||
}; | |||
}; | |||
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}} | |||
===={{MicroprocessorDevice | device=15}}==== | ===={{MicroprocessorDevice | device=15}}==== | ||
The ADC nodes are declared in stm32mp151.dtsi<ref name="stm32mp151_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/stm32mp151.dtsi | STM32MP151 device tree file}}</ref>. | The ADC nodes are declared in stm32mp151.dtsi<ref name="stm32mp151_dtsi">{{CodeSource | Linux kernel | arch/arm/boot/dts/st/stm32mp151.dtsi | STM32MP151 device tree file}}</ref>. | ||
adc: adc@address { | adc: adc@address { | ||
compatible = "st,stm32mp1-adc-core"; | compatible = "st,stm32mp1-adc-core"; | ||
Line 53: | Line 75: | ||
}; | }; | ||
}; | }; | ||
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}} | |||
===={{MicroprocessorDevice | device= | ===={{MicroprocessorDevice | device=21}}==== | ||
The ADC nodes are declared in stm32mp211.dtsi<ref name="stm32mp211_dtsi">{{CodeSource | Linux kernel | arch/arm64/boot/dts/st/stm32mp211.dtsi | STM32MP211 device tree file}}</ref>. | |||
The ADC nodes are declared in | adc_1: adc@404e0000 { | ||
compatible = "st,stm32mp21-adc-core"; | |||
adc_1: adc@ | |||
compatible = "st, | |||
... {{highlight|/* common resources in 'adc_1' root node. */}} | ... {{highlight|/* common resources in 'adc_1' root node. */}} | ||
adc1: adc@0 { | adc1: adc@0 { | ||
compatible = "st, | compatible = "st,stm32mp21-adc"; | ||
... {{highlight|/* private resources in 'adc1' child node. */}} | ... {{highlight|/* private resources in 'adc1' child node. */}} | ||
}; | }; | ||
}; | }; | ||
adc_2: adc@ | adc_2: adc@404f0000 { | ||
compatible = "st, | compatible = "st,stm32mp21-adc-core"; | ||
... {{highlight|/* common resources in 'adc_2' root node. */}} | ... {{highlight|/* common resources in 'adc_2' root node. */}} | ||
adc2: adc@0 { | adc2: adc@0 { | ||
compatible = "st, | compatible = "st,stm32mp21-adc"; | ||
... {{highlight|/* private resources in 'adc2' child node. */}} | |||
}; | |||
}; | |||
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}} | |||
===={{MicroprocessorDevice | device=23}} ==== | |||
The ADC nodes are declared in stm32mp231.dtsi<ref name="stm32mp231_dtsi">{{CodeSource | Linux kernel | arch/arm64/boot/dts/st/stm32mp231.dtsi | STM32MP231 device tree file}}</ref>. | |||
adc_12: adc@404e0000 { | |||
compatible = "st,stm32mp23-adc-core"; | |||
... {{highlight|/* common resources in 'adc_12' root node. */}} | |||
adc1: adc@0 { | |||
compatible = "st,stm32mp23-adc"; | |||
... {{highlight|/* private resources in 'adc1' child node. */}} | |||
}; | |||
adc2: adc@100 { | |||
compatible = "st,stm32mp23-adc"; | |||
... {{highlight|/* private resources in 'adc2' child node. */}} | |||
}; | |||
}; | |||
adc_3: adc@404f0000 { | |||
compatible = "st,stm32mp23-adc-core"; | |||
... {{highlight|/* common resources in 'adc_3' root node. */}} | |||
adc3: adc@0 { | |||
compatible = "st,stm32mp23-adc"; | |||
... {{highlight|/* private resources in 'adc3' child node. */}} | |||
}; | |||
}; | |||
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}} | |||
===={{MicroprocessorDevice | device=25}} ==== | |||
The ADC nodes are declared in stm32mp251.dtsi<ref name="stm32mp251_dtsi">{{CodeSource | Linux kernel | arch/arm64/boot/dts/st/stm32mp251.dtsi | STM32MP251 device tree file}}</ref>. | |||
adc_12: adc@404e0000 { | |||
compatible = "st,stm32mp25-adc-core"; | |||
... {{highlight|/* common resources in 'adc_12' root node. */}} | |||
adc1: adc@0 { | |||
compatible = "st,stm32mp25-adc"; | |||
... {{highlight|/* private resources in 'adc1' child node. */}} | |||
}; | |||
adc2: adc@100 { | |||
compatible = "st,stm32mp25-adc"; | |||
... {{highlight|/* private resources in 'adc2' child node. */}} | ... {{highlight|/* private resources in 'adc2' child node. */}} | ||
}; | }; | ||
}; | }; | ||
adc_3: adc@404f0000 { | |||
compatible = "st,stm32mp25-adc-core"; | |||
... {{highlight|/* common resources in 'adc_3' root node. */}} | |||
adc3: adc@0 { | |||
compatible = "st,stm32mp25-adc"; | |||
... {{highlight|/* private resources in 'adc3' child node. */}} | |||
}; | |||
}; | |||
{{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}} | {{Warning|This device tree part is related to STM32 microprocessors. It must be kept as is, without being modified by the end-user.}} | ||
=== DT configuration (board level) === | === DT configuration (board level) === | ||
The objective of this chapter is to explain how to enable and configure the ADC | The objective of this chapter is to explain how to enable and configure the ADC DT nodes for a board. | ||
Peripheral configuration should be done in specific board device tree files (board dts file and [[Pinctrl device tree configuration|pinctrl dtsi file]]).<br> | |||
==== Common resources for all ADCs ==== | ==== Common resources for all ADCs ==== | ||
Line 93: | Line 164: | ||
==== Resources dedicated to an ADC ==== | ==== Resources dedicated to an ADC ==== | ||
The '''DT child nodes''' ('''' | The '''DT child nodes''' (''''adc<n=1, 2, 3>'''') must be filled in with the ADC and channels properties. The number <n> of ADC instances may vary depending on the {{MicroprocessorDevice | device=Class}} used, as described in [[ADC internal peripheral]]. | ||
===== ADC properties ===== | ===== ADC properties ===== | ||
* Enable ADC by setting '''status = "okay".''' | * Enable ADC by setting '''status = "okay".''' | ||
* Set ADC resolution by setting '''assigned-resolution-bits = <12>''' (optional). | * Set ADC resolution by setting '''assigned-resolution-bits = <12>''' (optional). | ||
===== Channel properties | ===== Channel properties ===== | ||
Each channel is described by a dedicated '''DT sub node''', filled in with properties documented in | Each channel is described by a dedicated '''DT sub node''', filled in with properties documented in | ||
''Generic IIO bindings for ADC channels''<ref>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/iio/adc/adc.yaml | Documentation/devicetree/bindings/iio/adc/adc.yaml}}, Generic IIO bindings for ADC channels</ref>. | ''Generic IIO bindings for ADC channels''<ref>{{CodeSource | Linux kernel | Documentation/devicetree/bindings/iio/adc/adc.yaml | Documentation/devicetree/bindings/iio/adc/adc.yaml}}, Generic IIO bindings for ADC channels</ref>. | ||
* Define channel index 'x' by setting '''reg = <x>'''. | * Define channel index 'x' by setting '''reg = <x>'''. | ||
* Identifiy the channel by setting its name with '''label = "xxx"''' (optional). <BR>Reserved labels allow to identify the internal channels. | * Enable differential channel pair (''<vinp vinn>'') by setting '''diff-channels = <x y>''' (optional).<BR>Refer to the connectivity section of the ADC chapter in the reference manual, to determine the relevant pin indexes (x,y). The "x" index corresponds to the positive input INPx. For the negative input INNx, the index "y" of the associated positive input pin INPy, must be provided. An example of differential pins configuration is given in the [[ADC_device_tree_configuration#DT_configuration_examples|DT configuration examples]] chapter below. | ||
** "'''vrefint'''", "'''vddcore'''": These internal channels are defined in the SoC DT. They can be removed in the board DT if they are not used. | |||
* Set the minimum sampling time <ref>[http://www.st.com/content/ccc/resource/technical/document/application_note/group0/3f/4c/a4/82/bd/63/4e/92/CD00211314/files/CD00211314.pdf/jcr:content/translations/en.CD00211314.pdf How to get the best ADC accuracy in STM32], by STMicroelectronics</ref> by setting '''st,min-sample-time-ns = <10000>''' (optional) | |||
* Identifiy the channel by setting its name with '''label = "xxx"''' (optional). <BR>Reserved labels allow to identify the '''internal channels'''. | |||
** "'''vrefint'''", "'''vddcore'''", "'''vddcpu'''", "'''vddq_ddr'''", "'''vddgpu'''": These internal channels are defined in the SoC DT. They can be removed in the board DT if they are not used. | |||
** "'''vbat'''": This internal channel can be defined in the board DT. It is not defined by default in the SoC DT to save current consumption. | ** "'''vbat'''": This internal channel can be defined in the board DT. It is not defined by default in the SoC DT to save current consumption. | ||
{{Info | Internal channels availability depends on the ADC instance used. It also depends on the '''STM32 microprocessor''' device.}} | |||
=== DT configuration | === DT configuration examples === | ||
The example below shows how to configure ADC1: | The example below shows how to configure ADC1 on {{MicroprocessorDevice | device=15}}. Same applies for all {{MicroprocessorDevice | device=Class}}: | ||
* Input pin: use [[Pinctrl device tree configuration]] to configure PF12 as analog input. | * Input pin: use [[Pinctrl device tree configuration]] to configure PF12 as analog input. | ||
* Analog supply: it is provided by one of the [[PMIC hardware components|PMIC]] LDO regulators. | * Analog supply: it is provided by one of the [[PMIC hardware components|PMIC]] LDO regulators. | ||
* Voltage reference: it is provided by the [[Regulator_overview#Microprocessor device internal | * Voltage reference: it is provided by the [[Regulator_overview#Microprocessor device internal regulator|VREFBUF internal regulator]]. | ||
* Input channel: configure ADC1_IN6 (e.g on PF12). | * Input channel: configure ADC1_IN6 (e.g on PF12). | ||
* Sampling time: the minimum sampling time is 10 µs. | * Sampling time: the minimum sampling time is 10 µs. | ||
Line 135: | Line 196: | ||
}; | }; | ||
{{Info|ANA0 and ANA1 pins are dedicated to the ADC, so ''pinctrl'' definition is not needed for those pins.}} | |||
&adc { | &adc { | ||
Line 149: | Line 210: | ||
/* private resources for ADC1 */ | /* private resources for ADC1 */ | ||
status = "'''okay'''"; {{highlight|/* Enable ADC1 */}} | status = "'''okay'''"; {{highlight|/* Enable ADC1 */}} | ||
/* Single-ended channel */ | |||
channel@6 { | channel@6 { | ||
reg = {{highlight|<6>}}; {{highlight|/* ADC1 in6 channel is used */}} | reg = {{highlight|<6>}}; {{highlight|/* ADC1 in6 channel is used */}} | ||
st,min-sample-time-ns = {{highlight|<10000>}}; {{highlight|/* 10µs sampling time */}} | |||
}; | |||
/* Configure channel 1 as differential (ANA1 - ANA0) */ | |||
channel@1 { | |||
reg = {{highlight|<1>}}; {{highlight|/* ADC1 inp1 and inn1 (inn1 equivalent to inp0) channels are used */}} | |||
diff-channels = {{highlight|<1 0>}}; | |||
st,min-sample-time-ns = {{highlight|<10000>}}; {{highlight|/* 10µs sampling time */}} | st,min-sample-time-ns = {{highlight|<10000>}}; {{highlight|/* 10µs sampling time */}} | ||
}; | }; | ||
}; | }; | ||
}; | }; | ||
==How to configure the DT using STM32CubeMX== | ==How to configure the DT using STM32CubeMX== | ||
The [[STM32CubeMX]] tool can be used to configure the STM32MPU device and get the corresponding [[Device_tree# | The [[STM32CubeMX]] tool can be used to configure the STM32MPU device and get the corresponding [[Device_tree#STM32_MPU|platform configuration device tree]] files.<br /> | ||
STM32CubeMX may not support all the properties described in DT binding files listed in the above [[#DT bindings documentation|DT bindings documentation]] paragraph. If so, the tool inserts '''user sections''' in the generated device tree. These sections can then be edited to add some properties, and they are preserved from one generation to another. Refer to [[STM32CubeMX]] user manual for further information. | |||
==References== | ==References== | ||
Line 189: | Line 235: | ||
<noinclude> | <noinclude> | ||
{{ArticleBasedOnModel | Peripheral or framework device tree configuration model}} | {{ArticleBasedOnModel | Peripheral or framework device tree configuration model}} | ||
{{PublicationRequestId | 8779 | {{PublicationRequestId | 24109|2022-07-27 | previous : 8779 - 2018-09-13 - AnneJ}} | ||
[[Category:Device tree configuration]] | [[Category:Device tree configuration]] | ||
[[Category:IIO]] | [[Category:IIO]] | ||
</noinclude> | </noinclude> |
Latest revision as of 14:18, 14 October 2024
1. Article purpose[edit | edit source]
The purpose of this article is to explain how to configure the analog-to-digital converter ADC internal peripheral using the device tree mechanism, relying on the bindings documentation that is the description of the required and optional device-tree properties.
The peripheral can be assigned to different contexts/software components, depending on the final product needs. Refer to How to assign an internal peripheral to an execution context for guidelines on this configuration.
The device tree file to configure depends on the context/component to which the ADC peripheral is assigned:
- U-Boot (Boot time context): refer to U-Boot overview.
- Linux® OS (Runtime context): refer to the IIO framework.https://wiki.st.com/stm32mpu/wiki/I3C_overview#STM32_I-internal_peripheral_controllertors
2. DT bindings documentation[edit | edit source]
U-Boot, Linux® OS: STM32 ADC device tree bindings: Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml
3. DT configuration[edit | edit source]
This hardware description is a combination of the STM32 microprocessor device tree files (.dtsi extension) and board device tree files (.dts extension). See the Device tree for an explanation of the device tree file split.
STM32CubeMX can be used to generate the board device tree. Refer to How to configure the DT using STM32CubeMX for more details.
3.1. DT configuration (STM32/SoC level)[edit | edit source]
An ADC peripheral provides one or more ADCs. Some hardware common resources are managed in the ADC peripheral, whatever the number of ADC sub-blocks. In the following chapters, the ADC peripheral is called "ADC block", while "ADC" refers to an ADC peripheral sub-block.
The ADC DT nodes are structured as follows:
- The DT root node describes the ADC block parameters such as register areas, clocks and interrupts.
- The DT child nodes describe the ADCs independently.
3.1.1. STM32MP13x lines
[edit | edit source]
The ADC nodes are declared in stm32mp131.dtsi[1] and in stm32mp133.dtsi[2].
/* common resources in 'adc_1' root node. */ adc1: adc@0 { compatible = "st,stm32mp13-adc"; ... /* private resources in 'adc1' child node. */ }; }; adc_2: adc@address { compatible = "st,stm32mp13-adc-core"; ... /* common resources in 'adc_2' root node. */ adc2: adc@0 { compatible = "st,stm32mp13-adc"; ... /* private resources in 'adc2' child node. */ }; };adc_1: adc@address { compatible = "st,stm32mp13-adc-core"; ...
3.1.2. STM32MP15x lines
[edit | edit source]
The ADC nodes are declared in stm32mp151.dtsi[3].
/* common resources in 'adc' root node. */ adc1: adc@0 { compatible = "st,stm32mp1-adc"; ... /* private resources in 'adc1' child node. */ }; adc2: adc@100 { compatible = "st,stm32mp1-adc"; ... /* private resources in 'adc2' child node. */ }; };adc: adc@address { compatible = "st,stm32mp1-adc-core"; ...
3.1.3. STM32MP21 unknown microprocessor device[edit | edit source]
The ADC nodes are declared in stm32mp211.dtsi[4].
/* common resources in 'adc_1' root node. */ adc1: adc@0 { compatible = "st,stm32mp21-adc"; ... /* private resources in 'adc1' child node. */ }; }; adc_2: adc@404f0000 { compatible = "st,stm32mp21-adc-core"; ... /* common resources in 'adc_2' root node. */ adc2: adc@0 { compatible = "st,stm32mp21-adc"; ... /* private resources in 'adc2' child node. */ }; };adc_1: adc@404e0000 { compatible = "st,stm32mp21-adc-core"; ...
3.1.4. STM32MP23 unknown microprocessor device[edit | edit source]
The ADC nodes are declared in stm32mp231.dtsi[5].
/* common resources in 'adc_12' root node. */ adc1: adc@0 { compatible = "st,stm32mp23-adc"; ... /* private resources in 'adc1' child node. */ }; adc2: adc@100 { compatible = "st,stm32mp23-adc"; ... /* private resources in 'adc2' child node. */ }; };adc_12: adc@404e0000 { compatible = "st,stm32mp23-adc-core"; ...
/* common resources in 'adc_3' root node. */ adc3: adc@0 { compatible = "st,stm32mp23-adc"; ... /* private resources in 'adc3' child node. */ }; };adc_3: adc@404f0000 { compatible = "st,stm32mp23-adc-core"; ...
3.1.5. STM32MP25 unknown microprocessor device[edit | edit source]
The ADC nodes are declared in stm32mp251.dtsi[6].
/* common resources in 'adc_12' root node. */ adc1: adc@0 { compatible = "st,stm32mp25-adc"; ... /* private resources in 'adc1' child node. */ }; adc2: adc@100 { compatible = "st,stm32mp25-adc"; ... /* private resources in 'adc2' child node. */ }; };adc_12: adc@404e0000 { compatible = "st,stm32mp25-adc-core"; ...
/* common resources in 'adc_3' root node. */ adc3: adc@0 { compatible = "st,stm32mp25-adc"; ... /* private resources in 'adc3' child node. */ }; };adc_3: adc@404f0000 { compatible = "st,stm32mp25-adc-core"; ...
3.2. DT configuration (board level)[edit | edit source]
The objective of this chapter is to explain how to enable and configure the ADC DT nodes for a board.
Peripheral configuration should be done in specific board device tree files (board dts file and pinctrl dtsi file).
3.2.1. Common resources for all ADCs[edit | edit source]
The DT root node must be filled in:
- Enable the ADC block by setting status = "okay".
- Configure the pins in use via pinctrl, through pinctrl-0 and pinctrl-names.
- Configure the analog supply voltage regulator[7] by setting vdda-supply = <&your_vdda_regulator>.
- Configure the analog reference voltage regulator[7] by setting vref-supply = <&your_vref_regulator>.
3.2.2. Resources dedicated to an ADC[edit | edit source]
The DT child nodes ('adc<n=1, 2, 3>') must be filled in with the ADC and channels properties. The number <n> of ADC instances may vary depending on the STM32 Arm® Cortex® MPUs used, as described in ADC internal peripheral.
3.2.2.1. ADC properties[edit | edit source]
- Enable ADC by setting status = "okay".
- Set ADC resolution by setting assigned-resolution-bits = <12> (optional).
3.2.2.2. Channel properties[edit | edit source]
Each channel is described by a dedicated DT sub node, filled in with properties documented in Generic IIO bindings for ADC channels[9].
- Define channel index 'x' by setting reg = <x>.
- Enable differential channel pair (<vinp vinn>) by setting diff-channels = <x y> (optional).
Refer to the connectivity section of the ADC chapter in the reference manual, to determine the relevant pin indexes (x,y). The "x" index corresponds to the positive input INPx. For the negative input INNx, the index "y" of the associated positive input pin INPy, must be provided. An example of differential pins configuration is given in the DT configuration examples chapter below.
- Set the minimum sampling time [10] by setting st,min-sample-time-ns = <10000> (optional)
- Identifiy the channel by setting its name with label = "xxx" (optional).
Reserved labels allow to identify the internal channels.- "vrefint", "vddcore", "vddcpu", "vddq_ddr", "vddgpu": These internal channels are defined in the SoC DT. They can be removed in the board DT if they are not used.
- "vbat": This internal channel can be defined in the board DT. It is not defined by default in the SoC DT to save current consumption.
3.3. DT configuration examples[edit | edit source]
The example below shows how to configure ADC1 on STM32MP15x lines . Same applies for all STM32 Arm® Cortex® MPUs
:
- Input pin: use Pinctrl device tree configuration to configure PF12 as analog input.
- Analog supply: it is provided by one of the PMIC LDO regulators.
- Voltage reference: it is provided by the VREFBUF internal regulator.
- Input channel: configure ADC1_IN6 (e.g on PF12).
- Sampling time: the minimum sampling time is 10 µs.
'F', 12, ANALOG)>; /* configure 'PF12' as ANALOG */ }; };# part of pin-controller dt node adc1_in6_pins_a: adc1-in6 { pins { pinmux = <STM32_PINMUX(
ADC block common resources */ pinctrl-names = "default"; pinctrl-0 = <&adc1_in6_pins_a>; /* Use PF12 pin as ANALOG */ vdda-supply = <&vdda>; /* Example to supply vdda pin by using a PMIC regulator vref-supply = <&vrefbuf>; /* Example to use VREFBUF (It needs to be enabled as well) */ status = "okay"; /* Enable ADC block */ adc1: adc@0 { #address-cells = <1>; #size-cells = <0>; /* private resources for ADC1 */ status = "okay"; /* Enable ADC1 */ /* Single-ended channel */ channel@6 { reg = <6>; /* ADC1 in6 channel is used */ st,min-sample-time-ns = <10000>; /* 10µs sampling time */ }; /* Configure channel 1 as differential (ANA1 - ANA0) */ channel@1 { reg = <1>; /* ADC1 inp1 and inn1 (inn1 equivalent to inp0) channels are used */ diff-channels = <1 0>; st,min-sample-time-ns = <10000>; /* 10µs sampling time */ }; }; };&adc { /*
4. How to configure the DT using STM32CubeMX[edit | edit source]
The STM32CubeMX tool can be used to configure the STM32MPU device and get the corresponding platform configuration device tree files.
STM32CubeMX may not support all the properties described in DT binding files listed in the above DT bindings documentation paragraph. If so, the tool inserts user sections in the generated device tree. These sections can then be edited to add some properties, and they are preserved from one generation to another. Refer to STM32CubeMX user manual for further information.
5. References[edit | edit source]
For additional information, refer to the following links:
- ↑ STM32MP131 device tree file
- ↑ STM32MP133 device tree file
- ↑ STM32MP151 device tree file
- ↑ STM32MP211 device tree file
- ↑ STM32MP231 device tree file
- ↑ STM32MP251 device tree file
- ↑ Jump up to: 7.0 7.1 7.2 Regulator overview
- ↑ VREFBUF internal peripheral
- ↑ Documentation/devicetree/bindings/iio/adc/adc.yaml , Generic IIO bindings for ADC channels
- ↑ How to get the best ADC accuracy in STM32, by STMicroelectronics