linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas
@ 2019-01-07 18:53 Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey Paweł Chmiel
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

This patches adds support for Aries (Samsung i9000) and Midas (Samsung S3)
based devices to TM2 Touchkey driver.

Changes from v2:
  - Change property name from keycodes to linux,keycodes

Changes from v1:
  - Added Reviewed-by to some patches
  - Use ints for keycodes (they could be bigger than 255)
  - Droped separate name changes
  - Added missing const in few places
  - Removed redundant cast

Jonathan Bakker (5):
  Input: tm2-touchkey: Correct initial brightness
  Input: tm2-touchkey: Allow specifying custom keycodes
  Input: dt-bindings: tm2-touchkey: Document new keycodes property
  Input: tm2-touchkey: Add support for aries touchkey variant
  Input: dt-bindings: tm2-touchkey: Add support for aries touchkey

Simon Shields (2):
  Input: tm2-touchkey: Add support for midas touchkey
  Input: dt-bindings: tm2-touchkey: Add support for midas touchkey

 .../bindings/input/cypress,tm2-touchkey.txt   |   9 +-
 drivers/input/keyboard/tm2-touchkey.c         | 132 +++++++++++++-----
 2 files changed, 108 insertions(+), 33 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 2/7] Input: dt-bindings: " Paweł Chmiel
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Simon Shields <simon@lineageos.org>

The touchkey on midas boards is almost identical.
The only real difference is that it uses the same register for both
keycode and base.

Signed-off-by: Simon Shields <simon@lineageos.org>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v1:
  - Droped separate name changes
  - Added missing const in few places
  - Removed redundant cast
---
 drivers/input/keyboard/tm2-touchkey.c | 34 +++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index abc266e40e17..5a1fe08bdd76 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -22,12 +22,12 @@
 #include <linux/leds.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/pm.h>
 #include <linux/regulator/consumer.h>
 
 #define TM2_TOUCHKEY_DEV_NAME		"tm2-touchkey"
-#define TM2_TOUCHKEY_KEYCODE_REG	0x03
-#define TM2_TOUCHKEY_BASE_REG		0x00
+
 #define TM2_TOUCHKEY_CMD_LED_ON		0x10
 #define TM2_TOUCHKEY_CMD_LED_OFF	0x20
 #define TM2_TOUCHKEY_BIT_PRESS_EV	BIT(3)
@@ -40,12 +40,28 @@ enum {
 	TM2_TOUCHKEY_KEY_BACK,
 };
 
+struct touchkey_variant {
+	u8 keycode_reg;
+	u8 base_reg;
+};
+
 struct tm2_touchkey_data {
 	struct i2c_client *client;
 	struct input_dev *input_dev;
 	struct led_classdev led_dev;
 	struct regulator *vdd;
 	struct regulator_bulk_data regulators[2];
+	const struct touchkey_variant *variant;
+};
+
+static const struct touchkey_variant tm2_touchkey_variant = {
+	.keycode_reg = 0x03,
+	.base_reg = 0x00,
+};
+
+static const struct touchkey_variant midas_touchkey_variant = {
+	.keycode_reg = 0x00,
+	.base_reg = 0x00,
 };
 
 static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -66,7 +82,7 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
 
 	regulator_set_voltage(touchkey->vdd, volt, volt);
 	i2c_smbus_write_byte_data(touchkey->client,
-				  TM2_TOUCHKEY_BASE_REG, data);
+				  touchkey->variant->base_reg, data);
 }
 
 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -99,7 +115,7 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 	int key;
 
 	data = i2c_smbus_read_byte_data(touchkey->client,
-					TM2_TOUCHKEY_KEYCODE_REG);
+					touchkey->variant->keycode_reg);
 	if (data < 0) {
 		dev_err(&touchkey->client->dev,
 			"failed to read i2c data: %d\n", data);
@@ -153,6 +169,8 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 	touchkey->client = client;
 	i2c_set_clientdata(client, touchkey);
 
+	touchkey->variant = of_device_get_match_data(&client->dev);
+
 	touchkey->regulators[0].supply = "vcc";
 	touchkey->regulators[1].supply = "vdd";
 	error = devm_regulator_bulk_get(&client->dev,
@@ -262,7 +280,13 @@ static const struct i2c_device_id tm2_touchkey_id_table[] = {
 MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table);
 
 static const struct of_device_id tm2_touchkey_of_match[] = {
-	{ .compatible = "cypress,tm2-touchkey", },
+	{
+		.compatible = "cypress,tm2-touchkey",
+		.data = &tm2_touchkey_variant,
+	}, {
+		.compatible = "cypress,midas-touchkey",
+		.data = &midas_touchkey_variant,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/7] Input: dt-bindings: tm2-touchkey: Add support for midas touchkey
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness Paweł Chmiel
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Simon Shields <simon@lineageos.org>

Document compatible for midas touchkey.

Signed-off-by: Simon Shields <simon@lineageos.org>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes from v1:
  - Added Reviewed-by
---
 .../devicetree/bindings/input/cypress,tm2-touchkey.txt        | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 0c252d9306da..dfb3b9f0ee40 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -1,7 +1,9 @@
 Samsung tm2-touchkey
 
 Required properties:
-- compatible: must be "cypress,tm2-touchkey"
+- compatible:
+    * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
+    * "cypress,midas-touchkey" - for the touchkey found on midas boards
 - reg: I2C address of the chip.
 - interrupts: interrupt to which the chip is connected (see interrupt
 	binding[0]).
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 2/7] Input: dt-bindings: " Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes Paweł Chmiel
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Jonathan Bakker <xc-racer2@live.ca>

Tm2-touchkey don't have brightness levels, but only on/off states,
so replace LED_FULL with LED_ON.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
 drivers/input/keyboard/tm2-touchkey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index 5a1fe08bdd76..0336789ab1bb 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -230,7 +230,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 
 	/* led device */
 	touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
-	touchkey->led_dev.brightness = LED_FULL;
+	touchkey->led_dev.brightness = LED_ON;
 	touchkey->led_dev.max_brightness = LED_ON;
 	touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
                   ` (2 preceding siblings ...)
  2019-01-07 18:53 ` [PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property Paweł Chmiel
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Jonathan Bakker <xc-racer2@live.ca>

Not all devices use the same keycodes in the same order,
so add possibility to define keycodes for buttons present
on actual hardware.

If keycodes property is not present, we assume that device has
at least MENU and BACK keys.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v2:
  - Change property name from keycodes to linux,keycodes

Changes from v1:
  - Because key codes could be bigger than 255, use ints for keycodes
---
 drivers/input/keyboard/tm2-touchkey.c | 49 +++++++++++++++------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index 0336789ab1bb..b55faf597d8a 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -35,11 +35,6 @@
 #define TM2_TOUCHKEY_LED_VOLTAGE_MIN	2500000
 #define TM2_TOUCHKEY_LED_VOLTAGE_MAX	3300000
 
-enum {
-	TM2_TOUCHKEY_KEY_MENU = 0x1,
-	TM2_TOUCHKEY_KEY_BACK,
-};
-
 struct touchkey_variant {
 	u8 keycode_reg;
 	u8 base_reg;
@@ -52,6 +47,8 @@ struct tm2_touchkey_data {
 	struct regulator *vdd;
 	struct regulator_bulk_data regulators[2];
 	const struct touchkey_variant *variant;
+	u32 keycodes[4];
+	int num_keycodes;
 };
 
 static const struct touchkey_variant tm2_touchkey_variant = {
@@ -112,7 +109,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 {
 	struct tm2_touchkey_data *touchkey = devid;
 	int data;
-	int key;
+	int index;
+	int i;
 
 	data = i2c_smbus_read_byte_data(touchkey->client,
 					touchkey->variant->keycode_reg);
@@ -122,26 +120,20 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 		goto out;
 	}
 
-	switch (data & TM2_TOUCHKEY_BIT_KEYCODE) {
-	case TM2_TOUCHKEY_KEY_MENU:
-		key = KEY_PHONE;
-		break;
-
-	case TM2_TOUCHKEY_KEY_BACK:
-		key = KEY_BACK;
-		break;
-
-	default:
+	index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1;
+	if (index < 0 || index >= touchkey->num_keycodes) {
 		dev_warn(&touchkey->client->dev,
-			 "unhandled keycode, data %#02x\n", data);
+			 "invalid keycode index %d\n", index);
 		goto out;
 	}
 
 	if (data & TM2_TOUCHKEY_BIT_PRESS_EV) {
-		input_report_key(touchkey->input_dev, KEY_PHONE, 0);
-		input_report_key(touchkey->input_dev, KEY_BACK, 0);
+		for (i = 0; i < touchkey->num_keycodes; i++)
+			input_report_key(touchkey->input_dev,
+					 touchkey->keycodes[i], 0);
 	} else {
-		input_report_key(touchkey->input_dev, key, 1);
+		input_report_key(touchkey->input_dev,
+				 touchkey->keycodes[index], 1);
 	}
 
 	input_sync(touchkey->input_dev);
@@ -153,8 +145,10 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 static int tm2_touchkey_probe(struct i2c_client *client,
 			      const struct i2c_device_id *id)
 {
+	struct device_node *np = client->dev.of_node;
 	struct tm2_touchkey_data *touchkey;
 	int error;
+	int i;
 
 	if (!i2c_check_functionality(client->adapter,
 			I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -184,6 +178,16 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 	/* Save VDD for easy access */
 	touchkey->vdd = touchkey->regulators[1].consumer;
 
+	touchkey->num_keycodes = of_property_read_variable_u32_array(np,
+					"linux,keycodes", touchkey->keycodes, 0,
+					ARRAY_SIZE(touchkey->keycodes));
+	if (touchkey->num_keycodes <= 0) {
+		/* default keycodes */
+		touchkey->keycodes[0] = KEY_PHONE;
+		touchkey->keycodes[1] = KEY_BACK;
+		touchkey->num_keycodes = 2;
+	}
+
 	error = tm2_touchkey_power_enable(touchkey);
 	if (error) {
 		dev_err(&client->dev, "failed to power up device: %d\n", error);
@@ -208,8 +212,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 	touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
 	touchkey->input_dev->id.bustype = BUS_I2C;
 
-	input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
-	input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK);
+	for (i = 0; i < touchkey->num_keycodes; i++)
+		input_set_capability(touchkey->input_dev, EV_KEY,
+				     touchkey->keycodes[i]);
 
 	error = input_register_device(touchkey->input_dev);
 	if (error) {
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
                   ` (3 preceding siblings ...)
  2019-01-07 18:53 ` [PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-11 14:30   ` Rob Herring
  2019-01-07 18:53 ` [PATCH v3 6/7] Input: tm2-touchkey: Add support for aries touchkey variant Paweł Chmiel
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Jonathan Bakker <xc-racer2@live.ca>

Document new optional property for setting custom keycodes.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v2:
  - Change property name from keycodes to linux,keycodes

Changes from v1:
  - Because key codes could be bigger than 255, use ints for keycodes
---
 .../devicetree/bindings/input/cypress,tm2-touchkey.txt        | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index dfb3b9f0ee40..8ef1517c0220 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -10,6 +10,9 @@ Required properties:
 - vcc-supply : internal regulator output. 1.8V
 - vdd-supply : power supply for IC 3.3V
 
+Optional properties:
+- linux,keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK
+
 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
 
 Example:
@@ -23,5 +26,6 @@ Example:
 			interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
 			vcc-supply=<&ldo32_reg>;
 			vdd-supply=<&ldo33_reg>;
+			linux,keycodes = <KEY_PHONE KEY_BACK>;
 		};
 	};
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 6/7] Input: tm2-touchkey: Add support for aries touchkey variant
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
                   ` (4 preceding siblings ...)
  2019-01-07 18:53 ` [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-07 18:53 ` [PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey Paweł Chmiel
  2019-01-07 19:53 ` [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Dmitry Torokhov
  7 siblings, 0 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Jonathan Bakker <xc-racer2@live.ca>

The touchkey variant found on aries board is slighty different,
it uses a fixed regulator and writes/read to the same place

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
 drivers/input/keyboard/tm2-touchkey.c | 53 +++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 7 deletions(-)

diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index b55faf597d8a..7dbef96559d2 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -28,6 +28,8 @@
 
 #define TM2_TOUCHKEY_DEV_NAME		"tm2-touchkey"
 
+#define ARIES_TOUCHKEY_CMD_LED_ON	0x1
+#define ARIES_TOUCHKEY_CMD_LED_OFF	0x2
 #define TM2_TOUCHKEY_CMD_LED_ON		0x10
 #define TM2_TOUCHKEY_CMD_LED_OFF	0x20
 #define TM2_TOUCHKEY_BIT_PRESS_EV	BIT(3)
@@ -38,6 +40,10 @@
 struct touchkey_variant {
 	u8 keycode_reg;
 	u8 base_reg;
+	u8 cmd_led_on;
+	u8 cmd_led_off;
+	bool no_reg;
+	bool fixed_regulator;
 };
 
 struct tm2_touchkey_data {
@@ -54,11 +60,22 @@ struct tm2_touchkey_data {
 static const struct touchkey_variant tm2_touchkey_variant = {
 	.keycode_reg = 0x03,
 	.base_reg = 0x00,
+	.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
+	.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
 };
 
 static const struct touchkey_variant midas_touchkey_variant = {
 	.keycode_reg = 0x00,
 	.base_reg = 0x00,
+	.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
+	.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
+};
+
+static struct touchkey_variant aries_touchkey_variant = {
+	.no_reg = true,
+	.fixed_regulator = true,
+	.cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON,
+	.cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF,
 };
 
 static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -71,15 +88,20 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
 
 	if (brightness == LED_OFF) {
 		volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
-		data = TM2_TOUCHKEY_CMD_LED_OFF;
+		data = touchkey->variant->cmd_led_off;
 	} else {
 		volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
-		data = TM2_TOUCHKEY_CMD_LED_ON;
+		data = touchkey->variant->cmd_led_on;
 	}
 
-	regulator_set_voltage(touchkey->vdd, volt, volt);
-	i2c_smbus_write_byte_data(touchkey->client,
-				  touchkey->variant->base_reg, data);
+	if (!touchkey->variant->fixed_regulator)
+		regulator_set_voltage(touchkey->vdd, volt, volt);
+
+	if (touchkey->variant->no_reg)
+		i2c_smbus_write_byte(touchkey->client, data);
+	else
+		i2c_smbus_write_byte_data(touchkey->client,
+					  touchkey->variant->base_reg, data);
 }
 
 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -112,8 +134,11 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 	int index;
 	int i;
 
-	data = i2c_smbus_read_byte_data(touchkey->client,
-					touchkey->variant->keycode_reg);
+	if (touchkey->variant->no_reg)
+		data = i2c_smbus_read_byte(touchkey->client);
+	else
+		data = i2c_smbus_read_byte_data(touchkey->client,
+						touchkey->variant->keycode_reg);
 	if (data < 0) {
 		dev_err(&touchkey->client->dev,
 			"failed to read i2c data: %d\n", data);
@@ -139,6 +164,14 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
 	input_sync(touchkey->input_dev);
 
 out:
+	if (touchkey->variant->fixed_regulator &&
+				data & TM2_TOUCHKEY_BIT_PRESS_EV) {
+		/* touch turns backlight on, so make sure we're in sync */
+		if (touchkey->led_dev.brightness == LED_OFF)
+			tm2_touchkey_led_brightness_set(&touchkey->led_dev,
+							LED_OFF);
+	}
+
 	return IRQ_HANDLED;
 }
 
@@ -246,6 +279,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
 		return error;
 	}
 
+	if (touchkey->variant->fixed_regulator)
+		tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON);
+
 	return 0;
 }
 
@@ -291,6 +327,9 @@ static const struct of_device_id tm2_touchkey_of_match[] = {
 	}, {
 		.compatible = "cypress,midas-touchkey",
 		.data = &midas_touchkey_variant,
+	}, {
+		.compatible = "cypress,aries-touchkey",
+		.data = &aries_touchkey_variant,
 	},
 	{ },
 };
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
                   ` (5 preceding siblings ...)
  2019-01-07 18:53 ` [PATCH v3 6/7] Input: tm2-touchkey: Add support for aries touchkey variant Paweł Chmiel
@ 2019-01-07 18:53 ` Paweł Chmiel
  2019-01-07 19:53 ` [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Dmitry Torokhov
  7 siblings, 0 replies; 10+ messages in thread
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	pawel.mikolaj.chmiel, xc-racer2, simon

From: Jonathan Bakker <xc-racer2@live.ca>

Document compatible for aries touchkey.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes from v1:
  - Added Reviewed-by
---
 Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 8ef1517c0220..ef2ae729718f 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -4,6 +4,7 @@ Required properties:
 - compatible:
     * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
     * "cypress,midas-touchkey" - for the touchkey found on midas boards
+    * "cypress,aries-touchkey" - for the touchkey found on aries boards
 - reg: I2C address of the chip.
 - interrupts: interrupt to which the chip is connected (see interrupt
 	binding[0]).
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas
  2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
                   ` (6 preceding siblings ...)
  2019-01-07 18:53 ` [PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey Paweł Chmiel
@ 2019-01-07 19:53 ` Dmitry Torokhov
  7 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2019-01-07 19:53 UTC (permalink / raw)
  To: Paweł Chmiel
  Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
	xc-racer2, simon

On Mon, Jan 07, 2019 at 07:53:39PM +0100, Paweł Chmiel wrote:
> This patches adds support for Aries (Samsung i9000) and Midas (Samsung S3)
> based devices to TM2 Touchkey driver.

Applied the lot, thank you.

> 
> Changes from v2:
>   - Change property name from keycodes to linux,keycodes
> 
> Changes from v1:
>   - Added Reviewed-by to some patches
>   - Use ints for keycodes (they could be bigger than 255)
>   - Droped separate name changes
>   - Added missing const in few places
>   - Removed redundant cast
> 
> Jonathan Bakker (5):
>   Input: tm2-touchkey: Correct initial brightness
>   Input: tm2-touchkey: Allow specifying custom keycodes
>   Input: dt-bindings: tm2-touchkey: Document new keycodes property
>   Input: tm2-touchkey: Add support for aries touchkey variant
>   Input: dt-bindings: tm2-touchkey: Add support for aries touchkey
> 
> Simon Shields (2):
>   Input: tm2-touchkey: Add support for midas touchkey
>   Input: dt-bindings: tm2-touchkey: Add support for midas touchkey
> 
>  .../bindings/input/cypress,tm2-touchkey.txt   |   9 +-
>  drivers/input/keyboard/tm2-touchkey.c         | 132 +++++++++++++-----
>  2 files changed, 108 insertions(+), 33 deletions(-)
> 
> -- 
> 2.17.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property
  2019-01-07 18:53 ` [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property Paweł Chmiel
@ 2019-01-11 14:30   ` Rob Herring
  0 siblings, 0 replies; 10+ messages in thread
From: Rob Herring @ 2019-01-11 14:30 UTC (permalink / raw)
  To: Paweł Chmiel
  Cc: dmitry.torokhov, mark.rutland, devicetree, linux-input,
	linux-kernel, xc-racer2, simon

On Mon, Jan 07, 2019 at 07:53:44PM +0100, Paweł Chmiel wrote:
> From: Jonathan Bakker <xc-racer2@live.ca>
> 
> Document new optional property for setting custom keycodes.
> 
> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
> Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
> ---
> Changes from v2:
>   - Change property name from keycodes to linux,keycodes
> 
> Changes from v1:
>   - Because key codes could be bigger than 255, use ints for keycodes
> ---
>  .../devicetree/bindings/input/cypress,tm2-touchkey.txt        | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-01-11 14:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-07 18:53 [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Paweł Chmiel
2019-01-07 18:53 ` [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey Paweł Chmiel
2019-01-07 18:53 ` [PATCH v3 2/7] Input: dt-bindings: " Paweł Chmiel
2019-01-07 18:53 ` [PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness Paweł Chmiel
2019-01-07 18:53 ` [PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes Paweł Chmiel
2019-01-07 18:53 ` [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property Paweł Chmiel
2019-01-11 14:30   ` Rob Herring
2019-01-07 18:53 ` [PATCH v3 6/7] Input: tm2-touchkey: Add support for aries touchkey variant Paweł Chmiel
2019-01-07 18:53 ` [PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey Paweł Chmiel
2019-01-07 19:53 ` [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).