Skip to contentSkip to conversation

Input: Add driver for Microchip's CAP1106

PATCH Superseded Daniel Mack 1 participant 1 message Jul 11, 2014

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Input: Add driver for Microchip's CAP1106

This patch adds a driver for Microchips CAP1106, an I2C driven, 6-channel capacitive touch sensor.

For now, only the capacitive buttons are supported, and no specific settings that can be tweaked for individual channels, except for the device-wide sensitivity gain. The defaults seem to work just fine out of the box, so I'll leave configurable parameters for someone who's in need of them and who can actually measure the impact. All registers are prepared, however. Many of them are just not used for now.

The implementation does not make any attempt to be compatible to platform data driven boards, but fully depends on CONFIG_OF.

Power management functions are also left for volounteers with the ability to actually test them.

---
v2:
* Fix potential deadlocks pointed out by David.

v3:
* Use devm_request_threaded_irq() and get rid of the work struct.
* Drop ->open() and ->close() as it isn't actually needed for an interrupt-driven device. This way, we can also get rid of the locking entirely.

 .../devicetree/bindings/input/cap1106.txt          |  63 ++++
 drivers/input/keyboard/Kconfig                     |  10 +
 drivers/input/keyboard/Makefile                    |   1 +
 drivers/input/keyboard/cap1106.c                   | 322 +++++++++++++++++++++
 4 files changed, 396 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/cap1106.txt
 create mode 100644 drivers/input/keyboard/cap1106.c
Documentation/devicetree/bindings/input/cap1106.txt new file +63 -0
new file mode 100644
index 0000000..57f5af3
@@ -0,0 +1,63 @@
+Device tree bindings for Microchip CAP1106, 6 channel capacitive touch sensor
+
+The node for this driver must be a child of a I2C controller node, as the
+device communication via I2C only.
+
+Required properties:
+
+	compatible:		Must be "microchip,cap1106"
+	reg:			The I2C slave address of the device.
+				Only 0x28 is valid.
+	interrupt:		Node describing the interrupt line the device's
+				ALERT#/CM_IRQ# pin is connected to.
+
+Optional properties:
+
+	autorepeat:		Enables the Linux input system's autorepeat
+				feature on the input device.
+	microchip,sensor-gain:	Defines the gain of the sensor circuitry. This
+				effectively controls the sensitivity, as a
+				smaller delta capacitance is required to
+				generate the same delta count values.
+				Valid values are 1, 2, 4, and 8.
+				By default, a gain of 1 is set.
+
+To define details of each individual button channel, six subnodes can be
+specified. Inside each of those, the following property is valid:
+
+	linux,keycode:	Specify the numeric identifier of the keycode to be
+			generated when this channel is activated. If this
+			property is omitted, KEY_A, KEY_B, etc are used as
+			defaults.
+
+Example:
+
+i2c_controller {
+	cap1106@28 {
+		compatible = "microchip,cap1106";
+		interrupt-parent = <&gpio1>;
+		interrupts = <0 0>;
+		reg = <0x28>;
+		autorepeat;
+		microchip,sensor-gain = <2>;
+
+		up {
+			linux,keycode = <103>; /* KEY_UP */
+		};
+		right {
+			linux,keycode = <106>; /* KEY_RIGHT */
+		};
+		down {
+			linux,keycode = <108>; /* KEY_DOWN */
+		};
+		left {
+			linux,keycode = <105>; /* KEY_LEFT */
+		};
+		pagedown {
+			linux,keycode = <109>; /* KEY_PAGEDOWN */
+		};
+		pageup {
+			linux,keycode = <104>; /* KEY_PAGEUP */
+		};
+	};
+}
drivers/input/keyboard/Kconfig +10 -0
index f7e79b4..a3958c6 100644
@@ -665,4 +665,14 @@ config KEYBOARD_CROS_EC
 	  To compile this driver as a module, choose M here: the
 	  module will be called cros_ec_keyb.
 
+config KEYBOARD_CAP1106
+	tristate "Microchip CAP1106 touch sensor"
+	depends on OF && I2C
+	select REGMAP_I2C
+	help
+	  Say Y here to enable the CAP1106 touch sensor driver.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cap1106.
+
 endif
drivers/input/keyboard/Makefile +1 -0
index 7504ae1..0a33456 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_KEYBOARD_AMIGA)		+= amikbd.o
 obj-$(CONFIG_KEYBOARD_ATARI)		+= atakbd.o
 obj-$(CONFIG_KEYBOARD_ATKBD)		+= atkbd.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
+obj-$(CONFIG_KEYBOARD_CAP1106)		+= cap1106.o
 obj-$(CONFIG_KEYBOARD_CLPS711X)		+= clps711x-keypad.o
 obj-$(CONFIG_KEYBOARD_CROS_EC)		+= cros_ec_keyb.o
 obj-$(CONFIG_KEYBOARD_DAVINCI)		+= davinci_keyscan.o
drivers/input/keyboard/cap1106.c new file +322 -0

322 lines not on this page · raw message

Signature · 1 line
1.9.3