# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/dac/adi,ad5686.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices AD5686 and similar SPI DACs

maintainers:
  - Michael Hennerich <michael.hennerich@analog.com>
  - Jonathan Cameron <jic23@kernel.org>

properties:
  compatible:
    enum:
      - adi,ad5310r
      - adi,ad5313r
      - adi,ad5317r
      - adi,ad5672r
      - adi,ad5674
      - adi,ad5674r
      - adi,ad5676
      - adi,ad5676r
      - adi,ad5679
      - adi,ad5679r
      - adi,ad5681r
      - adi,ad5682r
      - adi,ad5683
      - adi,ad5683r
      - adi,ad5684
      - adi,ad5684r
      - adi,ad5685r
      - adi,ad5686
      - adi,ad5686r
      - adi,ad5687
      - adi,ad5687r
      - adi,ad5689
      - adi,ad5689r

  reg:
    maxItems: 1

  vdd-supply:
    description: Input power supply.

  vlogic-supply:
    description:
      Digital power supply. On some tiny package variants for single-channel
      devices, this supply is internally connected to vdd; in that case, specify
      this property with the same regulator as vdd.

  vref-supply:
    description:
      Reference voltage supply. If not supplied the internal reference is used.

  vcc-supply:
    deprecated: true
    description: Use vref-supply instead.

  reset-gpios:
    description: Active-low RESET pin to reset the device.
    maxItems: 1

  ldac-gpios:
    description:
      Active-low LDAC pin used to asynchronously update the DAC channels.
    maxItems: 1

  gain-gpios:
    description:
      GAIN pin that sets a multiplier for the DAC output voltage. When high,
      the DAC output voltage is multiplied by 2, otherwise it is unchanged.
    maxItems: 1

  adi,range-double:
    description:
      Sets the initial voltage output range from 0 to 2xVREF. On devices that
      have a GAIN pin and no gain-gpios property is set, this indicates the pin
      is hardwired high.
    type: boolean

required:
  - compatible
  - reg
  - vdd-supply
  - vlogic-supply

allOf:
  - $ref: /schemas/spi/spi-peripheral-props.yaml#
  - if:
      properties:
        compatible:
          contains:
            enum:
              - adi,ad5674
              - adi,ad5676
              - adi,ad5679
              - adi,ad5683
              - adi,ad5684
              - adi,ad5686
              - adi,ad5687
              - adi,ad5689
    then:
      required:
        - vref-supply
  - if:
      properties:
        compatible:
          contains:
            enum:
              - adi,ad5310r
              - adi,ad5681r
              - adi,ad5682r
              - adi,ad5683
              - adi,ad5683r
    then:
      properties:
        gain-gpios: false

unevaluatedProperties: false

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    spi {
        #address-cells = <1>;
        #size-cells = <0>;
        dac@0 {
            reg = <0>;
            compatible = "adi,ad5310r";
            vdd-supply = <&dac_vdd>;
            vlogic-supply = <&dac_vlogic>;
            vref-supply = <&dac_vref>;
            reset-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
            ldac-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
        };
    };
...