All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add support for Goodix GT917S touch controller
@ 2020-01-10 16:26 Icenowy Zheng
  2020-01-10 16:26 ` [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Icenowy Zheng @ 2020-01-10 16:26 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Mark Rutland, Bastien Nocera, Jagan Teki
  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.txt     |  1 +
 drivers/input/touchscreen/goodix.c            | 41 +++++++++----------
 2 files changed, 21 insertions(+), 21 deletions(-)

-- 
2.23.0


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

* [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S
  2020-01-10 16:26 [PATCH 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
@ 2020-01-10 16:26 ` Icenowy Zheng
  2020-01-15 15:25   ` Rob Herring
  2020-01-10 16:26 ` [PATCH 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
  2020-01-10 16:26 ` [PATCH 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng
  2 siblings, 1 reply; 6+ messages in thread
From: Icenowy Zheng @ 2020-01-10 16:26 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Mark Rutland, Bastien Nocera, Jagan Teki
  Cc: linux-input, devicetree, linux-kernel, Icenowy Zheng

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>
---
 Documentation/devicetree/bindings/input/touchscreen/goodix.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
index fc03ea4cf5ab..c5447b136eb3 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
@@ -8,6 +8,7 @@ Required properties:
 				 or "goodix,gt911"
 				 or "goodix,gt9110"
 				 or "goodix,gt912"
+				 or "goodix,gt917s"
 				 or "goodix,gt927"
 				 or "goodix,gt9271"
 				 or "goodix,gt928"
-- 
2.23.0


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

* [PATCH 2/3] Input: goodix - use string-based chip ID
  2020-01-10 16:26 [PATCH 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
  2020-01-10 16:26 ` [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
@ 2020-01-10 16:26 ` Icenowy Zheng
  2020-01-11  0:26   ` Dmitry Torokhov
  2020-01-10 16:26 ` [PATCH 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng
  2 siblings, 1 reply; 6+ messages in thread
From: Icenowy Zheng @ 2020-01-10 16:26 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Mark Rutland, Bastien Nocera, Jagan Teki
  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>
---
 drivers/input/touchscreen/goodix.c | 39 ++++++++++++++----------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 0403102e807e..bfd067d7145e 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -48,7 +48,7 @@ struct goodix_ts_data {
 	struct regulator *vddio;
 	struct gpio_desc *gpiod_int;
 	struct gpio_desc *gpiod_rst;
-	u16 id;
+	char id[5];
 	u16 version;
 	const char *cfg_name;
 	struct completion firmware_loading_complete;
@@ -235,28 +235,25 @@ 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:
+	if (!strcmp(id, "1151") ||
+	    !strcmp(id, "5663") ||
+	    !strcmp(id, "5688"))
 		return &gt1x_chip_data;
 
-	case 911:
-	case 9271:
-	case 9110:
-	case 927:
-	case 928:
+	if (!strcmp(id, "911") ||
+	    !strcmp(id, "9271") ||
+	    !strcmp(id, "9110") ||
+	    !strcmp(id, "927") ||
+	    !strcmp(id, "928"))
 		return &gt911_chip_data;
 
-	case 912:
-	case 967:
+	if (!strcmp(id, "912") ||
+	    !strcmp(id, "967"))
 		return &gt967_chip_data;
 
-	default:
-		return &gt9x_chip_data;
-	}
+	return &gt9x_chip_data;
 }
 
 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
@@ -673,12 +670,11 @@ static int goodix_read_version(struct goodix_ts_data *ts)
 
 	memcpy(id_str, buf, 4);
 	id_str[4] = 0;
-	if (kstrtou16(id_str, 10, &ts->id))
-		ts->id = 0x1001;
+	strscpy(ts->id, id_str, 5);
 
 	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 +732,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 +912,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.23.0


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

* [PATCH 3/3] Input: goodix - Add support for Goodix GT917S
  2020-01-10 16:26 [PATCH 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
  2020-01-10 16:26 ` [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
  2020-01-10 16:26 ` [PATCH 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
@ 2020-01-10 16:26 ` Icenowy Zheng
  2 siblings, 0 replies; 6+ messages in thread
From: Icenowy Zheng @ 2020-01-10 16:26 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Mark Rutland, Bastien Nocera, Jagan Teki
  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>
---
 drivers/input/touchscreen/goodix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index bfd067d7145e..43d8e1b8fb7f 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -239,7 +239,8 @@ static const struct goodix_chip_data *goodix_get_chip_data(const char *id)
 {
 	if (!strcmp(id, "1151") ||
 	    !strcmp(id, "5663") ||
-	    !strcmp(id, "5688"))
+	    !strcmp(id, "5688") ||
+	    !strcmp(id, "917S"))
 		return &gt1x_chip_data;
 
 	if (!strcmp(id, "911") ||
@@ -1047,6 +1048,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.23.0


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

* Re: [PATCH 2/3] Input: goodix - use string-based chip ID
  2020-01-10 16:26 ` [PATCH 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
@ 2020-01-11  0:26   ` Dmitry Torokhov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2020-01-11  0:26 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Rob Herring, Mark Rutland, Bastien Nocera, Jagan Teki,
	linux-input, devicetree, linux-kernel

On Sat, Jan 11, 2020 at 12:26:07AM +0800, Icenowy Zheng wrote:
> 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>
> ---
>  drivers/input/touchscreen/goodix.c | 39 ++++++++++++++----------------
>  1 file changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index 0403102e807e..bfd067d7145e 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -48,7 +48,7 @@ struct goodix_ts_data {
>  	struct regulator *vddio;
>  	struct gpio_desc *gpiod_int;
>  	struct gpio_desc *gpiod_rst;
> -	u16 id;
> +	char id[5];
>  	u16 version;
>  	const char *cfg_name;
>  	struct completion firmware_loading_complete;
> @@ -235,28 +235,25 @@ 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:
> +	if (!strcmp(id, "1151") ||
> +	    !strcmp(id, "5663") ||
> +	    !strcmp(id, "5688"))
>  		return &gt1x_chip_data;
>  
> -	case 911:
> -	case 9271:
> -	case 9110:
> -	case 927:
> -	case 928:
> +	if (!strcmp(id, "911") ||
> +	    !strcmp(id, "9271") ||
> +	    !strcmp(id, "9110") ||
> +	    !strcmp(id, "927") ||
> +	    !strcmp(id, "928"))
>  		return &gt911_chip_data;
>  
> -	case 912:
> -	case 967:
> +	if (!strcmp(id, "912") ||
> +	    !strcmp(id, "967"))
>  		return &gt967_chip_data;
>  
> -	default:
> -		return &gt9x_chip_data;
> -	}
> +	return &gt9x_chip_data;

I wonder if with strings it would not be simpler to have a id -> pointer
mapping table and loop over it.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S
  2020-01-10 16:26 ` [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
@ 2020-01-15 15:25   ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2020-01-15 15:25 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Dmitry Torokhov, Mark Rutland, Bastien Nocera, Jagan Teki,
	linux-input, devicetree, linux-kernel

On Sat, Jan 11, 2020 at 12:26:06AM +0800, Icenowy Zheng wrote:
> 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>
> ---
>  Documentation/devicetree/bindings/input/touchscreen/goodix.txt | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> index fc03ea4cf5ab..c5447b136eb3 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> @@ -8,6 +8,7 @@ Required properties:
>  				 or "goodix,gt911"
>  				 or "goodix,gt9110"
>  				 or "goodix,gt912"
> +				 or "goodix,gt917s"

This binding is getting converted to schema, so you'll probably need to 
respin. In any case,

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

>  				 or "goodix,gt927"
>  				 or "goodix,gt9271"
>  				 or "goodix,gt928"
> -- 
> 2.23.0
> 

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

end of thread, other threads:[~2020-01-15 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 16:26 [PATCH 0/3] Add support for Goodix GT917S touch controller Icenowy Zheng
2020-01-10 16:26 ` [PATCH 1/3] dt-bindings: input: touchscreen: add compatible string for Goodix GT917S Icenowy Zheng
2020-01-15 15:25   ` Rob Herring
2020-01-10 16:26 ` [PATCH 2/3] Input: goodix - use string-based chip ID Icenowy Zheng
2020-01-11  0:26   ` Dmitry Torokhov
2020-01-10 16:26 ` [PATCH 3/3] Input: goodix - Add support for Goodix GT917S Icenowy Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.