linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Add support for Goodix GT917S touch controller
@ 2020-02-28  1:01 Icenowy Zheng
  2020-02-28  1:01 ` [PATCH v3 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Icenowy Zheng @ 2020-02-28  1:01 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Bastien Nocera, Ondrej Jirman
  Cc: linux-input, devicetree, linux-kernel, Icenowy Zheng

This patchset introduces support for Goodix GT917S touch controller.

The major difference with other touch controllers from Goodix is that
the ID string is no longer number-only (it contains a 'S'), so an
additional patch is introduced for migrating the ID to a string.

Icenowy Zheng (3):
  dt-bindings: input: touchscreen: add compatible string for Goodix
    GT917S
  Input: goodix - use string-based chip ID
  Input: goodix - Add support for Goodix GT917S

 .../bindings/input/touchscreen/goodix.yaml    |  1 +
 drivers/input/touchscreen/goodix.c            | 71 +++++++++++--------
 2 files changed, 43 insertions(+), 29 deletions(-)

-- 
2.24.1


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

* [PATCH v3 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S
  2020-02-28  1:01 [PATCH v3 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
@ 2020-02-28  1:01 ` Icenowy Zheng
  2020-02-28  1:01 ` [PATCH v3 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Icenowy Zheng @ 2020-02-28  1:01 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Bastien Nocera, Ondrej Jirman
  Cc: linux-input, devicetree, linux-kernel, Icenowy Zheng, Rob Herring

Goodix GT917S is a new touchscreen chip from Goodix.

Add its compatible string to the device tree binding.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Rob Herring <robh@kernel.org>
---
No changes in v3.
Changes in v2:
- Adapted for the new YAML-based binding.
- Added Rob's ACK.

 Documentation/devicetree/bindings/input/touchscreen/goodix.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml b/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml
index d7c3262b2494..109e5ca8d6e8 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.yaml
@@ -21,6 +21,7 @@ properties:
       - goodix,gt911
       - goodix,gt9110
       - goodix,gt912
+      - goodix,gt917s
       - goodix,gt927
       - goodix,gt9271
       - goodix,gt928
-- 
2.24.1


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

* [PATCH v3 2/3] Input: goodix - use string-based chip ID
  2020-02-28  1:01 [PATCH v3 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
  2020-02-28  1:01 ` [PATCH v3 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
@ 2020-02-28  1:01 ` Icenowy Zheng
  2020-02-28  1:01 ` [PATCH v3 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng
  2020-02-28  9:46 ` [PATCH v3 0/3] Add support for Goodix GT917S touch controller Bastien Nocera
  3 siblings, 0 replies; 6+ messages in thread
From: Icenowy Zheng @ 2020-02-28  1:01 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Bastien Nocera, Ondrej Jirman
  Cc: linux-input, devicetree, linux-kernel, Icenowy Zheng

For Goodix GT917S chip, the chip ID string is "917S", which contains not
only numbers now.

Use string-based chip ID in the driver to support this chip and further
chips with alphanumber ID.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
Changes in v3:
- Added a macro to define the maximum length of ID.
Changes in v2:
- Used a table to save ID and chip data info.
- Use strscpy().

 drivers/input/touchscreen/goodix.c | 69 +++++++++++++++++-------------
 1 file changed, 40 insertions(+), 29 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 0403102e807e..9aec1356b45e 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -37,6 +37,13 @@ struct goodix_chip_data {
 	int (*check_config)(struct goodix_ts_data *, const struct firmware *);
 };
 
+struct goodix_chip_id {
+	const char *id;
+	const struct goodix_chip_data *data;
+};
+
+#define GOODIX_ID_MAX_LEN	4
+
 struct goodix_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input_dev;
@@ -48,7 +55,7 @@ struct goodix_ts_data {
 	struct regulator *vddio;
 	struct gpio_desc *gpiod_int;
 	struct gpio_desc *gpiod_rst;
-	u16 id;
+	char id[GOODIX_ID_MAX_LEN + 1];
 	u16 version;
 	const char *cfg_name;
 	struct completion firmware_loading_complete;
@@ -115,6 +122,22 @@ static const struct goodix_chip_data gt9x_chip_data = {
 	.check_config		= goodix_check_cfg_8,
 };
 
+static const struct goodix_chip_id goodix_chip_ids[] = {
+	{ .id = "1151", .data = &gt1x_chip_data },
+	{ .id = "5663", .data = &gt1x_chip_data },
+	{ .id = "5688", .data = &gt1x_chip_data },
+
+	{ .id = "911", .data = &gt911_chip_data },
+	{ .id = "9271", .data = &gt911_chip_data },
+	{ .id = "9110", .data = &gt911_chip_data },
+	{ .id = "927", .data = &gt911_chip_data },
+	{ .id = "928", .data = &gt911_chip_data },
+
+	{ .id = "912", .data = &gt967_chip_data },
+	{ .id = "967", .data = &gt967_chip_data },
+	{ }
+};
+
 static const unsigned long goodix_irq_flags[] = {
 	IRQ_TYPE_EDGE_RISING,
 	IRQ_TYPE_EDGE_FALLING,
@@ -235,28 +258,16 @@ static int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value)
 	return goodix_i2c_write(client, reg, &value, sizeof(value));
 }
 
-static const struct goodix_chip_data *goodix_get_chip_data(u16 id)
+static const struct goodix_chip_data *goodix_get_chip_data(const char *id)
 {
-	switch (id) {
-	case 1151:
-	case 5663:
-	case 5688:
-		return &gt1x_chip_data;
-
-	case 911:
-	case 9271:
-	case 9110:
-	case 927:
-	case 928:
-		return &gt911_chip_data;
-
-	case 912:
-	case 967:
-		return &gt967_chip_data;
-
-	default:
-		return &gt9x_chip_data;
+	unsigned int i;
+
+	for (i = 0; goodix_chip_ids[i].id; i++) {
+		if (!strcmp(goodix_chip_ids[i].id, id))
+			return goodix_chip_ids[i].data;
 	}
+
+	return &gt9x_chip_data;
 }
 
 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
@@ -663,7 +674,7 @@ static int goodix_read_version(struct goodix_ts_data *ts)
 {
 	int error;
 	u8 buf[6];
-	char id_str[5];
+	char id_str[GOODIX_ID_MAX_LEN + 1];
 
 	error = goodix_i2c_read(ts->client, GOODIX_REG_ID, buf, sizeof(buf));
 	if (error) {
@@ -671,14 +682,13 @@ static int goodix_read_version(struct goodix_ts_data *ts)
 		return error;
 	}
 
-	memcpy(id_str, buf, 4);
-	id_str[4] = 0;
-	if (kstrtou16(id_str, 10, &ts->id))
-		ts->id = 0x1001;
+	memcpy(id_str, buf, GOODIX_ID_MAX_LEN);
+	id_str[GOODIX_ID_MAX_LEN] = 0;
+	strscpy(ts->id, id_str, GOODIX_ID_MAX_LEN + 1);
 
 	ts->version = get_unaligned_le16(&buf[4]);
 
-	dev_info(&ts->client->dev, "ID %d, version: %04x\n", ts->id,
+	dev_info(&ts->client->dev, "ID %s, version: %04x\n", ts->id,
 		 ts->version);
 
 	return 0;
@@ -736,7 +746,8 @@ static int goodix_configure_dev(struct goodix_ts_data *ts)
 	ts->input_dev->phys = "input/ts";
 	ts->input_dev->id.bustype = BUS_I2C;
 	ts->input_dev->id.vendor = 0x0416;
-	ts->input_dev->id.product = ts->id;
+	if (kstrtou16(ts->id, 10, &ts->input_dev->id.product))
+		ts->input_dev->id.product = 0x1001;
 	ts->input_dev->id.version = ts->version;
 
 	/* Capacitive Windows/Home button on some devices */
@@ -915,7 +926,7 @@ static int goodix_ts_probe(struct i2c_client *client,
 	if (ts->gpiod_int && ts->gpiod_rst) {
 		/* update device config */
 		ts->cfg_name = devm_kasprintf(&client->dev, GFP_KERNEL,
-					      "goodix_%d_cfg.bin", ts->id);
+					      "goodix_%s_cfg.bin", ts->id);
 		if (!ts->cfg_name)
 			return -ENOMEM;
 
-- 
2.24.1


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

* [PATCH v3 3/3] Input: goodix - Add support for Goodix GT917S
  2020-02-28  1:01 [PATCH v3 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
  2020-02-28  1:01 ` [PATCH v3 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
  2020-02-28  1:01 ` [PATCH v3 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
@ 2020-02-28  1:01 ` Icenowy Zheng
  2020-02-28  9:46 ` [PATCH v3 0/3] Add support for Goodix GT917S touch controller Bastien Nocera
  3 siblings, 0 replies; 6+ messages in thread
From: Icenowy Zheng @ 2020-02-28  1:01 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Bastien Nocera, Ondrej Jirman
  Cc: linux-input, devicetree, linux-kernel, Icenowy Zheng

Goodix GT917S is a touchscreen chip from Goodix that is in the GT1x
family.

Add its support by assigning the gt1x config to it.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
No changes in v3.
Changes in v2:
- Change according to v2 of PATCH 2.

 drivers/input/touchscreen/goodix.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 9aec1356b45e..810cb467650a 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -126,6 +126,7 @@ static const struct goodix_chip_id goodix_chip_ids[] = {
 	{ .id = "1151", .data = &gt1x_chip_data },
 	{ .id = "5663", .data = &gt1x_chip_data },
 	{ .id = "5688", .data = &gt1x_chip_data },
+	{ .id = "917S", .data = &gt1x_chip_data },
 
 	{ .id = "911", .data = &gt911_chip_data },
 	{ .id = "9271", .data = &gt911_chip_data },
@@ -1061,6 +1062,7 @@ static const struct of_device_id goodix_of_match[] = {
 	{ .compatible = "goodix,gt911" },
 	{ .compatible = "goodix,gt9110" },
 	{ .compatible = "goodix,gt912" },
+	{ .compatible = "goodix,gt917s" },
 	{ .compatible = "goodix,gt927" },
 	{ .compatible = "goodix,gt9271" },
 	{ .compatible = "goodix,gt928" },
-- 
2.24.1


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

* Re: [PATCH v3 0/3] Add support for Goodix GT917S touch controller
  2020-02-28  1:01 [PATCH v3 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
                   ` (2 preceding siblings ...)
  2020-02-28  1:01 ` [PATCH v3 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng
@ 2020-02-28  9:46 ` Bastien Nocera
  2020-03-02 10:58   ` Bastien Nocera
  3 siblings, 1 reply; 6+ messages in thread
From: Bastien Nocera @ 2020-02-28  9:46 UTC (permalink / raw)
  To: Icenowy Zheng, Dmitry Torokhov, Rob Herring, Ondrej Jirman
  Cc: linux-input, devicetree, linux-kernel

On Fri, 2020-02-28 at 09:01 +0800, Icenowy Zheng wrote:
> This patchset introduces support for Goodix GT917S touch controller.
> 
> The major difference with other touch controllers from Goodix is that
> the ID string is no longer number-only (it contains a 'S'), so an
> additional patch is introduced for migrating the ID to a string.
> 
> Icenowy Zheng (3):
>   dt-bindings: input: touchscreen: add compatible string for Goodix
>     GT917S
>   Input: goodix - use string-based chip ID
>   Input: goodix - Add support for Goodix GT917S

For the whole patchset:
Reviewed-by: Bastien Nocera <hadess@hadess.net>

Thanks!

>  .../bindings/input/touchscreen/goodix.yaml    |  1 +
>  drivers/input/touchscreen/goodix.c            | 71 +++++++++++----
> ----
>  2 files changed, 43 insertions(+), 29 deletions(-)
> 



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

* Re: [PATCH v3 0/3] Add support for Goodix GT917S touch controller
  2020-02-28  9:46 ` [PATCH v3 0/3] Add support for Goodix GT917S touch controller Bastien Nocera
@ 2020-03-02 10:58   ` Bastien Nocera
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien Nocera @ 2020-03-02 10:58 UTC (permalink / raw)
  To: Icenowy Zheng, Dmitry Torokhov, Rob Herring, Ondrej Jirman
  Cc: linux-input, devicetree, linux-kernel

On Fri, 2020-02-28 at 10:46 +0100, Bastien Nocera wrote:
> On Fri, 2020-02-28 at 09:01 +0800, Icenowy Zheng wrote:
> > This patchset introduces support for Goodix GT917S touch
> > controller.
> > 
> > The major difference with other touch controllers from Goodix is
> > that
> > the ID string is no longer number-only (it contains a 'S'), so an
> > additional patch is introduced for migrating the ID to a string.
> > 
> > Icenowy Zheng (3):
> >   dt-bindings: input: touchscreen: add compatible string for Goodix
> >     GT917S
> >   Input: goodix - use string-based chip ID
> >   Input: goodix - Add support for Goodix GT917S
> 
> For the whole patchset:
> Reviewed-by: Bastien Nocera <hadess@hadess.net>

Dmitry, would be nice to land this soon, there are a couple of patches
still in the queue to be reviewed with support for new models, and they
will conflict with this one.

Cheers


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

end of thread, other threads:[~2020-03-02 10:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-28  1:01 [PATCH v3 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
2020-02-28  1:01 ` [PATCH v3 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
2020-02-28  1:01 ` [PATCH v3 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
2020-02-28  1:01 ` [PATCH v3 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng
2020-02-28  9:46 ` [PATCH v3 0/3] Add support for Goodix GT917S touch controller Bastien Nocera
2020-03-02 10:58   ` Bastien Nocera

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).