st,stm32-adc.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. STMicroelectronics STM32 ADC device
  2. STM32 ADC is a successive approximation analog-to-digital converter.
  3. It has several multiplexed input channels. Conversions can be performed
  4. in single, continuous, scan or discontinuous mode. Result of the ADC is
  5. stored in a left-aligned or right-aligned 32-bit data register.
  6. Conversions can be launched in software or using hardware triggers.
  7. The analog watchdog feature allows the application to detect if the input
  8. voltage goes beyond the user-defined, higher or lower thresholds.
  9. Each STM32 ADC block can have up to 3 ADC instances.
  10. Each instance supports two contexts to manage conversions, each one has its
  11. own configurable sequence and trigger:
  12. - regular conversion can be done in sequence, running in background
  13. - injected conversions have higher priority, and so have the ability to
  14. interrupt regular conversion sequence (either triggered in SW or HW).
  15. Regular sequence is resumed, in case it has been interrupted.
  16. Contents of a stm32 adc root node:
  17. -----------------------------------
  18. Required properties:
  19. - compatible: Should be one of:
  20. "st,stm32f4-adc-core"
  21. "st,stm32h7-adc-core"
  22. "st,stm32mp1-adc-core"
  23. - reg: Offset and length of the ADC block register set.
  24. - interrupts: One or more interrupts for ADC block. Some parts like stm32f4
  25. and stm32h7 share a common ADC interrupt line. stm32mp1 has two separate
  26. interrupt lines, one for each ADC within ADC block.
  27. - clocks: Core can use up to two clocks, depending on part used:
  28. - "adc" clock: for the analog circuitry, common to all ADCs.
  29. It's required on stm32f4.
  30. It's optional on stm32h7.
  31. - "bus" clock: for registers access, common to all ADCs.
  32. It's not present on stm32f4.
  33. It's required on stm32h7.
  34. - clock-names: Must be "adc" and/or "bus" depending on part used.
  35. - interrupt-controller: Identifies the controller node as interrupt-parent
  36. - vref-supply: Phandle to the vref input analog reference voltage.
  37. - #interrupt-cells = <1>;
  38. - #address-cells = <1>;
  39. - #size-cells = <0>;
  40. Optional properties:
  41. - A pinctrl state named "default" for each ADC channel may be defined to set
  42. inX ADC pins in mode of operation for analog input on external pin.
  43. Contents of a stm32 adc child node:
  44. -----------------------------------
  45. An ADC block node should contain at least one subnode, representing an
  46. ADC instance available on the machine.
  47. Required properties:
  48. - compatible: Should be one of:
  49. "st,stm32f4-adc"
  50. "st,stm32h7-adc"
  51. "st,stm32mp1-adc"
  52. - reg: Offset of ADC instance in ADC block (e.g. may be 0x0, 0x100, 0x200).
  53. - clocks: Input clock private to this ADC instance. It's required only on
  54. stm32f4, that has per instance clock input for registers access.
  55. - interrupt-parent: Phandle to the parent interrupt controller.
  56. - interrupts: IRQ Line for the ADC (e.g. may be 0 for adc@0, 1 for adc@100 or
  57. 2 for adc@200).
  58. - st,adc-channels: List of single-ended channels muxed for this ADC.
  59. It can have up to 16 channels on stm32f4 or 20 channels on stm32h7, numbered
  60. from 0 to 15 or 19 (resp. for in0..in15 or in0..in19).
  61. - st,adc-diff-channels: List of differential channels muxed for this ADC.
  62. Depending on part used, some channels can be configured as differential
  63. instead of single-ended (e.g. stm32h7). List here positive and negative
  64. inputs pairs as <vinp vinn>, <vinp vinn>,... vinp and vinn are numbered
  65. from 0 to 19 on stm32h7)
  66. Note: At least one of "st,adc-channels" or "st,adc-diff-channels" is required.
  67. Both properties can be used together. Some channels can be used as
  68. single-ended and some other ones as differential (mixed). But channels
  69. can't be configured both as single-ended and differential (invalid).
  70. - #io-channel-cells = <1>: See the IIO bindings section "IIO consumers" in
  71. Documentation/devicetree/bindings/iio/iio-bindings.txt
  72. Optional properties:
  73. - dmas: Phandle to dma channel for this ADC instance.
  74. See ../../dma/dma.txt for details.
  75. - dma-names: Must be "rx" when dmas property is being used.
  76. - assigned-resolution-bits: Resolution (bits) to use for conversions. Must
  77. match device available resolutions:
  78. * can be 6, 8, 10 or 12 on stm32f4
  79. * can be 8, 10, 12, 14 or 16 on stm32h7
  80. Default is maximum resolution if unset.
  81. - st,min-sample-time-nsecs: Minimum sampling time in nanoseconds.
  82. Depending on hardware (board) e.g. high/low analog input source impedance,
  83. fine tune of ADC sampling time may be recommended.
  84. This can be either one value or an array that matches 'st,adc-channels' list,
  85. to set sample time resp. for all channels, or independently for each channel.
  86. Example:
  87. adc: adc@40012000 {
  88. compatible = "st,stm32f4-adc-core";
  89. reg = <0x40012000 0x400>;
  90. interrupts = <18>;
  91. clocks = <&rcc 0 168>;
  92. clock-names = "adc";
  93. vref-supply = <&reg_vref>;
  94. interrupt-controller;
  95. pinctrl-names = "default";
  96. pinctrl-0 = <&adc3_in8_pin>;
  97. #interrupt-cells = <1>;
  98. #address-cells = <1>;
  99. #size-cells = <0>;
  100. adc@0 {
  101. compatible = "st,stm32f4-adc";
  102. #io-channel-cells = <1>;
  103. reg = <0x0>;
  104. clocks = <&rcc 0 168>;
  105. interrupt-parent = <&adc>;
  106. interrupts = <0>;
  107. st,adc-channels = <8>;
  108. dmas = <&dma2 0 0 0x400 0x0>;
  109. dma-names = "rx";
  110. assigned-resolution-bits = <8>;
  111. };
  112. ...
  113. other adc child nodes follow...
  114. };
  115. Example to setup:
  116. - channel 1 as single-ended
  117. - channels 2 & 3 as differential (with resp. 6 & 7 negative inputs)
  118. adc: adc@40022000 {
  119. compatible = "st,stm32h7-adc-core";
  120. ...
  121. adc1: adc@0 {
  122. compatible = "st,stm32h7-adc";
  123. ...
  124. st,adc-channels = <1>;
  125. st,adc-diff-channels = <2 6>, <3 7>;
  126. };
  127. };