1 From patchwork Thu Oct 5 15:35:08 2017
2 Content-Type: text/plain; charset="utf-8"
4 Content-Transfer-Encoding: 7bit
5 Subject: [3/3] input: edt-ft5x06: implement support for the EDT-M12 series.
6 From: Simon Budig <simon.budig@kernelconcepts.de>
7 X-Patchwork-Id: 9987471
8 Message-Id: <20171005153508.32127-3-simon.budig@kernelconcepts.de>
9 To: linux-input@vger.kernel.org
10 Cc: dmitry.torokhov@gmail.com, Simon Budig <simon.budig@kernelconcepts.de>
11 Date: Thu, 5 Oct 2017 17:35:08 +0200
13 From: Simon Budig <simon.budig@kernelconcepts.de>
15 This adds support for the EDT M12 series of touchscreens.
17 Signed-off-by: Simon Budig <simon.budig@kernelconcepts.de>
19 drivers/input/touchscreen/edt-ft5x06.c | 48 +++++++++++++++++++++++++++-------
20 1 file changed, 38 insertions(+), 10 deletions(-)
22 diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
23 index d128445..8f5c2c0 100644
24 --- a/drivers/input/touchscreen/edt-ft5x06.c
25 +++ b/drivers/input/touchscreen/edt-ft5x06.c
34 @@ -188,6 +189,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
42 @@ -211,7 +213,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
46 - /* M09 does not send header or CRC */
47 + /* M09/M12 does not send header or CRC */
48 if (tsdata->version == EDT_M06) {
49 if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa ||
50 rdbuf[2] != datalen) {
51 @@ -274,6 +276,7 @@ static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata,
52 return edt_ft5x06_ts_readwrite(tsdata->client, 4,
59 @@ -313,6 +316,7 @@ static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata,
66 error = edt_ft5x06_ts_readwrite(tsdata->client, 1,
67 @@ -377,6 +381,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev,
73 addr = attr->addr_m09;
75 @@ -447,6 +452,7 @@ static ssize_t edt_ft5x06_setting_store(struct device *dev,
81 addr = attr->addr_m09;
83 @@ -472,14 +478,18 @@ static ssize_t edt_ft5x06_setting_store(struct device *dev,
84 return error ?: count;
87 +/* m06, m09: range 0-31, m12: range 0-5 */
88 static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN,
89 M09_REGISTER_GAIN, 0, 31);
90 +/* m06, m09: range 0-31, m12: range 0-16 */
91 static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET,
92 M09_REGISTER_OFFSET, 0, 31);
93 +/* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */
94 static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD,
95 - M09_REGISTER_THRESHOLD, 0, 80);
96 + M09_REGISTER_THRESHOLD, 0, 255);
97 +/* m06: range 3 to 14, m12: (0x64: 100Hz) */
98 static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE,
99 - NO_REGISTER, 3, 14);
100 + NO_REGISTER, 0, 255);
102 static struct attribute *edt_ft5x06_attrs[] = {
103 &edt_ft5x06_attr_gain.dattr.attr,
104 @@ -551,7 +561,7 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
108 - dev_err(&client->dev, "No factory mode support for M09/GENERIC_FT\n");
109 + dev_err(&client->dev, "No factory mode support for M09/M12/GENERIC_FT\n");
113 @@ -776,13 +786,14 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
114 * to have garbage in there
116 memset(rdbuf, 0, sizeof(rdbuf));
117 - error = edt_ft5x06_ts_readwrite(client, 1, "\xbb",
118 + error = edt_ft5x06_ts_readwrite(client, 1, "\xBB",
119 EDT_NAME_LEN - 1, rdbuf);
123 - /* if we find something consistent, stay with that assumption
124 - * at least M09 won't send 3 bytes here
125 + /* probe content for something consistent.
126 + * M06 starts with a response byte, M12 gives the data directly.
127 + * M09/Generic does not provide model number information.
129 if (!(strncasecmp(rdbuf + 1, "EP0", 3))) {
130 tsdata->version = EDT_M06;
131 @@ -798,8 +809,22 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
133 strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN);
134 strlcpy(fw_version, p ? p : "", EDT_NAME_LEN);
135 + } else if (!(strncasecmp(rdbuf, "EP0", 3))) {
136 + tsdata->version = EDT_M12;
138 + /* remove last '$' end marker */
139 + rdbuf[EDT_NAME_LEN - 2] = '\0';
140 + if (rdbuf[EDT_NAME_LEN - 3] == '$')
141 + rdbuf[EDT_NAME_LEN - 3] = '\0';
143 + /* look for Model/Version separator */
144 + p = strchr(rdbuf, '*');
147 + strlcpy(model_name, rdbuf, EDT_NAME_LEN);
148 + strlcpy(fw_version, p ? p : "", EDT_NAME_LEN);
150 - /* If it is not an EDT M06 touchscreen, then the model
151 + /* if it is not an EDT M06/M12 touchscreen then the model
152 * detection is a bit hairy. The different ft5x06
153 * firmares around don't reliably implement the
154 * identification registers. Well. we'll take a shot.
155 @@ -894,7 +919,8 @@ edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata)
156 tsdata->report_rate = edt_ft5x06_register_read(tsdata,
157 reg_addr->reg_report_rate);
158 if (tsdata->version == EDT_M06 ||
159 - tsdata->version == EDT_M09) {
160 + tsdata->version == EDT_M09 ||
161 + tsdata->version == EDT_M12) {
162 tsdata->num_x = edt_ft5x06_register_read(tsdata,
163 reg_addr->reg_num_x);
164 tsdata->num_y = edt_ft5x06_register_read(tsdata,
165 @@ -921,6 +947,7 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata)
170 reg_addr->reg_threshold = M09_REGISTER_THRESHOLD;
171 reg_addr->reg_report_rate = NO_REGISTER;
172 reg_addr->reg_gain = M09_REGISTER_GAIN;
173 @@ -1029,7 +1056,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
174 input->dev.parent = &client->dev;
176 if (tsdata->version == EDT_M06 ||
177 - tsdata->version == EDT_M09) {
178 + tsdata->version == EDT_M09 ||
179 + tsdata->version == EDT_M12) {
180 input_set_abs_params(input, ABS_MT_POSITION_X,
181 0, tsdata->num_x * 64 - 1, 0, 0);
182 input_set_abs_params(input, ABS_MT_POSITION_Y,