From 62ae8907efb221f232126726bf4df5c9da23a8b4 Mon Sep 17 00:00:00 2001
From: Jesse Taube <Mr.Bossman075@gmail.com>
Date: Thu, 8 Jul 2021 16:32:16 -0400
Subject: [PATCH] overlays: Add overlay for cap1106 capacitive touch
 sensor

Signed-off-by: Jesse Taube  <mr.bossman075@gmail.com>
---
 arch/arm/boot/dts/overlays/Makefile           |  1 +
 arch/arm/boot/dts/overlays/README             |  6 +++
 .../arm/boot/dts/overlays/cap1106-overlay.dts | 52 +++++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 arch/arm/boot/dts/overlays/cap1106-overlay.dts

--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -30,6 +30,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
 	audiosense-pi.dtbo \
 	audremap.dtbo \
 	balena-fin.dtbo \
+	cap1106.dtbo \
 	chipdip-i2s-master-dac.dtbo \
 	cma.dtbo \
 	dht11.dtbo \
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -622,6 +622,12 @@ Info:   This overlay is now deprecated -
 Load:   <Deprecated>
 
 
+Name:   cap1106
+Info:   Enables the ability to use the cap1106 touch sensor as a keyboard
+Load:   dtoverlay=cap1106,<param>=<val>
+Params: int_pin                 GPIO pin for interrupt signal (default 23)
+
+
 Name:   chipdip-i2s-master-dac
 Info:   Configures Raspberry PI to work as I2S slave with BCLK=64Fs.
 Load:   dtoverlay=chipdip-i2s-master-dac
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/cap1106-overlay.dts
@@ -0,0 +1,52 @@
+// Overlay for cap1106 from  Microchip Semiconductor
+// add CONFIG_KEYBOARD_CAP11XX=y
+
+/dts-v1/;
+/plugin/;
+
+/ {
+        compatible = "brcm,bcm2835";
+        fragment@0 {
+                target = <&i2c1>;
+                __overlay__{
+                        status = "okay";
+                        cap1106: cap1106@28 {
+                                compatible = "microchip,cap1106";
+                                pinctrl-0 = <&cap1106_pins>;
+                                pinctrl-names = "default";
+                                interrupt-parent = <&gpio>;
+                                interrupts = <4 2>;
+                                reg = <0x28>;
+                                autorepeat;
+                                microchip,sensor-gain = <2>;
+
+                                linux,keycodes = <2>,           /* KEY_1 */
+                                                <3>,            /* KEY_2 */
+                                                <4>,            /* KEY_3 */
+                                                <5>,            /* KEY_4 */
+                                                <6>,            /* KEY_5 */
+                                                <7>;            /* KEY_6 */
+
+                                #address-cells = <1>;
+                                #size-cells = <0>;
+                                status = "okay";
+
+                        };
+                };
+        };
+        fragment@1 {
+                target = <&gpio>;
+                __overlay__ {
+                        cap1106_pins: cap1106_pins {
+                                brcm,pins = <4>;
+                                brcm,function = <0>; /* in */
+                                brcm,pull = <0>; /* none */
+                        };
+                };
+        };
+
+        __overrides__ {
+                int_pin = <&cap1106>, "interrupts:0",
+                          <&cap1106_pins>, "brcm,pins:0";
+        };
+};
