mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Irina Tirdea <irina.tirdea@intel.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Bastien Nocera <hadess@hadess.net>,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Irina Tirdea <irina.tirdea@intel.com>,
	Octavian Purdila <octavian.purdila@intel.com>
Subject: [PATCH 3/9] input: goodix: export id and version read from device
Date: Thu, 28 May 2015 15:47:39 +0300	[thread overview]
Message-ID: <1432817265-23891-4-git-send-email-irina.tirdea@intel.com> (raw)
In-Reply-To: <1432817265-23891-1-git-send-email-irina.tirdea@intel.com>

Goodix touchscreens export through their registers a Product ID
and Firmware Version. The Product ID is an ASCII encoding of the
product name (e.g.: "911").

Export to sysfs (through the input subsystem) the product id and
firmware version read from the device rather than using constant
values.

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
 drivers/input/touchscreen/goodix.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index dac1b3c..9561396 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -47,7 +47,7 @@ struct goodix_ts_data {
 /* Register defines */
 #define GOODIX_READ_COOR_ADDR		0x814E
 #define GOODIX_REG_CONFIG_DATA		0x8047
-#define GOODIX_REG_VERSION		0x8140
+#define GOODIX_REG_ID			0x8140
 
 #define RESOLUTION_LOC		1
 #define MAX_CONTACTS_LOC	5
@@ -231,22 +231,27 @@ static void goodix_read_config(struct goodix_ts_data *ts)
  *
  * @client: the i2c client
  * @version: output buffer containing the version on success
+ * @id: output buffer containing the id on success
  */
-static int goodix_read_version(struct i2c_client *client, u16 *version)
+static int goodix_read_version(struct i2c_client *client, u16 *version, u16 *id)
 {
 	int error;
 	u8 buf[6];
+	char id_str[5];
 
-	error = goodix_i2c_read(client, GOODIX_REG_VERSION, buf, sizeof(buf));
+	error = goodix_i2c_read(client, GOODIX_REG_ID, buf, sizeof(buf));
 	if (error) {
 		dev_err(&client->dev, "read version failed: %d\n", error);
 		return error;
 	}
 
-	if (version)
-		*version = get_unaligned_le16(&buf[4]);
+	memcpy(id_str, buf, 4);
+	id_str[4] = 0;
+	if (kstrtou16(id_str, 10, id))
+		*id = 0x1001;
+	*version = get_unaligned_le16(&buf[4]);
 
-	dev_info(&client->dev, "IC VERSION: %6ph\n", buf);
+	dev_info(&client->dev, "ID %d, version: %04x\n", *id, *version);
 
 	return 0;
 }
@@ -280,10 +285,13 @@ static int goodix_i2c_test(struct i2c_client *client)
  * goodix_request_input_dev - Allocate, populate and register the input device
  *
  * @ts: our goodix_ts_data pointer
+ * @version: device firmware version
+ * @id: device ID
  *
  * Must be called during probe
  */
-static int goodix_request_input_dev(struct goodix_ts_data *ts)
+static int goodix_request_input_dev(struct goodix_ts_data *ts, u16 version,
+				    u16 id)
 {
 	int error;
 
@@ -311,8 +319,8 @@ static int goodix_request_input_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 = 0x1001;
-	ts->input_dev->id.version = 10427;
+	ts->input_dev->id.product = id;
+	ts->input_dev->id.version = version;
 
 	error = input_register_device(ts->input_dev);
 	if (error) {
@@ -330,7 +338,7 @@ static int goodix_ts_probe(struct i2c_client *client,
 	struct goodix_ts_data *ts;
 	unsigned long irq_flags;
 	int error;
-	u16 version_info;
+	u16 version_info, id_info;
 
 	dev_dbg(&client->dev, "I2C Address: 0x%02x\n", client->addr);
 
@@ -352,7 +360,7 @@ static int goodix_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
-	error = goodix_read_version(client, &version_info);
+	error = goodix_read_version(client, &version_info, &id_info);
 	if (error) {
 		dev_err(&client->dev, "Read version failed.\n");
 		return error;
@@ -360,7 +368,7 @@ static int goodix_ts_probe(struct i2c_client *client,
 
 	goodix_read_config(ts);
 
-	error = goodix_request_input_dev(ts);
+	error = goodix_request_input_dev(ts, version_info, id_info);
 	if (error)
 		return error;
 
-- 
1.9.1


  parent reply	other threads:[~2015-05-28 12:50 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28 12:47 [PATCH 0/9] Goodix touchscreen enhancements Irina Tirdea
2015-05-28 12:47 ` [PATCH 1/9] input: goodix: fix alignment issues Irina Tirdea
2015-06-04 12:48   ` Bastien Nocera
2015-06-05 16:49   ` Dmitry Torokhov
2015-06-05 17:07     ` Tirdea, Irina
2015-06-05 17:17     ` Joe Perches
2015-06-05 17:31       ` Dmitry Torokhov
2015-05-28 12:47 ` [PATCH 2/9] input: goodix: fix variable length array warning Irina Tirdea
2015-05-28 15:57   ` Antonio Ospite
2015-06-03 10:26     ` Tirdea, Irina
2015-06-03 20:49       ` Antonio Ospite
2015-06-05 16:34         ` Tirdea, Irina
2015-06-05 16:40           ` Dmitry Torokhov
2015-06-05 17:00             ` Tirdea, Irina
2015-06-05 17:11               ` Dmitry Torokhov
2015-06-05 17:34                 ` Tirdea, Irina
2015-05-28 12:47 ` Irina Tirdea [this message]
2015-05-28 12:47 ` [PATCH 4/9] input: goodix: add ACPI IDs for GT911 and GT9271 Irina Tirdea
2015-06-04 12:51   ` Bastien Nocera
2015-06-05 16:36     ` Tirdea, Irina
2015-06-05 16:41       ` Dmitry Torokhov
2015-06-05 17:01         ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 5/9] input: goodix: reset device at init Irina Tirdea
2015-05-28 13:19   ` Mark Rutland
2015-05-28 13:42     ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 6/9] input: goodix: write configuration data to device Irina Tirdea
2015-05-28 13:21   ` Mark Rutland
2015-05-28 13:51     ` Tirdea, Irina
2015-06-04 12:55       ` Bastien Nocera
2015-06-05 16:36         ` Tirdea, Irina
2015-06-05 16:43           ` Dmitry Torokhov
2015-06-05 17:05             ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 7/9] input: goodix: add power management support Irina Tirdea
2015-06-04 13:01   ` Bastien Nocera
2015-06-05 16:42     ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 8/9] input: goodix: add support for ESD Irina Tirdea
2015-05-28 13:23   ` Mark Rutland
2015-05-28 14:26     ` Tirdea, Irina
2015-06-04 12:57       ` Bastien Nocera
2015-06-05 16:37         ` Tirdea, Irina
2015-06-05 16:46           ` Dmitry Torokhov
2015-06-08 14:28             ` Tirdea, Irina
2015-07-30 12:06               ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 9/9] input: goodix: use goodix_i2c_write_u8 instead of i2c_master_send Irina Tirdea
2015-06-04 13:04 ` [PATCH 0/9] Goodix touchscreen enhancements Bastien Nocera
2015-06-05 16:36   ` Tirdea, Irina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432817265-23891-4-git-send-email-irina.tirdea@intel.com \
    --to=irina.tirdea@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hadess@hadess.net \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®