# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/touchscreen/ti,ads7843.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: TI's SPI driven touch screen controllers

maintainers:
  - Alexander Stein <alexander.stein@ew.tq-group.com>
  - Dmitry Torokhov <dmitry.torokhov@gmail.com>
  - Marek Vasut <marex@denx.de>

description:
  TI's ADS7843, ADS7845, ADS7846, ADS7873, TSC2046 SPI driven touch screen
  controllers.

properties:
  compatible:
    enum:
      - ti,ads7843
      - ti,ads7845
      - ti,ads7846
      - ti,ads7873
      - ti,tsc2046

  interrupts:
    maxItems: 1

  pendown-gpio:
    maxItems: 1
    description:
      GPIO handle describing the pin the !PENIRQ line is connected to.

  vcc-supply:
    description:
      A regulator node for the supply voltage.

  wakeup-source: true

  ti,debounce-max:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Max number of additional readings per sample.

  ti,debounce-rep:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Additional consecutive good readings required after the first two.

  ti,debounce-tol:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Tolerance used for filtering.

  ti,hsync-gpios:
    maxItems: 1
    description:
      GPIO line to poll for hsync.

  ti,keep-vref-on:
    $ref: /schemas/types.yaml#/definitions/flag
    description:
      Set to keep Vref on for differential measurements as well.

  ti,pendown-gpio-debounce:
    $ref: /schemas/types.yaml#/definitions/uint32
    description:
      Platform specific debounce time for the pendown-gpio.

  ti,penirq-recheck-delay-usecs:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      If set to non-zero, after samples are taken this delay is applied and
      penirq is rechecked, to help avoid false events.  This value is
      affected by the material used to build the touch layer.

  ti,pressure-max:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Maximum reported pressure value.

  ti,pressure-min:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Minimum reported pressure value (threshold).

  ti,settle-delay-usec:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Settling time of the analog signals; a function of Vcc and the
      capacitance on the X/Y drivers.  If set to non-zero, two samples are
      taken with settle_delay us apart, and the second one is used. ~150
      uSec with 0.01uF caps.

  ti,swap-xy:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/flag
    description:
      Swap x and y axis.

  ti,vref-delay-usecs:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Vref supply delay in usecs, 0 for external Vref.

  ti,vref-mv:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      The VREF voltage, in millivolts.
      Set to 0 to use internal references (ADS7846).

  ti,x-plate-ohms:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Resistance of the X-plate, in Ohms.

  ti,x-max:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Maximum value on the X axis.

  ti,x-min:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Minimum value on the X axis.

  ti,y-plate-ohms:
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Resistance of the Y-plate, in Ohms.

  ti,y-max:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Maximum value on the Y axis.

  ti,y-min:
    deprecated: true
    $ref: /schemas/types.yaml#/definitions/uint16
    description:
      Minimum value on the Y axis.

required:
  - compatible
  - reg

allOf:
  - $ref: touchscreen.yaml#
  - $ref: /schemas/spi/spi-peripheral-props.yaml#

unevaluatedProperties: false

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

        touchscreen@0 {
           compatible = "ti,tsc2046";
           reg = <0>;	/* CS0 */
           interrupt-parent = <&gpio1>;
           interrupts = <8 0>;	/* BOOT6 / GPIO 8 */
           pendown-gpio = <&gpio1 8 0>;
           spi-max-frequency = <1000000>;
           vcc-supply = <&reg_vcc3>;
           wakeup-source;

           ti,pressure-max = /bits/ 16 <255>;
           ti,x-max = /bits/ 16 <8000>;
           ti,x-min = /bits/ 16 <0>;
           ti,x-plate-ohms = /bits/ 16 <40>;
           ti,y-max = /bits/ 16 <4800>;
           ti,y-min = /bits/ 16 <0>;
       };
    };
