# SPDX-License-Identifier: GPL-2.0-only
%YAML 1.2
---
$id: http://devicetree.org/schemas/display/bridge/ti,tfp410.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: TFP410 DPI to DVI encoder

maintainers:
  - Tomi Valkeinen <tomi.valkeinen@ti.com>
  - Jyri Sarha <jsarha@ti.com>

properties:
  compatible:
    const: ti,tfp410

  reg:
    description: I2C address of the device.
    maxItems: 1

  powerdown-gpios:
    maxItems: 1

  ti,deskew:
    description:
      Data de-skew value in 350ps increments, from 0 to 7, as configured
      through the DK[3:1] pins. The de-skew multiplier is computed as
      (DK[3:1] - 4), so it ranges from -4 to 3.
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 0
    maximum: 7

  ports:
    $ref: /schemas/graph.yaml#/properties/ports

    properties:
      port@0:
        $ref: /schemas/graph.yaml#/$defs/port-base
        unevaluatedProperties: false
        description: DPI input port.

        properties:
          endpoint:
            $ref: /schemas/graph.yaml#/$defs/endpoint-base
            unevaluatedProperties: false

            properties:
              pclk-sample:
                description:
                  Endpoint sampling edge.
                enum:
                  - 0  # Falling edge
                  - 1  # Rising edge
                default: 0

              bus-width:
                description:
                  Endpoint bus width.
                enum:
                  - 12  # 12 data lines connected and dual-edge mode
                  - 24  # 24 data lines connected and single-edge mode
                default: 24

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

    required:
      - port@0
      - port@1

required:
  - compatible
  - ports

if:
  required:
    - reg
then:
  properties:
    ti,deskew: false
else:
  required:
    - ti,deskew

additionalProperties: false

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

    tfp410: encoder {
        compatible = "ti,tfp410";
        powerdown-gpios = <&twl_gpio 2 GPIO_ACTIVE_LOW>;
        ti,deskew = <3>;

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

            port@0 {
                reg = <0>;
                tfp410_in: endpoint {
                    pclk-sample = <1>;
                    bus-width = <24>;
                    remote-endpoint = <&dpi_out>;
                };
            };

            port@1 {
                reg = <1>;
                tfp410_out: endpoint {
                    remote-endpoint = <&dvi_connector_in>;
                };
            };
        };
    };

...