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

title: Freescale i.MX6UL Touch Controller

maintainers:
  - Haibo Chen <haibo.chen@nxp.com>
  - Shawn Guo <shawnguo@kernel.org>
  - Sascha Hauer <s.hauer@pengutronix.de>

properties:
  compatible:
    const: fsl,imx6ul-tsc

  reg:
    items:
      - description: touch controller address
      - description: ADC2 address

  interrupts:
    items:
      - description: touch controller address
      - description: ADC2 address

  clocks:
    maxItems: 2

  clock-names:
    items:
      - const: tsc
      - const: adc

  xnur-gpios:
    maxItems: 1
    description:
      The X- gpio this controller connect to. This xnur-gpio returns to
      low once the finger leave the touch screen (The last touch event
      the touch controller capture).

  measure-delay-time:
    $ref: /schemas/types.yaml#/definitions/uint32
    description:
      The value of measure delay time. Before X-axis or Y-axis measurement,
      the screen need some time before even potential distribution ready.
    default: 0xffff
    minimum: 0
    maximum: 0xffffff

  pre-charge-time:
    $ref: /schemas/types.yaml#/definitions/uint32
    description:
      The touch screen need some time to precharge.
    default: 0xfff
    minimum: 0
    maximum: 0xffffffff

  touchscreen-average-samples:
    $ref: /schemas/types.yaml#/definitions/uint32
    description: Number of data samples which are averaged for each read.
    enum: [ 1, 4, 8, 16, 32 ]

  debounce-delay-us:
    description: |
      Minimum duration in microseconds a signal must remain stable
      to be considered valid.

      Drivers must convert this value to IPG clock cycles and map
      it to one of the four discrete thresholds exposed by the
      TSC_DEBUG_MODE2 register:

        0: 8191 IPG cycles
        1: 4095 IPG cycles
        2: 2047 IPG cycles
        3: 1023 IPG cycles

required:
  - compatible
  - reg
  - interrupts
  - clocks
  - clock-names
  - xnur-gpios

allOf:
  - $ref: touchscreen.yaml#

additionalProperties: false

examples:
  - |
    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/clock/imx6ul-clock.h>
    #include <dt-bindings/gpio/gpio.h>
    touchscreen@2040000 {
        compatible = "fsl,imx6ul-tsc";
        reg = <0x02040000 0x4000>, <0x0219c000 0x4000>;
        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&clks IMX6UL_CLK_IPG>,
                 <&clks IMX6UL_CLK_ADC2>;
        clock-names = "tsc", "adc";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_tsc>;
        xnur-gpios = <&gpio1 3 GPIO_ACTIVE_LOW>;
        measure-delay-time = <0xfff>;
        pre-charge-time = <0xffff>;
        touchscreen-average-samples = <32>;
    };
