Skip to contentSkip to conversation

input: touchscreen: Add goodix GT5553 CTP support

PATCH Superseded Jagan Teki 2 participants 8 messages Feb 17, 2019 – Feb 18, 2019

Subsystems (4)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

v5 cover input: touchscreen: Add goodix GT5553 CTP support

This is v5 patchset for supporting goodix GT5553 CTP. Here is the previous version[1]

Changes for v4:
- document AVDD22, DVDD12, VDDIO as optional properties
- use regulator bulk calls, for get, enable and disable functionalities Changes for v4:
- devm_add_action_or_reset for disabling regulator
Changes for v3:
- add cover-letter
- s/ADVV28/AVDD28 on commit head
- fix few typo
Changes for v2:
- Rename vcc-supply with AVDD28-supply
- disable regulator in remove
- fix to setup regulator in probe code
- add chipdata
- drop example node in dt-bindings

[1] https://patchwork.kernel.org/cover/10807779/

Jagan Teki (4):
dt-bindings: input: touchscreen: goodix: Document regulator properties
Input: goodix - Add regulators support
dt-bindings: input: touchscreen: goodix: Add GT5663 compatible
Input: goodix - Add GT5663 CTP support

 .../bindings/input/touchscreen/goodix.txt     |  8 +++
 drivers/input/touchscreen/goodix.c            | 60 +++++++++++++++++--
 2 files changed, 62 insertions(+), 6 deletions(-)
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#1 lore raw

PATCH v5 1/4 dt-bindings: input: touchscreen: goodix: Document regulator properties

Goodix CTP controllers support analog, digital and gpio regulator supplies on relevant controller pin configurations.

Out of which AVDD28 regulator is mandatory supplied regulator in most of the board designs, so document AVDD28 as required property and rest marked as optional regulators.

---
 .../devicetree/bindings/input/touchscreen/goodix.txt       | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.txt +7 -0
index f7e95c52f3c7..8f6e6eede64d 100644
@@ -23,6 +23,13 @@ Optional properties:
  - touchscreen-inverted-y  : Y axis is inverted (boolean)
  - touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
                              (swapping is done after inverting the axis)
+ - AVDD28-supply	: Analog power supply regulator on AVDD28 pin
+
+Optional properties:
+
+ - AVDD22-supply	: Analog power supply regulator on AVDD22 pin
+ - DVDD12-supply	: Digital power supply regulator on DVDD12 pin
+ - VDDIO-supply		: GPIO power supply regulator on VDDIO pin
 
 Example:
 
Signature · 1 line
2.18.0.321.gffc6fa0e3
maintainer Reviewed-by on v5 1/4
#2 lore raw

Re: [PATCH v5 1/4] dt-bindings: input: touchscreen: goodix: Document regulator properties

Quoted 11 lines · Jagan Teki

Goodix CTP controllers support analog, digital and gpio regulator supplies on relevant controller pin configurations.

Out of which AVDD28 regulator is mandatory supplied regulator in most of the board designs, so document AVDD28 as required property and rest marked as optional regulators.

---
 .../devicetree/bindings/input/touchscreen/goodix.txt       | 7 +++++++
 1 file changed, 7 insertions(+)
author
#3 lore raw

Re: [PATCH v5 1/4] dt-bindings: input: touchscreen: goodix: Document regulator properties

Hi Rob,

Quoted 8 lines · Rob Herring
Quoted 6 lines · Jagan Teki

Goodix CTP controllers support analog, digital and gpio regulator supplies on relevant controller pin configurations.

Out of which AVDD28 regulator is mandatory supplied regulator in most of the board designs, so document AVDD28 as required property and rest marked as optional regulators.

Look like AVDD22, DVDD12 regulators are not being used in power-up schema pg. 12 so I would like to drop these two from bindings in next version set. let me know if you have any questions?

author
#4 lore raw

PATCH v5 2/4 Input: goodix - Add regulators support

In reply to Jagan Teki

Goodix CTP controllers support analog, digital and gpio regulator supplies on relevant controller pin configurations.

Support them via regulator bulk calls.

---
 drivers/input/touchscreen/goodix.c | 58 ++++++++++++++++++++++++++----
 1 file changed, 52 insertions(+), 6 deletions(-)
drivers/input/touchscreen/goodix.c +52 -6
index f2d9c2c41885..294456a53fe0 100644
@@ -27,6 +27,7 @@
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/of.h>
@@ -40,6 +41,15 @@ struct goodix_chip_data {
 	int (*check_config)(struct goodix_ts_data *, const struct firmware *);
 };
 
+static const char * const goodix_supply_names[] = {
+	"AVDD28",
+	"AVDD22",
+	"DVDD12",
+	"VDDIO",
+};
+
+#define GOODIX_NUM_SUPPLIES	ARRAY_SIZE(goodix_supply_names)
+
 struct goodix_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input_dev;
@@ -47,6 +57,7 @@ struct goodix_ts_data {
 	struct touchscreen_properties prop;
 	unsigned int max_touch_num;
 	unsigned int int_trigger_type;
+	struct regulator_bulk_data supplies[GOODIX_NUM_SUPPLIES];
 	struct gpio_desc *gpiod_int;
 	struct gpio_desc *gpiod_rst;
 	u16 id;
@@ -761,11 +772,18 @@ static void goodix_config_cb(const struct firmware *cfg, void *ctx)
 	complete_all(&ts->firmware_loading_complete);
 }
 
+static void goodix_disable_regulator(void *arg)
+{
+	struct goodix_ts_data *ts = arg;
+
+	regulator_bulk_disable(GOODIX_NUM_SUPPLIES, ts->supplies);
+}
+
 static int goodix_ts_probe(struct i2c_client *client,
 			   const struct i2c_device_id *id)
 {
 	struct goodix_ts_data *ts;
-	int error;
+	int error, i;
 
 	dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr);
 
@@ -786,25 +804,49 @@ static int goodix_ts_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
+	for (i = 0; i < GOODIX_NUM_SUPPLIES; i++)
+		ts->supplies[i].supply = goodix_supply_names[i];
+
+	error = devm_regulator_bulk_get(&client->dev, GOODIX_NUM_SUPPLIES,
+					ts->supplies);
+	if (error) {
+		dev_err(&client->dev, "Failed to get regulators (ret=%d)\n",
+			error);
+		return error;
+	}
+
+	error = devm_add_action_or_reset(&client->dev,
+					 goodix_disable_regulator, ts);
+	if (error)
+		return error;
+
+	/* power the controller */
+	error = regulator_bulk_enable(GOODIX_NUM_SUPPLIES, ts->supplies);
+	if (error) {
+		dev_err(&client->dev, "Failed to enable regulators (ret=%d)\n",
+			error);
+		return error;
+	}
+
 	if (ts->gpiod_int && ts->gpiod_rst) {
 		/* reset the controller */
 		error = goodix_reset(ts);
 		if (error) {
 			dev_err(&client->dev, "Controller reset failed.\n");
-			return error;
+			goto error;
 		}
 	}
 
 	error = goodix_i2c_test(client);
 	if (error) {
 		dev_err(&client->dev, "I2C communication failure: %d\n", error);
-		return error;
+		goto error;
 	}
 
 	error = goodix_read_version(ts);
 	if (error) {
 		dev_err(&client->dev, "Read version failed.\n");
-		return error;
+		goto error;
 	}
 
 	ts->chip = goodix_get_chip_data(ts->id);
@@ -823,17 +865,21 @@ static int goodix_ts_probe(struct i2c_client *client,
 			dev_err(&client->dev,
 				"Failed to invoke firmware loader: %d\n",
 				error);
-			return error;
+			goto error;
 		}
 
 		return 0;
 	} else {
 		error = goodix_configure_dev(ts);
 		if (error)
-			return error;
+			goto error;
 	}
 
 	return 0;
+
+error:
+	regulator_bulk_disable(GOODIX_NUM_SUPPLIES, ts->supplies);
+	return error;
 }
 
 static int goodix_ts_remove(struct i2c_client *client)
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#5 lore raw

PATCH v5 3/4 dt-bindings: input: touchscreen: goodix: Add GT5663 compatible

In reply to Jagan Teki

GT5663 is capacitive touch controller with customized smart wakeup gestures, it support chipdata which is similar to existing GT1151 and require AVDD28 supply for some boards.

Document the compatible for the same.

---
 Documentation/devicetree/bindings/input/touchscreen/goodix.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.txt +1 -0
index 8f6e6eede64d..29c149d91a05 100644
@@ -3,6 +3,7 @@ Device tree bindings for Goodix GT9xx series touchscreen controller
 Required properties:
 
  - compatible		: Should be "goodix,gt1151"
+				 or "goodix,gt5663"
 				 or "goodix,gt911"
 				 or "goodix,gt9110"
 				 or "goodix,gt912"
Signature · 1 line
2.18.0.321.gffc6fa0e3
maintainer Reviewed-by on v5 3/4
#6 lore raw

Re: [PATCH v5 3/4] dt-bindings: input: touchscreen: goodix: Add GT5663 compatible

Quoted 11 lines · Jagan Teki

GT5663 is capacitive touch controller with customized smart wakeup gestures, it support chipdata which is similar to existing GT1151 and require AVDD28 supply for some boards.

Document the compatible for the same.

---
 Documentation/devicetree/bindings/input/touchscreen/goodix.txt | 1 +
 1 file changed, 1 insertion(+)
author
#7 lore raw

PATCH v5 4/4 Input: goodix - Add GT5663 CTP support

In reply to Jagan Teki

GT5663 is capacitive touch controller with customized smart wakeup gestures.

Add support for it by adding compatible and supported chip data.

The chip data on GT5663 is similar to GT1151, like
- config data register has 0x8050 address
- config data register max len is 240
- config data checksum has 16-bit

---
 drivers/input/touchscreen/goodix.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/input/touchscreen/goodix.c +2 -0
index 294456a53fe0..80f8b920ef5e 100644
@@ -227,6 +227,7 @@ static const struct goodix_chip_data *goodix_get_chip_data(u16 id)
 {
 	switch (id) {
 	case 1151:
+	case 5663:
 		return &gt1x_chip_data;
 
 	case 911:
@@ -988,6 +989,7 @@ MODULE_DEVICE_TABLE(acpi, goodix_acpi_match);
 #ifdef CONFIG_OF
 static const struct of_device_id goodix_of_match[] = {
 	{ .compatible = "goodix,gt1151" },
+	{ .compatible = "goodix,gt5663" },
 	{ .compatible = "goodix,gt911" },
 	{ .compatible = "goodix,gt9110" },
 	{ .compatible = "goodix,gt912" },
Signature · 1 line
2.18.0.321.gffc6fa0e3