From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: David Heidelberg <david@ixit.cz>,
Dmitry Osipenko <digetx@gmail.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Henrik Rydberg <rydberg@bitmath.org>,
James Chen <james.chen@emc.com.tw>,
Johnny Chuang <johnny.chuang@emc.com.tw>,
Rob Herring <robh+dt@kernel.org>,
Scott Liu <scott.liu@emc.com.tw>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 06/10] input: elants: read touchscreen size for EKTF3624
Date: Sun, 26 Apr 2020 19:47:52 +0200 [thread overview]
Message-ID: <79b982b774afcddf6a8ded8c7987b2f83aeb7ec5.1587923061.git.mirq-linux@rere.qmqm.pl> (raw)
In-Reply-To: <cover.1587923061.git.mirq-linux@rere.qmqm.pl>
EKTF3624 as present in Asus TF300T tablet has touchscreen size encoded
in different registers.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/input/touchscreen/elants_i2c.c | 82 ++++++++++++++++++++++++--
1 file changed, 77 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 74ece2091c76..88294bc491e8 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -35,7 +35,7 @@
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/acpi.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <asm/unaligned.h>
@@ -43,6 +43,10 @@
/* Device, Driver information */
#define DEVICE_NAME "elants_i2c"
+/* Device IDs */
+#define EKTH3500 0
+#define EKTF3624 1
+
/* Convert from rows or columns into resolution */
#define ELAN_TS_RESOLUTION(n, m) (((n) - 1) * (m))
@@ -166,6 +170,7 @@ struct elants_data {
bool wake_irq_enabled;
bool keep_power_in_suspend;
+ u8 chip_id;
/* Must be last to be used for DMA operations */
u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned;
@@ -444,7 +449,58 @@ static int elants_i2c_query_bc_version(struct elants_data *ts)
return 0;
}
-static int elants_i2c_query_ts_info(struct elants_data *ts)
+static int elants_i2c_query_ts_info_ektf(struct elants_data *ts)
+{
+ struct i2c_client *client = ts->client;
+ int error;
+ u8 resp[4];
+ u16 phy_x, phy_y;
+ const u8 get_xres_cmd[] = {
+ CMD_HEADER_READ, E_INFO_X_RES, 0x00, 0x00
+ };
+ const u8 get_yres_cmd[] = {
+ CMD_HEADER_READ, E_INFO_Y_RES, 0x00, 0x00
+ };
+
+ /* Get X/Y size in mm */
+ error = elants_i2c_execute_command(client, get_xres_cmd,
+ sizeof(get_xres_cmd),
+ resp, sizeof(resp), 1,
+ "get X size");
+ if (error)
+ return error;
+
+ phy_x = resp[2] | ((resp[3] & 0xF0) << 4);
+
+ error = elants_i2c_execute_command(client, get_yres_cmd,
+ sizeof(get_yres_cmd),
+ resp, sizeof(resp), 1,
+ "get Y size");
+ if (error)
+ return error;
+
+ phy_y = resp[2] | ((resp[3] & 0xF0) << 4);
+
+ if (!phy_x || !phy_y) {
+ dev_warn(&client->dev,
+ "invalid size data: %d x %d mm\n",
+ phy_x, phy_y);
+ return 0;
+ }
+
+ dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y);
+
+ /* calculate resolution from size */
+ ts->x_max = 2240-1;
+ ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x);
+
+ ts->y_max = 1408-1;
+ ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y);
+
+ return 0;
+}
+
+static int elants_i2c_query_ts_info_ekth(struct elants_data *ts)
{
struct i2c_client *client = ts->client;
int error;
@@ -595,8 +651,20 @@ static int elants_i2c_initialize(struct elants_data *ts)
error = elants_i2c_query_fw_version(ts);
if (!error)
error = elants_i2c_query_test_version(ts);
- if (!error)
- error = elants_i2c_query_ts_info(ts);
+
+ switch (ts->chip_id) {
+ case EKTH3500:
+ if (!error)
+ error = elants_i2c_query_ts_info_ekth(ts);
+ break;
+ case EKTF3624:
+ if (!error)
+ error = elants_i2c_query_ts_info_ektf(ts);
+ break;
+ default:
+ unreachable();
+ break;
+ }
if (error)
ts->iap_mode = ELAN_IAP_RECOVERY;
@@ -1252,6 +1320,9 @@ static int elants_i2c_probe(struct i2c_client *client,
ts->client = client;
i2c_set_clientdata(client, ts);
+ if (client->dev.of_node)
+ ts->chip_id = (uintptr_t)of_device_get_match_data(&client->dev);
+
ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
if (IS_ERR(ts->vcc33)) {
error = PTR_ERR(ts->vcc33);
@@ -1480,7 +1551,8 @@ MODULE_DEVICE_TABLE(acpi, elants_acpi_id);
#ifdef CONFIG_OF
static const struct of_device_id elants_of_match[] = {
- { .compatible = "elan,ekth3500" },
+ { .compatible = "elan,ekth3500", .data = (void *)EKTH3500 },
+ { .compatible = "elan,ektf3624", .data = (void *)EKTF3624 },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, elants_of_match);
--
2.20.1
next prev parent reply other threads:[~2020-04-26 17:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-26 17:47 [PATCH v5 00/10] input: elants: Support Asus TF300T touchscreen Michał Mirosław
2020-04-26 17:47 ` [PATCH v5 02/10] input: elants: support old touch report format Michał Mirosław
2020-04-26 17:47 ` [PATCH v5 01/10] input: elants: document some registers and values Michał Mirosław
2020-05-18 4:07 ` Dmitry Torokhov
2020-05-18 9:18 ` Dmitry Osipenko
2020-04-26 17:47 ` [PATCH v5 03/10] input: elants: remove unused axes Michał Mirosław
2020-04-26 18:34 ` Dmitry Osipenko
2020-05-18 3:39 ` Dmitry Torokhov
2020-04-26 17:47 ` [PATCH v5 04/10] input: elants: override touchscreen info with DT properties Michał Mirosław
2020-05-18 4:02 ` Dmitry Torokhov
2020-04-26 17:47 ` [PATCH v5 05/10] input: elants: refactor elants_i2c_execute_command() Michał Mirosław
2020-05-14 19:43 ` Dmitry Osipenko
2020-05-18 4:03 ` Dmitry Torokhov
2020-04-26 17:47 ` Michał Mirosław [this message]
2020-04-26 17:47 ` [PATCH v5 07/10] input: elants: support 0x66 reply opcode for reporting touches Michał Mirosław
2020-05-18 4:05 ` Dmitry Torokhov
2020-05-18 9:10 ` Dmitry Osipenko
2020-04-26 17:47 ` [PATCH v5 08/10] dt-bindings: input: elants-i2c: Document common touchscreen properties Michał Mirosław
2020-04-26 17:47 ` [PATCH v5 09/10] dt-bindings: input: elants-i2c: Document eKTF3624 Michał Mirosław
2020-04-26 17:47 ` [PATCH v5 10/10] dt-bindings: input: touchscreen: elants_i2c: convert to YAML Michał Mirosław
2020-05-14 19:45 ` [PATCH v5 00/10] input: elants: Support Asus TF300T touchscreen Dmitry Osipenko
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=79b982b774afcddf6a8ded8c7987b2f83aeb7ec5.1587923061.git.mirq-linux@rere.qmqm.pl \
--to=mirq-linux@rere.qmqm.pl \
--cc=david@ixit.cz \
--cc=digetx@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=james.chen@emc.com.tw \
--cc=johnny.chuang@emc.com.tw \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=rydberg@bitmath.org \
--cc=scott.liu@emc.com.tw \
/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;
as well as URLs for NNTP newsgroup(s).