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

title: ITE IT6625/IT6626 HDMI to dual MIPI CSI-2 bridge

maintainers:
  - Hermes Wu <Hermes.wu@ite.com.tw>

description:
  The ITE IT6625 and IT6626 are HDMI to MIPI CSI-2 bridge devices.
  IT6625 supports an HDMI 2.0 input and converts it to one or two D-PHY CSI
  outputs, while IT6626 supports an HDMI 2.1 input and converts it to one or
  two C/D-PHY CSI outputs. The bridges are programmable through I2C and
  expose two selectable CSI-2 output ports and an HDMI input port. The
  bridge can operate in split mode or clone mode.

properties:
  compatible:
    enum:
      - ite,it6625
      - ite,it6626

  reg:
    maxItems: 1

  interrupts:
    maxItems: 1

  reset-gpios:
    description:
      GPIO connected to the active-low reset line.
    maxItems: 1

  vcc10-supply:
    description: 1.0V core supply

  vdd33-supply:
    description: 3.3V supply

  ovdd-supply:
    description: I/O supply voltage

  ports:
    $ref: /schemas/graph.yaml#/properties/ports
    properties:
      port@0:
        $ref: /schemas/graph.yaml#/$defs/port-base
        unevaluatedProperties: false
        description: CSI-2 output port MIPI0

        properties:
          endpoint:
            $ref: /schemas/media/video-interfaces.yaml#
            unevaluatedProperties: false

            properties:
              data-lanes:
                minItems: 1
                maxItems: 4

              bus-type:
                enum:
                  - 1 # MEDIA_BUS_TYPE_CSI2_CPHY
                  - 4 # MEDIA_BUS_TYPE_CSI2_DPHY
                default: 4 # MEDIA_BUS_TYPE_CSI2_DPHY

            required:
              - data-lanes

      port@1:
        $ref: /schemas/graph.yaml#/$defs/port-base
        unevaluatedProperties: false
        description: CSI-2 output port MIPI1

        properties:
          endpoint:
            $ref: /schemas/media/video-interfaces.yaml#
            unevaluatedProperties: false

            properties:
              data-lanes:
                minItems: 1
                maxItems: 4

              bus-type:
                enum:
                  - 1 # MEDIA_BUS_TYPE_CSI2_CPHY
                  - 4 # MEDIA_BUS_TYPE_CSI2_DPHY
                default: 4 # MEDIA_BUS_TYPE_CSI2_DPHY

            required:
              - data-lanes

      port@2:
        $ref: /schemas/graph.yaml#/$defs/port-base
        unevaluatedProperties: false
        description: HDMI input port

    required:
      - port@0

required:
  - compatible
  - reg
  - ports
  - vcc10-supply
  - vdd33-supply
  - ovdd-supply

allOf:
  - if:
      properties:
        compatible:
          contains:
            const: ite,it6626
    then:
      properties:
        ports:
          properties:
            port@0:
              properties:
                endpoint:
                  required:
                    - bus-type
            port@1:
              properties:
                endpoint:
                  required:
                    - bus-type

additionalProperties: false

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

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

      hdmi-bridge@4c {
        compatible = "ite,it6625";
        reg = <0x4c>;
        interrupts = <3 IRQ_TYPE_LEVEL_LOW>;

        reset-gpios = <&gpio 2 GPIO_ACTIVE_LOW>;

        vcc10-supply = <&vcc10_reg>;
        vdd33-supply = <&vdd33_reg>;
        ovdd-supply = <&ovdd_reg>;

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

          port@0 {
            reg = <0>;
            csi_out0: endpoint {
              remote-endpoint = <&csi2_rx0>;
              bus-type = <4>; /* MEDIA_BUS_TYPE_CSI2_DPHY */
              data-lanes = <1 2 3 4>;
            };
          };

          port@2 {
            reg = <2>;
            endpoint {
              remote-endpoint = <&hdmi_con>;
            };
          };
        };
      };
    };