Skip to contentSkip to conversation

Input: Add driver for Microchip's CAP1106

PATCH Applied Daniel Mack 2 participants 2 messages Jul 15, 2014 – Jul 20, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v5 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.

v4:
* Follow Mark Rutland's advices regarding the DTS bindings:
* Fix 'interrupt' node in the bindings documentation
* Drop the subnode structure, and store keycodes in an array named 'linux,keycodes'. This way, we no longer rely on subnodes ordering.
* Use of_property_read_bool() to read boolean properties.

* Re-introduce ->open() and ->close() for the input device, for power-saving purposes. Also, put the device to deep sleep at probe time, so it draws less power until ->open() is called.

* Re-introduce ->open() and ->close() for the input device, for power-saving purposes. Also, put the device to deep sleep at probe time, so it draws less power until ->open() is called.

v5:
* Remove input_unregister_device(). As that was the only call in the drivers ->remove() function, the entire thing can be dropped.
* Fix compilation error when building as module

 .../devicetree/bindings/input/cap1106.txt          |  53 ++++
 drivers/input/keyboard/Kconfig                     |  10 +
 drivers/input/keyboard/Makefile                    |   1 +
 drivers/input/keyboard/cap1106.c                   | 337 +++++++++++++++++++++
 4 files changed, 401 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 +53 -0
new file mode 100644
index 0000000..4b46390
@@ -0,0 +1,53 @@
+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.
+
+	interrupts:		Property describing the interrupt line the
+				device's ALERT#/CM_IRQ# pin is connected to.
+				The device only has one interrupt source.
+
+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.
+
+	linux,keycodes:		Specifies an array of numeric keycode values to
+				be used for the channels. If this property is
+				omitted, KEY_A, KEY_B, etc are used as
+				defaults. The array must have exactly six
+				entries.
+
+Example:
+
+i2c_controller {
+	cap1106@28 {
+		compatible = "microchip,cap1106";
+		interrupt-parent = <&gpio1>;
+		interrupts = <0 0>;
+		reg = <0x28>;
+		autorepeat;
+		microchip,sensor-gain = <2>;
+
+		linux,keycodes = <103		/* KEY_UP */
+				  106		/* KEY_RIGHT */
+				  108		/* KEY_DOWN */
+				  105		/* KEY_LEFT */
+				  109		/* KEY_PAGEDOWN */
+				  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 +337 -0

337 lines not on this page · raw message

Signature · 1 line
1.9.3
maintainer Applied
#1 lore raw
Quoted 10 lines · Daniel Mack

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.

Quoted 7 lines

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.

Applied, thank you.

Signature · 1 line
Dmitry