Skip to contentSkip to conversation

cap1106: add support for cap11xx variants

PATCH Superseded Matt Ranostay 2 participants 6 messages Oct 10, 2014

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover cap1106: add support for cap11xx variants

Changes from v4:

* Only allocate private structure and keycodes memory once

Matt Ranostay (3):
cap11xx: make driver generic for variant support
cap11xx: Add support for various cap11xx devices
cap11xx: support for irq-active-high option

 .../bindings/input/{cap1106.txt => cap11xx.txt}    |  12 +-
 drivers/input/keyboard/Kconfig                     |   8 +-
 drivers/input/keyboard/Makefile                    |   2 +-
 drivers/input/keyboard/cap1106.c                   | 341 -------------------
 drivers/input/keyboard/cap11xx.c                   | 368 +++++++++++++++++++++
 5 files changed, 382 insertions(+), 349 deletions(-)
 rename Documentation/devicetree/bindings/input/{cap1106.txt => cap11xx.txt} (78%)
 delete mode 100644 drivers/input/keyboard/cap1106.c
 create mode 100644 drivers/input/keyboard/cap11xx.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v5 1/3 cap11xx: make driver generic for variant support

cap1106 driver can support much more one device make the driver generic for support of similiar parts.

---
 .../bindings/input/{cap1106.txt => cap11xx.txt}    |   5 +-
 drivers/input/keyboard/Kconfig                     |   8 +-
 drivers/input/keyboard/Makefile                    |   2 +-
 drivers/input/keyboard/cap1106.c                   | 341 ---------------------
 drivers/input/keyboard/cap11xx.c                   | 340 ++++++++++++++++++++
 5 files changed, 348 insertions(+), 348 deletions(-)
 rename Documentation/devicetree/bindings/input/{cap1106.txt => cap11xx.txt} (89%)
 delete mode 100644 drivers/input/keyboard/cap1106.c
 create mode 100644 drivers/input/keyboard/cap11xx.c
Documentation/devicetree/bindings/input/cap11xx.txt renamed from Documentation/devicetree/bindings/input/cap1106.txt +3 -2
similarity index 89%
rename from Documentation/devicetree/bindings/input/cap1106.txt
rename to Documentation/devicetree/bindings/input/cap11xx.txt
index 4b46390..738f5f3 100644
@@ -1,11 +1,12 @@
-Device tree bindings for Microchip CAP1106, 6 channel capacitive touch sensor
+Device tree bindings for Microchip CAP1106 based 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"
+	compatible:		Must be on the following, depending on the model:
+					"microchip,cap1106"
 
 	reg:			The I2C slave address of the device.
 				Only 0x28 is valid.
drivers/input/keyboard/Kconfig +4 -4
index a3958c6..96ee26c 100644
@@ -665,14 +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"
+config KEYBOARD_CAP11XX
+	tristate "Microchip CAP11XX based touch sensors"
 	depends on OF && I2C
 	select REGMAP_I2C
 	help
-	  Say Y here to enable the CAP1106 touch sensor driver.
+	  Say Y here to enable the CAP11XX touch sensor driver.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called cap1106.
+	  module will be called cap11xx.
 
 endif
drivers/input/keyboard/Makefile +1 -1
index 0a33456..febafa5 100644
@@ -11,7 +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_CAP11XX)		+= cap11xx.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 deleted +0 -341

341 lines not on this page · raw message

drivers/input/keyboard/cap11xx.c new file +340 -0

340 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v5 2/3 cap11xx: Add support for various cap11xx devices

In reply to Matt Ranostay

Several other variants of the cap11xx device exists with a varying number of capacitance detection channels. Add support for creating the channels dynamically.

---
 .../devicetree/bindings/input/cap11xx.txt          |  3 +-
 drivers/input/keyboard/cap11xx.c                   | 64 ++++++++++++++--------
 2 files changed, 44 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/input/cap11xx.txt +2 -1
index 738f5f3..8031aa5 100644
@@ -7,9 +7,10 @@ Required properties:
 
 	compatible:		Must be on the following, depending on the model:
 					"microchip,cap1106"
+					"microchip,cap1126"
+					"microchip,cap1188"
 
 	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.
drivers/input/keyboard/cap11xx.c +42 -22

140 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#3 lore raw

Re: [PATCH v5 2/3] cap11xx: Add support for various cap11xx devices

Hi Matt,

drivers/input/keyboard/cap11xx.c struct cap11xx_priv { · line 64

Quoted 7 lines · Matt Ranostay
drivers/input/keyboard/cap11xx.c +2 -1
@@ -63,7 +60,25 @@ struct cap11xx_priv {
 	struct input_dev *idev;
 
 	/* config */
-	unsigned short keycodes[CAP11XX_NUM_CHN];
+	unsigned int num_channels;
+	u32 keycodes[];

Any particular reason you decided to keep num_channels field givfen that the same data is accessible through priv->idev->keycodemax?

Thanks.

Signature · 1 line
Dmitry
#4 lore raw

Re: [PATCH v5 2/3] cap11xx: Add support for various cap11xx devices

No just an oversight..

Thanks,

Matt

Quoted 18 lines · Dmitry Torokhov

Hi Matt,

drivers/input/keyboard/cap11xx.c struct cap11xx_priv { · line 64

Quoted 7 lines · Matt Ranostay
drivers/input/keyboard/cap11xx.c +2 -1
@@ -63,7 +60,25 @@ struct cap11xx_priv {
      struct input_dev *idev;
 
      /* config */
-     unsigned short keycodes[CAP11XX_NUM_CHN];
+     unsigned int num_channels;
+     u32 keycodes[];

Any particular reason you decided to keep num_channels field givfen that the same data is accessible through priv->idev->keycodemax?

Thanks.

--
Dmitry

#5 lore raw

PATCH v5 3/3 cap11xx: support for irq-active-high option

In reply to Matt Ranostay

Some applications need to use the irq-active-high push-pull option. This allows it be enabled in the device tree child node.

---
 Documentation/devicetree/bindings/input/cap11xx.txt | 4 ++++
 drivers/input/keyboard/cap11xx.c                    | 8 ++++++++
 2 files changed, 12 insertions(+)
Documentation/devicetree/bindings/input/cap11xx.txt +4 -0
index 8031aa5..57407be 100644
@@ -28,6 +28,10 @@ Optional properties:
 				Valid values are 1, 2, 4, and 8.
 				By default, a gain of 1 is set.
 
+	microchip,irq-active-high:	By default the interrupt pin is active low
+				open drain. This property allows using the active
+				high push-pull output.
+
 	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
drivers/input/keyboard/cap11xx.c +8 -0
index b605134..a75b8fc 100644
@@ -45,6 +45,7 @@
 #define CAP11XX_REG_STANDBY_SENSITIVITY	0x42
 #define CAP11XX_REG_STANDBY_THRESH	0x43
 #define CAP11XX_REG_CONFIG2		0x44
+#define CAP11XX_REG_CONFIG2_ALT_POL	BIT(6)
 #define CAP11XX_REG_SENSOR_BASE_CNT(X)	(0x50 + (X))
 #define CAP11XX_REG_SENSOR_CALIB	(0xb1 + (X))
 #define CAP11XX_REG_SENSOR_CALIB_LSB1	0xb9
@@ -255,6 +256,13 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
 			dev_err(dev, "Invalid sensor-gain value %d\n", gain32);
 	}
 
+	if (of_property_read_bool(node, "microchip,irq-active-high")) {
+		error = regmap_update_bits(priv->regmap, CAP11XX_REG_CONFIG2,
+					   CAP11XX_REG_CONFIG2_ALT_POL, 0);
+		if (error)
+			return error;
+	}
+
 	/* Provide some useful defaults */
 	for (i = 0; i < priv->num_channels; i++)
 		priv->keycodes[i] = KEY_A + i;
Signature · 1 line
1.9.1