# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/adv7604.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices ADV7604/10/11/12 video decoder with HDMI receiver

maintainers:
  - Hans Verkuil <hverkuil-cisco@xs4all.nl>

description:
  The ADV7604 and ADV7610/11/12 are multiformat video decoders with
  an integrated HDMI receiver. The ADV7604 has four multiplexed HDMI inputs
  and one analog input, and the ADV7610/11 have one HDMI input and no analog
  input. The ADV7612 is similar to the ADV7610/11 but has 2 HDMI inputs.

  These device tree bindings support the ADV7610/11/12 only at the moment.

properties:
  compatible:
    items:
      - enum:
          - adi,adv7610
          - adi,adv7611
          - adi,adv7612

  reg:
    minItems: 1
    maxItems: 13

  reg-names:
    minItems: 1
    items:
      - const: main
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]
      - enum: [ avlink, cec, infoframe, esdp, dpp, afe, rep, edid, hdmi, test, cp, vdp ]

  interrupts:
    maxItems: 1

  reset-gpios:
    maxItems: 1

  hpd-gpios:
    minItems: 1
    description:
      References to the GPIOs that control the HDMI hot-plug detection pins,
      one per HDMI input. The active flag indicates the GPIO level that
      enables hot-plug detection.

  default-input:
    $ref: /schemas/types.yaml#/definitions/uint32
    enum: [ 0, 1 ]
    description:
      Select which input is selected after reset.

  ports: true

required:
  - compatible
  - reg
  - ports

additionalProperties: false

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: adi,adv7611
    then:
      properties:
        ports:
          $ref: /schemas/graph.yaml#/properties/ports
          properties:
            port@0:
              $ref: /schemas/graph.yaml#/properties/port
              description: Input port

            port@1:
              $ref: /schemas/graph.yaml#/properties/port
              description: Output port

          required:
            - port@1

  - if:
      properties:
        compatible:
          contains:
            const: adi,adv7612
    then:
      properties:
        ports:
          $ref: /schemas/graph.yaml#/properties/ports
          properties:
            port@2:
              $ref: /schemas/graph.yaml#/properties/port
              description: Output port

          patternProperties:
            "^port@[0-1]$":
              $ref: /schemas/graph.yaml#/properties/port
              description: Input port

          required:
            - port@2

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>

    i2c {
            #address-cells = <1>;
            #size-cells = <0>;

            hdmi_receiver@4c {
                    compatible = "adi,adv7611";
                    /*
                     * The edid page will be accessible @ 0x66 on the I2C bus. All
                     * other maps will retain their default addresses.
                     */
                    reg = <0x4c>, <0x66>;
                    reg-names = "main", "edid";

                    reset-gpios = <&ioexp 0 GPIO_ACTIVE_LOW>;
                    hpd-gpios = <&ioexp 2 GPIO_ACTIVE_HIGH>;
                    default-input = <0>;

                    ports {
                            #address-cells = <1>;
                            #size-cells = <0>;

                            port@0 {
                                    reg = <0>;
                            };

                            port@1 {
                                    reg = <1>;
                                    hdmi_in: endpoint {
                                            remote-endpoint = <&ccdc_in>;
                                    };
                            };
                    };


            };
    };