# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/display/panel/sitronix,st7701.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Sitronix ST7701 based LCD panels

maintainers:
  - Jagan Teki <jagan@amarulasolutions.com>

description: |
  ST7701 designed for small and medium sizes of TFT LCD display, is
  capable of supporting up to 480RGBX864 in resolution. It provides
  several system interfaces like MIPI/RGB/SPI.

  Techstar TS8550B is 480x854, 2-lane MIPI DSI LCD panel which has
  inbuilt ST7701 chip.

  Densitron DMT028VGHMCMI-1A is 480x640, 2-lane MIPI DSI LCD panel
  which has built-in ST7701 chip.

properties:
  compatible:
    items:
      - enum:
          - anbernic,rg-arc-panel
          - anbernic,rg28xx-panel
          - densitron,dmt028vghmcmi-1a
          - elida,kd50t048a
          - techstar,ts8550b
      - const: sitronix,st7701

  reg:
    description: DSI / SPI channel used by that screen
    maxItems: 1

  VCC-supply:
    description: analog regulator for MIPI circuit

  IOVCC-supply:
    description: I/O system regulator

  dc-gpios:
    maxItems: 1
    description:
      Controller data/command selection (D/CX) in 4-line SPI mode.
      If not set, the controller is in 3-line SPI mode.
      Disallowed for DSI.

  port: true
  reset-gpios: true
  rotation: true

  backlight: true

required:
  - compatible
  - reg
  - VCC-supply
  - IOVCC-supply
  - port
  - reset-gpios

allOf:
  - $ref: panel-common.yaml#
  - if:
      properties:
        compatible:
          contains:
            # SPI connected panels
            enum:
              - anbernic,rg28xx-panel
    then:
      $ref: /schemas/spi/spi-peripheral-props.yaml#

  - if:
      properties:
        compatible:
          not:
            contains:
              # DSI or SPI without D/CX pin
              enum:
                - anbernic,rg-arc-panel
                - anbernic,rg28xx-panel
                - densitron,dmt028vghmcmi-1a
                - elida,kd50t048a
                - techstar,ts8550b
    then:
      required:
        - dc-gpios
    else:
      properties:
        dc-gpios: false

unevaluatedProperties: false

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

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

        panel@0 {
            compatible = "techstar,ts8550b", "sitronix,st7701";
            reg = <0>;
            VCC-supply = <&reg_dldo2>;
            IOVCC-supply = <&reg_dldo2>;
            reset-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* LCD-RST: PD24 */
            backlight = <&backlight>;

            port {
                mipi_in_panel: endpoint {
                    remote-endpoint = <&mipi_out_panel>;
                };
            };
        };
    };
  - |
    #include <dt-bindings/gpio/gpio.h>

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

        panel@0 {
            compatible = "anbernic,rg28xx-panel", "sitronix,st7701";
            reg = <0>;
            spi-max-frequency = <3125000>;
            VCC-supply = <&reg_lcd>;
            IOVCC-supply = <&reg_lcd>;
            reset-gpios = <&pio 8 14 GPIO_ACTIVE_HIGH>; /* LCD-RST: PI14 */
            backlight = <&backlight>;

            port {
                panel_in_rgb: endpoint {
                    remote-endpoint = <&tcon_lcd0_out_lcd>;
                };
            };
        };
    };
