# Copyright (c) 2018, Endre Karlson
# Copyright (c) 2018, Song Qiang <songqiang1304521@gmail.com>
# SPDX-License-Identifier: Apache-2.0

description: ST STM32 family ADC

compatible: "st,stm32-adc"

include: [adc-controller.yaml, pinctrl-device.yaml]

properties:
  reg:
    required: true

  clocks:
    required: true

  interrupts:
    required: true

  "#io-channel-cells":
    const: 1

  pinctrl-0:
    required: true

  pinctrl-names:
    required: true

  st,adc-clock-source:
    type: int
    required: true
    enum:
      - 1 # SYNC for synchronous ADC clock source
      - 2 # ASYNC for asynchronous ADC clock source
    description: |
      Type of ADC clock source :
      - <SYNC>: derived from the bus clock.
      - <ASYNC> : independent and asynchronous with the bus clock
      One of the two values may not apply to some series. Refer to the RefMan.

  st,adc-prescaler:
    type: int
    required: true
    enum:
      - 1 # not divided
      - 2
      - 4
      - 6
      - 8
      - 10
      - 12
      - 16
      - 32
      - 64
      - 128
      - 256
    description: |
      Clock prescaler at the input of the ADC:
      Apply to synchronous or asynchronous clock depending on the STM32
      st,adc-clock-source.
      Some of the values may not apply to some series, and may depend on the
      selected clock source. Refer to the RefMan.
      On STM32F3x (except STM32F37x), this configures only the synchronous
      prescaler (see properties adcXX-prescaler in st,stm32f3-rcc bindings to
      set asynchronous prescaler).

  vref-mv:
    type: int
    default: 3300
    description: Indicates the reference voltage of the ADC in mV (on the target board).

  resolutions:
    type: array
    required: true
    description: |
      List of the resolutions supported by the ADC instance. They should be
      values created with STM32_ADC_RES macro or similar. Their order is not
      important. For example for STM32F4:
        <STM32_ADC_RES(12, 0x00) STM32_ADC_RES(10, 0x01)
         STM32_ADC_RES(8, 0x02)  STM32_ADC_RES(6, 0x03)>
      The two parameters are the resolution (for example 10 bits) and the
      corresponding register value (0x01 for a 10-bit resolution).
      By design, these macros also contains all register information (address,
      field offset and field mask) necessary to properly set the resolution.

  sampling-times:
    type: array
    required: true
    description: |
      List all the sampling times supported by the ADC instance.
      Rounded up if needed. Order is important: their index matches their binary
      value in the register.

  num-sampling-time-common-channels:
    type: int
    description: |
      Number of sampling time common channels for this ADC instance, if any.

  st,adc-sequencer:
    type: int
    required: true
    enum:
      - 0 # NOT_FULLY_CONFIGURABLE
      - 1 # FULLY_CONFIGURABLE
    description: |
      Type of ADC sequencer:
      - <NOT_FULLY_CONFIGURABLE>: Not fully configurable sequencer
      - <FULLY_CONFIGURABLE>: Fully configurable sequencer

io-channel-cells:
  - input
