From 7c9c2e970b0a047ae2a747752fdd12e31dbb2451 Mon Sep 17 00:00:00 2001
From: Jeff LaBundy <jeff@labundy.com>
Date: Mon, 28 Jan 2019 23:11:47 -0600
Subject: [PATCH] overlays: Add overlay for Azoteq IQS550

This patch adds a device tree overlay for the Azoteq IQS550
trackpad/touchscreen controller.

Signed-off-by: Jeff LaBundy <jeff@labundy.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             | 13 ++++++
 arch/arm/boot/dts/overlays/iqs550-overlay.dts | 46 +++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/iqs550-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -106,6 +106,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	iqaudio-dac.dtbo \
 	iqaudio-dacplus.dtbo \
 	iqaudio-digi-wm8804-audio.dtbo \
+	iqs550.dtbo \
 	irs1125.dtbo \
 	jedec-spi-nor.dtbo \
 	justboom-both.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -1991,6 +1991,19 @@ Params: card_name               Override
                                 dai stream name.
 
 
+Name:   iqs550
+Info:   Enables I2C connected Azoteq IQS550 trackpad/touchscreen controller
+        using GPIO 4 (pin 7 on GPIO header) for interrupt.
+Load:   dtoverlay=iqs550,<param>=<val>
+Params: interrupt               GPIO used for interrupt (default 4)
+        reset                   GPIO used for reset (optional)
+        sizex                   Touchscreen size x (default 800)
+        sizey                   Touchscreen size y (default 480)
+        invx                    Touchscreen inverted x axis
+        invy                    Touchscreen inverted y axis
+        swapxy                  Touchscreen swapped x y axis
+
+
 Name:   irs1125
 Info:   Infineon irs1125 TOF camera module.
         Uses Unicam 1, which is the standard camera connector on most Pi
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/iqs550-overlay.dts
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Definitions for Azoteq IQS550 trackpad/touchscreen controller
+/dts-v1/;
+/plugin/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+	compatible = "brcm,bcm2835";
+
+	fragment@0 {
+		target = <&i2c1>;
+		__overlay__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			iqs550: iqs550@74 {
+				compatible = "azoteq,iqs550";
+				reg = <0x74>;
+				interrupt-parent = <&gpio>;
+				interrupts = <4 IRQ_TYPE_LEVEL_HIGH>;
+				touchscreen-size-x = <800>;
+				touchscreen-size-y = <480>;
+			};
+		};
+	};
+
+	fragment@1 {
+		target = <&iqs550>;
+		iqs550_reset: __dormant__ {
+			reset-gpios = <&gpio 255 (GPIO_ACTIVE_LOW |
+						  GPIO_PUSH_PULL)>;
+		};
+	};
+
+	__overrides__ {
+		interrupt = <&iqs550>,"interrupts:0";
+		reset = <0>,"+1", <&iqs550_reset>,"reset-gpios:4";
+		sizex = <&iqs550>,"touchscreen-size-x:0";
+		sizey = <&iqs550>,"touchscreen-size-y:0";
+		invx = <&iqs550>,"touchscreen-inverted-x?";
+		invy = <&iqs550>,"touchscreen-inverted-y?";
+		swapxy = <&iqs550>,"touchscreen-swapped-x-y?";
+	};
+};
