From patchwork Tue May 19 18:24:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 207810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B769BC433E0 for ; Tue, 19 May 2020 18:25:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6BAF204EF for ; Tue, 19 May 2020 18:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729276AbgESSZG (ORCPT ); Tue, 19 May 2020 14:25:06 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56190 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728948AbgESSZF (ORCPT ); Tue, 19 May 2020 14:25:05 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 24A5F2A2605 Received: by jupiter.universe (Postfix, from userid 1000) id 98BAD480101; Tue, 19 May 2020 20:25:01 +0200 (CEST) From: Sebastian Reichel To: Dmitry Torokhov , Ahmet Inan , Martin Fuzzey Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 2/5] Input: EXC3000: switch to i2c's probe_new API Date: Tue, 19 May 2020 20:24:44 +0200 Message-Id: <20200519182447.73405-3-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519182447.73405-1-sebastian.reichel@collabora.com> References: <20200519182447.73405-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Switch to the "new" I2C probe API. Signed-off-by: Sebastian Reichel --- drivers/input/touchscreen/exc3000.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c index e007e2e8f626..555a14305cd4 100644 --- a/drivers/input/touchscreen/exc3000.c +++ b/drivers/input/touchscreen/exc3000.c @@ -145,8 +145,7 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static int exc3000_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int exc3000_probe(struct i2c_client *client) { struct exc3000_data *data; struct input_dev *input; @@ -210,7 +209,7 @@ static struct i2c_driver exc3000_driver = { .of_match_table = of_match_ptr(exc3000_of_match), }, .id_table = exc3000_id, - .probe = exc3000_probe, + .probe_new = exc3000_probe, }; module_i2c_driver(exc3000_driver); From patchwork Tue May 19 18:24:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 207811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B681AC433E1 for ; Tue, 19 May 2020 18:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A64FF204EF for ; Tue, 19 May 2020 18:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbgESSZX (ORCPT ); Tue, 19 May 2020 14:25:23 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56214 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729053AbgESSZH (ORCPT ); Tue, 19 May 2020 14:25:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 2C8792A2606 Received: by jupiter.universe (Postfix, from userid 1000) id 97FC64800EB; Tue, 19 May 2020 20:25:01 +0200 (CEST) From: Sebastian Reichel To: Dmitry Torokhov , Ahmet Inan , Martin Fuzzey Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 3/5] Input: EXC3000: add EXC80H60 and EXC80H84 support Date: Tue, 19 May 2020 20:24:45 +0200 Message-Id: <20200519182447.73405-4-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519182447.73405-1-sebastian.reichel@collabora.com> References: <20200519182447.73405-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This adds support for EXC80H60 and EXCH84 controllers, which use a different event type id and have two extra bits for the resolution (so the maximum is 16K instead of 4K). Signed-off-by: Sebastian Reichel --- .../bindings/input/touchscreen/exc3000.yaml | 5 +- drivers/input/touchscreen/exc3000.c | 79 +++++++++++++++---- 2 files changed, 69 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml index 5d2e7496d6dd..d83b61e884df 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml @@ -14,7 +14,10 @@ allOf: properties: compatible: - const: eeti,exc3000 + enum: + - eeti,exc3000 + - eeti,exc80h60 + - eeti,exc80h84 reg: const: 0x2a interrupts: diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c index 555a14305cd4..9622cba514b3 100644 --- a/drivers/input/touchscreen/exc3000.c +++ b/drivers/input/touchscreen/exc3000.c @@ -23,11 +23,43 @@ #define EXC3000_SLOTS_PER_FRAME 5 #define EXC3000_LEN_FRAME 66 #define EXC3000_LEN_POINT 10 -#define EXC3000_MT_EVENT 6 + +#define EXC3000_MT1_EVENT 0x06 +#define EXC3000_MT2_EVENT 0x18 + #define EXC3000_TIMEOUT_MS 100 +static const struct i2c_device_id exc3000_id[]; + +struct eeti_dev_info { + const char *name; + int max_xy; +}; + +enum eeti_dev_id { + EETI_EXC3000, + EETI_EXC80H60, + EETI_EXC80H84, +}; + +static struct eeti_dev_info exc3000_info[] = { + [EETI_EXC3000] = { + .name = "EETI EXC3000 Touch Screen", + .max_xy = SZ_4K - 1, + }, + [EETI_EXC80H60] = { + .name = "EETI EXC80H60 Touch Screen", + .max_xy = SZ_16K - 1, + }, + [EETI_EXC80H84] = { + .name = "EETI EXC80H84 Touch Screen", + .max_xy = SZ_16K - 1, + }, +}; + struct exc3000_data { struct i2c_client *client; + const struct eeti_dev_info *info; struct input_dev *input; struct touchscreen_properties prop; struct timer_list timer; @@ -58,10 +90,15 @@ static void exc3000_timer(struct timer_list *t) input_sync(data->input); } -static int exc3000_read_frame(struct i2c_client *client, u8 *buf) +static int exc3000_read_frame(struct exc3000_data *data, u8 *buf) { + struct i2c_client *client = data->client; + u8 expected_event = EXC3000_MT1_EVENT; int ret; + if (data->info->max_xy == SZ_16K - 1) + expected_event = EXC3000_MT2_EVENT; + ret = i2c_master_send(client, "'", 2); if (ret < 0) return ret; @@ -76,19 +113,21 @@ static int exc3000_read_frame(struct i2c_client *client, u8 *buf) if (ret != EXC3000_LEN_FRAME) return -EIO; - if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME || - buf[2] != EXC3000_MT_EVENT) + if (get_unaligned_le16(buf) != EXC3000_LEN_FRAME) + return -EINVAL; + + if (buf[2] != expected_event) return -EINVAL; return 0; } -static int exc3000_read_data(struct i2c_client *client, +static int exc3000_read_data(struct exc3000_data *data, u8 *buf, int *n_slots) { int error; - error = exc3000_read_frame(client, buf); + error = exc3000_read_frame(data, buf); if (error) return error; @@ -98,7 +137,7 @@ static int exc3000_read_data(struct i2c_client *client, if (*n_slots > EXC3000_SLOTS_PER_FRAME) { /* Read 2nd frame to get the rest of the contacts. */ - error = exc3000_read_frame(client, buf + EXC3000_LEN_FRAME); + error = exc3000_read_frame(data, buf + EXC3000_LEN_FRAME); if (error) return error; @@ -118,7 +157,7 @@ static irqreturn_t exc3000_interrupt(int irq, void *dev_id) int slots, total_slots; int error; - error = exc3000_read_data(data->client, buf, &total_slots); + error = exc3000_read_data(data, buf, &total_slots); if (error) { /* Schedule a timer to release "stuck" contacts */ mod_timer(&data->timer, @@ -149,13 +188,19 @@ static int exc3000_probe(struct i2c_client *client) { struct exc3000_data *data; struct input_dev *input; - int error; + int error, max_xy; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->client = client; + data->info = device_get_match_data(&client->dev); + if (!data->info) { + enum eeti_dev_id eeti_dev_id = + i2c_match_id(exc3000_id, client)->driver_data; + data->info = &exc3000_info[eeti_dev_id]; + } timer_setup(&data->timer, exc3000_timer, 0); input = devm_input_allocate_device(&client->dev); @@ -164,11 +209,13 @@ static int exc3000_probe(struct i2c_client *client) data->input = input; - input->name = "EETI EXC3000 Touch Screen"; + input->name = data->info->name; input->id.bustype = BUS_I2C; - input_set_abs_params(input, ABS_MT_POSITION_X, 0, 4095, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, 4095, 0, 0); + max_xy = data->info->max_xy; + input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_xy, 0, 0); + touchscreen_parse_properties(input, true, &data->prop); error = input_mt_init_slots(input, EXC3000_NUM_SLOTS, @@ -190,14 +237,18 @@ static int exc3000_probe(struct i2c_client *client) } static const struct i2c_device_id exc3000_id[] = { - { "exc3000", 0 }, + { "exc3000", EETI_EXC3000 }, + { "exc80h60", EETI_EXC80H60 }, + { "exc80h84", EETI_EXC80H84 }, { } }; MODULE_DEVICE_TABLE(i2c, exc3000_id); #ifdef CONFIG_OF static const struct of_device_id exc3000_of_match[] = { - { .compatible = "eeti,exc3000" }, + { .compatible = "eeti,exc3000", .data = &exc3000_info[EETI_EXC3000] }, + { .compatible = "eeti,exc80h60", .data = &exc3000_info[EETI_EXC80H60] }, + { .compatible = "eeti,exc80h84", .data = &exc3000_info[EETI_EXC80H84] }, { } }; MODULE_DEVICE_TABLE(of, exc3000_of_match); From patchwork Tue May 19 18:24:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 207812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85B0FC433E2 for ; Tue, 19 May 2020 18:25:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 745462075F for ; Tue, 19 May 2020 18:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729512AbgESSZM (ORCPT ); Tue, 19 May 2020 14:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729488AbgESSZI (ORCPT ); Tue, 19 May 2020 14:25:08 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3728C08C5C1; Tue, 19 May 2020 11:25:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id E54B62A268F Received: by jupiter.universe (Postfix, from userid 1000) id A2E294800FF; Tue, 19 May 2020 20:25:01 +0200 (CEST) From: Sebastian Reichel To: Dmitry Torokhov , Ahmet Inan , Martin Fuzzey Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 5/5] Input: EXC3000: Add reset gpio support Date: Tue, 19 May 2020 20:24:47 +0200 Message-Id: <20200519182447.73405-6-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519182447.73405-1-sebastian.reichel@collabora.com> References: <20200519182447.73405-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add basic support for an optional reset gpio. Signed-off-by: Sebastian Reichel --- .../bindings/input/touchscreen/exc3000.yaml | 2 ++ drivers/input/touchscreen/exc3000.c | 29 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml index d83b61e884df..8b70b918c7ca 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/exc3000.yaml @@ -22,6 +22,8 @@ properties: const: 0x2a interrupts: maxItems: 1 + reset-gpios: + maxItems: 1 touchscreen-size-x: true touchscreen-size-y: true touchscreen-inverted-x: true diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c index 1ae758bbf627..9fed66ef1719 100644 --- a/drivers/input/touchscreen/exc3000.c +++ b/drivers/input/touchscreen/exc3000.c @@ -8,7 +8,9 @@ */ #include +#include #include +#include #include #include #include @@ -32,6 +34,9 @@ #define EXC3000_TIMEOUT_MS 100 +#define EXC3000_RESET_MS 10 +#define EXC3000_READY_MS 100 + static const struct i2c_device_id exc3000_id[]; struct eeti_dev_info { @@ -65,6 +70,7 @@ struct exc3000_data { const struct eeti_dev_info *info; struct input_dev *input; struct touchscreen_properties prop; + struct gpio_desc *reset; struct timer_list timer; u8 buf[2 * EXC3000_LEN_FRAME]; struct completion wait_event; @@ -305,16 +311,17 @@ static const struct attribute_group *exc3000_attribute_groups[] = { static int exc3000_probe(struct i2c_client *client) { + struct device *dev = &client->dev; struct exc3000_data *data; struct input_dev *input; int error, max_xy, retry; - data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->client = client; - data->info = device_get_match_data(&client->dev); + data->info = device_get_match_data(dev); if (!data->info) { enum eeti_dev_id eeti_dev_id = i2c_match_id(exc3000_id, client)->driver_data; @@ -324,7 +331,17 @@ static int exc3000_probe(struct i2c_client *client) init_completion(&data->wait_event); mutex_init(&data->query_lock); - input = devm_input_allocate_device(&client->dev); + data->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(data->reset)) + return PTR_ERR(data->reset); + + if (data->reset) { + msleep(EXC3000_RESET_MS); + gpiod_set_value_cansleep(data->reset, 0); + msleep(EXC3000_READY_MS); + } + + input = devm_input_allocate_device(dev); if (!input) return -ENOMEM; @@ -350,7 +367,7 @@ static int exc3000_probe(struct i2c_client *client) if (error) return error; - error = devm_request_threaded_irq(&client->dev, client->irq, + error = devm_request_threaded_irq(dev, client->irq, NULL, exc3000_interrupt, IRQF_ONESHOT, client->name, data); if (error) @@ -360,14 +377,14 @@ static int exc3000_probe(struct i2c_client *client) error = exc3000_get_model(data); if (!error) break; - dev_warn(&client->dev, "Retry %d get EETI EXC3000 model: %d\n", + dev_warn(dev, "Retry %d get EETI EXC3000 model: %d\n", retry + 1, error); } if (error) return error; - dev_dbg(&client->dev, "TS Model: %s", data->model); + dev_dbg(dev, "TS Model: %s", data->model); return 0; }