From patchwork Thu Oct 5 15:35:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Budig X-Patchwork-Id: 9987471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A18A60291 for ; Thu, 5 Oct 2017 15:40:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C3542847D for ; Thu, 5 Oct 2017 15:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20EAE28C10; Thu, 5 Oct 2017 15:40:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 030272847D for ; Thu, 5 Oct 2017 15:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbdJEPkc (ORCPT ); Thu, 5 Oct 2017 11:40:32 -0400 Received: from smtprelay07.ispgateway.de ([134.119.228.103]:18345 "EHLO smtprelay07.ispgateway.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbdJEPka (ORCPT ); Thu, 5 Oct 2017 11:40:30 -0400 X-Greylist: delayed 306 seconds by postgrey-1.27 at vger.kernel.org; Thu, 05 Oct 2017 11:40:29 EDT Received: from [217.146.132.69] (helo=mezzanine.budig) by smtprelay07.ispgateway.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1e08BD-00064b-QE; Thu, 05 Oct 2017 17:35:19 +0200 Received: from simon by mezzanine.budig with local (Exim 4.89) (envelope-from ) id 1e08BD-0008Mw-H2; Thu, 05 Oct 2017 17:35:19 +0200 From: simon.budig@kernelconcepts.de To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, Simon Budig Subject: [PATCH 3/3] input: edt-ft5x06: implement support for the EDT-M12 series. Date: Thu, 5 Oct 2017 17:35:08 +0200 Message-Id: <20171005153508.32127-3-simon.budig@kernelconcepts.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171005153508.32127-1-simon.budig@kernelconcepts.de> References: <1507217501.7345.9.camel@kernelconcepts.de> <20171005153508.32127-1-simon.budig@kernelconcepts.de> X-Df-Sender: NDUxODk4 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Simon Budig This adds support for the EDT M12 series of touchscreens. Signed-off-by: Simon Budig --- drivers/input/touchscreen/edt-ft5x06.c | 48 +++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index d128445..8f5c2c0 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -72,6 +72,7 @@ enum edt_ver { EDT_M06, EDT_M09, + EDT_M12, GENERIC_FT, }; @@ -188,6 +189,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) break; case EDT_M09: + case EDT_M12: case GENERIC_FT: cmd = 0x0; offset = 3; @@ -211,7 +213,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) goto out; } - /* M09 does not send header or CRC */ + /* M09/M12 does not send header or CRC */ if (tsdata->version == EDT_M06) { if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || rdbuf[2] != datalen) { @@ -274,6 +276,7 @@ static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata, return edt_ft5x06_ts_readwrite(tsdata->client, 4, wrbuf, 0, NULL); case EDT_M09: + case EDT_M12: case GENERIC_FT: wrbuf[0] = addr; wrbuf[1] = value; @@ -313,6 +316,7 @@ static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, break; case EDT_M09: + case EDT_M12: case GENERIC_FT: wrbuf[0] = addr; error = edt_ft5x06_ts_readwrite(tsdata->client, 1, @@ -377,6 +381,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev, break; case EDT_M09: + case EDT_M12: case GENERIC_FT: addr = attr->addr_m09; break; @@ -447,6 +452,7 @@ static ssize_t edt_ft5x06_setting_store(struct device *dev, break; case EDT_M09: + case EDT_M12: case GENERIC_FT: addr = attr->addr_m09; break; @@ -472,14 +478,18 @@ static ssize_t edt_ft5x06_setting_store(struct device *dev, return error ?: count; } +/* m06, m09: range 0-31, m12: range 0-5 */ static EDT_ATTR(gain, S_IWUSR | S_IRUGO, WORK_REGISTER_GAIN, M09_REGISTER_GAIN, 0, 31); +/* m06, m09: range 0-31, m12: range 0-16 */ static EDT_ATTR(offset, S_IWUSR | S_IRUGO, WORK_REGISTER_OFFSET, M09_REGISTER_OFFSET, 0, 31); +/* m06: range 20 to 80, m09: range 0 to 30, m12: range 1 to 255... */ static EDT_ATTR(threshold, S_IWUSR | S_IRUGO, WORK_REGISTER_THRESHOLD, - M09_REGISTER_THRESHOLD, 0, 80); + M09_REGISTER_THRESHOLD, 0, 255); +/* m06: range 3 to 14, m12: (0x64: 100Hz) */ static EDT_ATTR(report_rate, S_IWUSR | S_IRUGO, WORK_REGISTER_REPORT_RATE, - NO_REGISTER, 3, 14); + NO_REGISTER, 0, 255); static struct attribute *edt_ft5x06_attrs[] = { &edt_ft5x06_attr_gain.dattr.attr, @@ -551,7 +561,7 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) return error; m09_out: - dev_err(&client->dev, "No factory mode support for M09/GENERIC_FT\n"); + dev_err(&client->dev, "No factory mode support for M09/M12/GENERIC_FT\n"); return -EINVAL; } @@ -776,13 +786,14 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, * to have garbage in there */ memset(rdbuf, 0, sizeof(rdbuf)); - error = edt_ft5x06_ts_readwrite(client, 1, "\xbb", + error = edt_ft5x06_ts_readwrite(client, 1, "\xBB", EDT_NAME_LEN - 1, rdbuf); if (error) return error; - /* if we find something consistent, stay with that assumption - * at least M09 won't send 3 bytes here + /* probe content for something consistent. + * M06 starts with a response byte, M12 gives the data directly. + * M09/Generic does not provide model number information. */ if (!(strncasecmp(rdbuf + 1, "EP0", 3))) { tsdata->version = EDT_M06; @@ -798,8 +809,22 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, *p++ = '\0'; strlcpy(model_name, rdbuf + 1, EDT_NAME_LEN); strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); + } else if (!(strncasecmp(rdbuf, "EP0", 3))) { + tsdata->version = EDT_M12; + + /* remove last '$' end marker */ + rdbuf[EDT_NAME_LEN - 2] = '\0'; + if (rdbuf[EDT_NAME_LEN - 3] == '$') + rdbuf[EDT_NAME_LEN - 3] = '\0'; + + /* look for Model/Version separator */ + p = strchr(rdbuf, '*'); + if (p) + *p++ = '\0'; + strlcpy(model_name, rdbuf, EDT_NAME_LEN); + strlcpy(fw_version, p ? p : "", EDT_NAME_LEN); } else { - /* if it is not an EDT M06 touchscreen then the model + /* if it is not an EDT M06/M12 touchscreen then the model * detection is a bit hairy. The different ft5x06 * firmares around don't reliably implement the * identification registers. Well. we'll take a shot. @@ -894,7 +919,8 @@ edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) tsdata->report_rate = edt_ft5x06_register_read(tsdata, reg_addr->reg_report_rate); if (tsdata->version == EDT_M06 || - tsdata->version == EDT_M09) { + tsdata->version == EDT_M09 || + tsdata->version == EDT_M12) { tsdata->num_x = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_x); tsdata->num_y = edt_ft5x06_register_read(tsdata, @@ -921,6 +947,7 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) break; case EDT_M09: + case EDT_M12: reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; reg_addr->reg_report_rate = NO_REGISTER; reg_addr->reg_gain = M09_REGISTER_GAIN; @@ -1029,7 +1056,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, input->dev.parent = &client->dev; if (tsdata->version == EDT_M06 || - tsdata->version == EDT_M09) { + tsdata->version == EDT_M09 || + tsdata->version == EDT_M12) { input_set_abs_params(input, ABS_MT_POSITION_X, 0, tsdata->num_x * 64 - 1, 0, 0); input_set_abs_params(input, ABS_MT_POSITION_Y,