From patchwork Thu Dec 20 20:42:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3548617E1 for ; Thu, 20 Dec 2018 20:43:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2711B28B4A for ; Thu, 20 Dec 2018 20:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A38528C12; Thu, 20 Dec 2018 20:43:21 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 B23D628BA6 for ; Thu, 20 Dec 2018 20:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732856AbeLTUnU (ORCPT ); Thu, 20 Dec 2018 15:43:20 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:40896 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732671AbeLTUnT (ORCPT ); Thu, 20 Dec 2018 15:43:19 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNxx58w6z1qxQ4; Thu, 20 Dec 2018 21:43:17 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNxx4DYtz1qqkv; Thu, 20 Dec 2018 21:43:17 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id gHTFa8REQzZN; Thu, 20 Dec 2018 21:43:16 +0100 (CET) X-Auth-Info: bOmiUA2QJaumTl5agkZj8GLdQ4XTTQUFkRL9kTck6AQ= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:16 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH V2 01/10] input: touchscreen: ili210x: Add DT binding document Date: Thu, 20 Dec 2018 21:42:56 +0100 Message-Id: <20181220204305.28807-2-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Add DT binding document for the Ilitek ILI210x and ILI251x touchscreen controllers. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann Cc: Rob Herring Cc: devicetree@vger.kernel.org To: linux-input@vger.kernel.org --- V2: New patch --- .../bindings/input/ilitek,ili2xxx.txt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/ilitek,ili2xxx.txt diff --git a/Documentation/devicetree/bindings/input/ilitek,ili2xxx.txt b/Documentation/devicetree/bindings/input/ilitek,ili2xxx.txt new file mode 100644 index 000000000000..bc256557ae8c --- /dev/null +++ b/Documentation/devicetree/bindings/input/ilitek,ili2xxx.txt @@ -0,0 +1,25 @@ +Ilitek ILI210x/ILI251x touchscreen controller + +Required properties: +- compatible: + ilitek,ili210x for ILI210x + ilitek,ili251x for ILI251x + +- reg: The I2C address of the device + +- interrupts: The sink for the touchscreen's IRQ output + See ../interrupt-controller/interrupts.txt + +Optional properties for main touchpad device: + +- reset-gpios: GPIO specifier for the touchscreen's reset pin (active low) + +Example: + + touch@41 { + compatible = "ilitek,ili251x"; + reg = <0x41>; + interrupt-parent = <&gpio4>; + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; + reset-gpios = <&gpio5 21 GPIO_ACTIVE_LOW>; + }; From patchwork Thu Dec 20 20:42:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF72217E1 for ; Thu, 20 Dec 2018 20:43:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFDA528B4A for ; Thu, 20 Dec 2018 20:43:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D42DF28BE3; Thu, 20 Dec 2018 20:43:22 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 8686728BA6 for ; Thu, 20 Dec 2018 20:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732935AbeLTUnW (ORCPT ); Thu, 20 Dec 2018 15:43:22 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:59307 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730639AbeLTUnV (ORCPT ); Thu, 20 Dec 2018 15:43:21 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNxy66jbz1qxQQ; Thu, 20 Dec 2018 21:43:18 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNxy5Zj8z1qqkv; Thu, 20 Dec 2018 21:43:18 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id oQcuSWDDGnSi; Thu, 20 Dec 2018 21:43:17 +0100 (CET) X-Auth-Info: Y0rep0+WVx3r3rVnPRqCDN5EB53AGuGzRMWz0lTASnY= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:17 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 02/10] input: touchscreen: ili210x: Drop platform data support Date: Thu, 20 Dec 2018 21:42:57 +0100 Message-Id: <20181220204305.28807-3-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 There is not a single user of the ili210x platform data in the kernel, just drop it. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: No change --- drivers/input/touchscreen/ili210x.c | 12 ++---------- include/linux/input/ili210x.h | 11 ----------- 2 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 include/linux/input/ili210x.h diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 6f76eeedf465..25b0ca6c07d9 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -6,7 +6,6 @@ #include #include #include -#include #define MAX_TOUCHES 2 #define DEFAULT_POLL_PERIOD 20 @@ -184,7 +183,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct device *dev = &client->dev; - const struct ili210x_platform_data *pdata = dev_get_platdata(dev); struct ili210x *priv; struct input_dev *input; struct panel_info panel; @@ -194,11 +192,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver"); - if (!pdata) { - dev_err(dev, "No platform data!\n"); - return -EINVAL; - } - if (client->irq <= 0) { dev_err(dev, "No IRQ!\n"); return -EINVAL; @@ -233,8 +226,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, priv->client = client; priv->input = input; - priv->get_pendown_state = pdata->get_pendown_state; - priv->poll_period = pdata->poll_period ? : DEFAULT_POLL_PERIOD; + priv->poll_period = DEFAULT_POLL_PERIOD; INIT_DELAYED_WORK(&priv->dwork, ili210x_work); /* Setup input device */ @@ -258,7 +250,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, priv); - error = request_irq(client->irq, ili210x_irq, pdata->irq_flags, + error = request_irq(client->irq, ili210x_irq, 0, client->name, priv); if (error) { dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", diff --git a/include/linux/input/ili210x.h b/include/linux/input/ili210x.h deleted file mode 100644 index b76e7c1404cd..000000000000 --- a/include/linux/input/ili210x.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ILI210X_H -#define _ILI210X_H - -struct ili210x_platform_data { - unsigned long irq_flags; - unsigned int poll_period; - bool (*get_pendown_state)(void); -}; - -#endif From patchwork Thu Dec 20 20:42:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B77BF1399 for ; Thu, 20 Dec 2018 20:43:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9AA128B4A for ; Thu, 20 Dec 2018 20:43:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DD2128C04; Thu, 20 Dec 2018 20:43:22 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 5840728B4A for ; Thu, 20 Dec 2018 20:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732934AbeLTUnV (ORCPT ); Thu, 20 Dec 2018 15:43:21 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:56691 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732671AbeLTUnV (ORCPT ); Thu, 20 Dec 2018 15:43:21 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNxz6ZXvz1qxQC; Thu, 20 Dec 2018 21:43:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNxz6PmTz1qqlD; Thu, 20 Dec 2018 21:43:19 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id rhds-adaAY9a; Thu, 20 Dec 2018 21:43:18 +0100 (CET) X-Auth-Info: ei98gIIPK9UctzCxf4xiPPkyTrA5lFhetoyv+irBYxo= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:18 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 03/10] input: touchscreen: ili210x: Drop get_pendown_state Date: Thu, 20 Dec 2018 21:42:58 +0100 Message-Id: <20181220204305.28807-4-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 The .get_pendown_state callback is set only by the platform data code, which was just removed. Thus, get_pendown_state() always returns false, so drop that altogether. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: New patch --- drivers/input/touchscreen/ili210x.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 25b0ca6c07d9..11007bf8113c 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -43,7 +43,6 @@ struct firmware_version { struct ili210x { struct i2c_client *client; struct input_dev *input; - bool (*get_pendown_state)(void); unsigned int poll_period; struct delayed_work dwork; }; @@ -102,16 +101,6 @@ static void ili210x_report_events(struct input_dev *input, input_sync(input); } -static bool get_pendown_state(const struct ili210x *priv) -{ - bool state = false; - - if (priv->get_pendown_state) - state = priv->get_pendown_state(); - - return state; -} - static void ili210x_work(struct work_struct *work) { struct ili210x *priv = container_of(work, struct ili210x, @@ -130,7 +119,7 @@ static void ili210x_work(struct work_struct *work) ili210x_report_events(priv->input, &touchdata); - if ((touchdata.status & 0xf3) || get_pendown_state(priv)) + if (touchdata.status & 0xf3) schedule_delayed_work(&priv->dwork, msecs_to_jiffies(priv->poll_period)); } From patchwork Thu Dec 20 20:42:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12D89924 for ; Thu, 20 Dec 2018 20:43:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04A0328B4A for ; Thu, 20 Dec 2018 20:43:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECF9828BE3; Thu, 20 Dec 2018 20:43:23 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 9B60E28B4A for ; Thu, 20 Dec 2018 20:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732936AbeLTUnX (ORCPT ); Thu, 20 Dec 2018 15:43:23 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:44370 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732917AbeLTUnX (ORCPT ); Thu, 20 Dec 2018 15:43:23 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy10BHdz1qtPb; Thu, 20 Dec 2018 21:43:21 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy06l6Zz1qqlD; Thu, 20 Dec 2018 21:43:20 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id DPloESKw0pBi; Thu, 20 Dec 2018 21:43:20 +0100 (CET) X-Auth-Info: Cs44AkeFTyVkpF7RcA3BrcKjy860q1f5KIFp54Wvj+E= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:19 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 04/10] input: touchscreen: ili210x: Convert to devm_ functions Date: Thu, 20 Dec 2018 21:42:59 +0100 Message-Id: <20181220204305.28807-5-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Convert the driver to dev-managed allocations. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: No change --- drivers/input/touchscreen/ili210x.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 11007bf8113c..322241472b9f 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -206,12 +206,10 @@ static int ili210x_i2c_probe(struct i2c_client *client, xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8); ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8); - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - input = input_allocate_device(); - if (!priv || !input) { - error = -ENOMEM; - goto err_free_mem; - } + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + input = devm_input_allocate_device(dev); + if (!priv || !input) + return -ENOMEM; priv->client = client; priv->input = input; @@ -273,8 +271,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, err_free_irq: free_irq(client->irq, priv); err_free_mem: - input_free_device(input); - kfree(priv); return error; } @@ -286,7 +282,6 @@ static int ili210x_i2c_remove(struct i2c_client *client) free_irq(priv->client->irq, priv); cancel_delayed_work_sync(&priv->dwork); input_unregister_device(priv->input); - kfree(priv); return 0; } From patchwork Thu Dec 20 20:43:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A516924 for ; Thu, 20 Dec 2018 20:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BB9028BE3 for ; Thu, 20 Dec 2018 20:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F394F28C0F; Thu, 20 Dec 2018 20:43:24 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 A9E7C28BE3 for ; Thu, 20 Dec 2018 20:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732995AbeLTUnY (ORCPT ); Thu, 20 Dec 2018 15:43:24 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:54246 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730639AbeLTUnX (ORCPT ); Thu, 20 Dec 2018 15:43:23 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy20l4jz1rYjf; Thu, 20 Dec 2018 21:43:22 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy20Wdhz1qqlD; Thu, 20 Dec 2018 21:43:22 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id P__C_WOGS2f2; Thu, 20 Dec 2018 21:43:21 +0100 (CET) X-Auth-Info: +AiDQnhxG1kOneQL7Xv6oj29alvqKRdPCVAFnRVWjC0= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:21 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 05/10] input: touchscreen: ili210x: Convert to threaded IRQ Date: Thu, 20 Dec 2018 21:43:00 +0100 Message-Id: <20181220204305.28807-6-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Get rid of the workqueue, just spawn a threaded IRQ and handle all the touchscreen readouts in the handler thread. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: Retain workqueue --- drivers/input/touchscreen/ili210x.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 322241472b9f..04d75d4ecb20 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -5,7 +5,6 @@ #include #include #include -#include #define MAX_TOUCHES 2 #define DEFAULT_POLL_PERIOD 20 @@ -237,19 +236,19 @@ static int ili210x_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, priv); - error = request_irq(client->irq, ili210x_irq, 0, - client->name, priv); + error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq, + IRQF_ONESHOT, client->name, priv); if (error) { dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n", error); - goto err_free_mem; + return error; } error = sysfs_create_group(&dev->kobj, &ili210x_attr_group); if (error) { dev_err(dev, "Unable to create sysfs attributes, err: %d\n", error); - goto err_free_irq; + return error; } error = input_register_device(priv->input); @@ -268,9 +267,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, err_remove_sysfs: sysfs_remove_group(&dev->kobj, &ili210x_attr_group); -err_free_irq: - free_irq(client->irq, priv); -err_free_mem: return error; } @@ -279,7 +275,6 @@ static int ili210x_i2c_remove(struct i2c_client *client) struct ili210x *priv = i2c_get_clientdata(client); sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group); - free_irq(priv->client->irq, priv); cancel_delayed_work_sync(&priv->dwork); input_unregister_device(priv->input); From patchwork Thu Dec 20 20:43:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 406121399 for ; Thu, 20 Dec 2018 20:43:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31AE828C0F for ; Thu, 20 Dec 2018 20:43:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2599328C15; Thu, 20 Dec 2018 20:43:28 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 BF46228C0F for ; Thu, 20 Dec 2018 20:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732933AbeLTUn0 (ORCPT ); Thu, 20 Dec 2018 15:43:26 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:37586 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732917AbeLTUn0 (ORCPT ); Thu, 20 Dec 2018 15:43:26 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy31Zlmz1qxQ4; Thu, 20 Dec 2018 21:43:23 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy31Nv2z1qqlD; Thu, 20 Dec 2018 21:43:23 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 5CP9zqYJVWsh; Thu, 20 Dec 2018 21:43:22 +0100 (CET) X-Auth-Info: dDUanls4eKj/TSmxhzxwVYttzOSdpVJ4trgu097Eb8A= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:22 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 06/10] input: touchscreen: ili210x: Add reset GPIO support Date: Thu, 20 Dec 2018 21:43:01 +0100 Message-Id: <20181220204305.28807-7-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 The touchscreen can have a reset GPIO connected to it, add support for such an arrangement. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: No change --- drivers/input/touchscreen/ili210x.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 04d75d4ecb20..a84ca555829e 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -5,6 +5,7 @@ #include #include #include +#include #define MAX_TOUCHES 2 #define DEFAULT_POLL_PERIOD 20 @@ -44,6 +45,7 @@ struct ili210x { struct input_dev *input; unsigned int poll_period; struct delayed_work dwork; + struct gpio_desc *reset_gpio; }; static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, @@ -172,6 +174,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, { struct device *dev = &client->dev; struct ili210x *priv; + struct gpio_desc *reset_gpio; struct input_dev *input; struct panel_info panel; struct firmware_version firmware; @@ -185,6 +188,17 @@ static int ili210x_i2c_probe(struct i2c_client *client, return -EINVAL; } + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpio)) + return PTR_ERR(reset_gpio); + + if (reset_gpio) { + gpiod_set_value_cansleep(reset_gpio, 1); + usleep_range(50, 100); + gpiod_set_value_cansleep(reset_gpio, 0); + mdelay(100); + } + /* Get firmware version */ error = ili210x_read_reg(client, REG_FIRMWARE_VERSION, &firmware, sizeof(firmware)); @@ -214,6 +228,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, priv->input = input; priv->poll_period = DEFAULT_POLL_PERIOD; INIT_DELAYED_WORK(&priv->dwork, ili210x_work); + priv->reset_gpio = reset_gpio; /* Setup input device */ input->name = "ILI210x Touchscreen"; @@ -277,6 +292,8 @@ static int ili210x_i2c_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ili210x_attr_group); cancel_delayed_work_sync(&priv->dwork); input_unregister_device(priv->input); + if (priv->reset_gpio) + gpiod_set_value_cansleep(priv->reset_gpio, 1); return 0; } From patchwork Thu Dec 20 20:43:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E58D1850 for ; Thu, 20 Dec 2018 20:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E41028C0F for ; Thu, 20 Dec 2018 20:43:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 127D628C15; Thu, 20 Dec 2018 20:43:30 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 B389C28C12 for ; Thu, 20 Dec 2018 20:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732686AbeLTUn1 (ORCPT ); Thu, 20 Dec 2018 15:43:27 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:44498 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733182AbeLTUn1 (ORCPT ); Thu, 20 Dec 2018 15:43:27 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy430FNz1qxQC; Thu, 20 Dec 2018 21:43:24 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy42qz2z1qqlD; Thu, 20 Dec 2018 21:43:24 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id jDQ0SsyPYC4u; Thu, 20 Dec 2018 21:43:23 +0100 (CET) X-Auth-Info: mGR8i68FdxyVe7eEHbUZfVIasPjpBiQTJvLxEWUmiYw= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:23 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 07/10] input: touchscreen: ili210x: Rework the touchscreen sample processing Date: Thu, 20 Dec 2018 21:43:02 +0100 Message-Id: <20181220204305.28807-8-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Get rid of the packed structures for representing data as that does not apply to other similar Ilitek touchscreens. Instead, implement a function which parses the data and reports touch events and coordinates. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: Replace touchdata.status with touchdata[0] and move it into ili210x_report_events() in anticipation of ILI251x specific changes, and to to synchronize the patch with changes in "input: touchscreen: ili210x: Convert to devm_ functions" --- drivers/input/touchscreen/ili210x.c | 59 +++++++++++++++++------------ 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index a84ca555829e..ab0e6c9a614c 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -16,20 +16,11 @@ #define REG_FIRMWARE_VERSION 0x40 #define REG_CALIBRATE 0xcc -struct finger { +struct panel_info { u8 x_low; u8 x_high; u8 y_low; u8 y_high; -} __packed; - -struct touchdata { - u8 status; - struct finger finger[MAX_TOUCHES]; -} __packed; - -struct panel_info { - struct finger finger_max; u8 xchannel_num; u8 ychannel_num; } __packed; @@ -74,25 +65,40 @@ static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, return 0; } -static void ili210x_report_events(struct input_dev *input, - const struct touchdata *touchdata) +static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, + unsigned int finger, + unsigned int *x, unsigned int *y) +{ + u8 x_low, x_high, y_low, y_high; + + if (finger >= MAX_TOUCHES) + return false; + + if (touchdata[0] & BIT(finger)) + return false; + + x_high = touchdata[1 + (finger * 4) + 0]; + x_low = touchdata[1 + (finger * 4) + 1]; + y_high = touchdata[1 + (finger * 4) + 2]; + y_low = touchdata[1 + (finger * 4) + 3]; + *x = x_low | (x_high << 8); + *y = y_low | (y_high << 8); + + return true; +} + +static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) { int i; bool touch; unsigned int x, y; - const struct finger *finger; for (i = 0; i < MAX_TOUCHES; i++) { input_mt_slot(input, i); - finger = &touchdata->finger[i]; - - touch = touchdata->status & (1 << i); + touch = ili210x_touchdata_to_coords(priv, touchdata, i, &x, &y); input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); if (touch) { - x = finger->x_low | (finger->x_high << 8); - y = finger->y_low | (finger->y_high << 8); - input_report_abs(input, ABS_MT_POSITION_X, x); input_report_abs(input, ABS_MT_POSITION_Y, y); } @@ -100,6 +106,8 @@ static void ili210x_report_events(struct input_dev *input, input_mt_report_pointer_emulation(input, false); input_sync(input); + + return touchdata[0] & 0xf3; } static void ili210x_work(struct work_struct *work) @@ -107,20 +115,21 @@ static void ili210x_work(struct work_struct *work) struct ili210x *priv = container_of(work, struct ili210x, dwork.work); struct i2c_client *client = priv->client; - struct touchdata touchdata; + u8 touchdata[1 + 4 * MAX_TOUCHES]; + bool touch; int error; error = ili210x_read_reg(client, REG_TOUCHDATA, - &touchdata, sizeof(touchdata)); + touchdata, sizeof(touchdata)); if (error) { dev_err(&client->dev, "Unable to get touchdata, err = %d\n", error); return; } - ili210x_report_events(priv->input, &touchdata); + touch = ili210x_report_events(priv, touchdata); - if (touchdata.status & 0xf3) + if (touch) schedule_delayed_work(&priv->dwork, msecs_to_jiffies(priv->poll_period)); } @@ -216,8 +225,8 @@ static int ili210x_i2c_probe(struct i2c_client *client, return error; } - xmax = panel.finger_max.x_low | (panel.finger_max.x_high << 8); - ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8); + xmax = panel.x_low | (panel.x_high << 8); + ymax = panel.y_low | (panel.y_high << 8); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); input = devm_input_allocate_device(dev); From patchwork Thu Dec 20 20:43:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92E2F1399 for ; Thu, 20 Dec 2018 20:43:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 816CE28C0F for ; Thu, 20 Dec 2018 20:43:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7341C28C15; Thu, 20 Dec 2018 20:43:29 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 255AC28C0F for ; Thu, 20 Dec 2018 20:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732779AbeLTUn2 (ORCPT ); Thu, 20 Dec 2018 15:43:28 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:48812 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732671AbeLTUn1 (ORCPT ); Thu, 20 Dec 2018 15:43:27 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy54ZDfz1qwdT; Thu, 20 Dec 2018 21:43:25 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy542Jyz1qqkv; Thu, 20 Dec 2018 21:43:25 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id va_oCqKKjH5t; Thu, 20 Dec 2018 21:43:24 +0100 (CET) X-Auth-Info: MSRHw0jjwVY74ji3v2MogRTikVEPPU1wtsEy0Zqy0Jw= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:24 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 08/10] input: touchscreen: ili210x: Reorder probe Date: Thu, 20 Dec 2018 21:43:03 +0100 Message-Id: <20181220204305.28807-9-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Perform the register access only after the I2C client data are set, this is only done in preparation for the subsequent patch which uses the I2C client data in the register IO function. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: No change --- drivers/input/touchscreen/ili210x.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index ab0e6c9a614c..b6143f7c2477 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -208,6 +208,19 @@ static int ili210x_i2c_probe(struct i2c_client *client, mdelay(100); } + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + input = devm_input_allocate_device(dev); + if (!priv || !input) + return -ENOMEM; + + priv->client = client; + priv->input = input; + priv->poll_period = DEFAULT_POLL_PERIOD; + INIT_DELAYED_WORK(&priv->dwork, ili210x_work); + priv->reset_gpio = reset_gpio; + + i2c_set_clientdata(client, priv); + /* Get firmware version */ error = ili210x_read_reg(client, REG_FIRMWARE_VERSION, &firmware, sizeof(firmware)); @@ -228,17 +241,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, xmax = panel.x_low | (panel.x_high << 8); ymax = panel.y_low | (panel.y_high << 8); - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - input = devm_input_allocate_device(dev); - if (!priv || !input) - return -ENOMEM; - - priv->client = client; - priv->input = input; - priv->poll_period = DEFAULT_POLL_PERIOD; - INIT_DELAYED_WORK(&priv->dwork, ili210x_work); - priv->reset_gpio = reset_gpio; - /* Setup input device */ input->name = "ILI210x Touchscreen"; input->id.bustype = BUS_I2C; @@ -258,8 +260,6 @@ static int ili210x_i2c_probe(struct i2c_client *client, input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0); input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0); - i2c_set_clientdata(client, priv); - error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq, IRQF_ONESHOT, client->name, priv); if (error) { From patchwork Thu Dec 20 20:43:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E2E2924 for ; Thu, 20 Dec 2018 20:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00E1D28C3A for ; Thu, 20 Dec 2018 20:43:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E979728C15; Thu, 20 Dec 2018 20:43:29 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 87EF928C3A for ; Thu, 20 Dec 2018 20:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732984AbeLTUn2 (ORCPT ); Thu, 20 Dec 2018 15:43:28 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:50428 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732917AbeLTUn2 (ORCPT ); Thu, 20 Dec 2018 15:43:28 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy64zxWz1qwfC; Thu, 20 Dec 2018 21:43:26 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy64Xzhz1qqkv; Thu, 20 Dec 2018 21:43:26 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id bo-JJ4eQEnVx; Thu, 20 Dec 2018 21:43:25 +0100 (CET) X-Auth-Info: YEDF+5h8oimoe8MqfvH19vu1aj9wNal6SNhoPDiZGqs= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:25 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 09/10] input: touchscreen: ili210x: Add OF match table Date: Thu, 20 Dec 2018 21:43:04 +0100 Message-Id: <20181220204305.28807-10-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Add OF match table for the ili210x touchscreen. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: No change --- drivers/input/touchscreen/ili210x.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index b6143f7c2477..bb77d37aaaba 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -336,10 +336,17 @@ static const struct i2c_device_id ili210x_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, ili210x_i2c_id); +static const struct of_device_id ili210x_dt_ids[] = { + { .compatible = "ilitek,ili210x", }, + { }, +}; +MODULE_DEVICE_TABLE(of, ili210x_dt_ids); + static struct i2c_driver ili210x_ts_driver = { .driver = { .name = "ili210x_i2c", .pm = &ili210x_i2c_pm, + .of_match_table = ili210x_dt_ids, }, .id_table = ili210x_i2c_id, .probe = ili210x_i2c_probe, From patchwork Thu Dec 20 20:43:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10739595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0E61924 for ; Thu, 20 Dec 2018 20:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D232528C0F for ; Thu, 20 Dec 2018 20:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C677A28C15; Thu, 20 Dec 2018 20:43:32 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 5DA4C28C0F for ; Thu, 20 Dec 2018 20:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733050AbeLTUnb (ORCPT ); Thu, 20 Dec 2018 15:43:31 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:34622 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732671AbeLTUnb (ORCPT ); Thu, 20 Dec 2018 15:43:31 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43LNy809wjz1qwdT; Thu, 20 Dec 2018 21:43:28 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43LNy774snz1qqkv; Thu, 20 Dec 2018 21:43:27 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Ohup2SNJh9aa; Thu, 20 Dec 2018 21:43:26 +0100 (CET) X-Auth-Info: wPMqu8GT0MA6cNDDWLGfPxhj9jmDCRYjsa0N+kdMqyk= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 Dec 2018 21:43:26 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V2 10/10] input: touchscreen: ili210x: Add ILI251X support Date: Thu, 20 Dec 2018 21:43:05 +0100 Message-Id: <20181220204305.28807-11-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181220204305.28807-1-marex@denx.de> References: <20181220204305.28807-1-marex@denx.de> MIME-Version: 1.0 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 Add support for ILI251x touch controller. This controller is similar to the ILI210x, except for the following differences: - Does not support I2C R-W transfer, Read must be followed by an obscenely long delay, and then followed by Write - Does support 10 simultaneous touch inputs. - Touch data format is slightly different, pressure reporting does not work although the touch data contain such information. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: - Implement delayed work for ILI251x - Fix operation with >6 fingers in ili210x_work --- drivers/input/touchscreen/ili210x.c | 128 ++++++++++++++++++++++++---- 1 file changed, 113 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index bb77d37aaaba..5099653dfb88 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -6,8 +6,10 @@ #include #include #include +#include -#define MAX_TOUCHES 2 +#define ILI210X_TOUCHES 2 +#define ILI251X_TOUCHES 10 #define DEFAULT_POLL_PERIOD 20 /* Touchscreen commands */ @@ -31,17 +33,25 @@ struct firmware_version { u8 minor; } __packed; +enum ili2xxx_model { + MODEL_ILI210X, + MODEL_ILI251X, +}; + struct ili210x { struct i2c_client *client; struct input_dev *input; unsigned int poll_period; struct delayed_work dwork; struct gpio_desc *reset_gpio; + enum ili2xxx_model model; + unsigned int max_touches; }; static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, size_t len) { + struct ili210x *priv = i2c_get_clientdata(client); struct i2c_msg msg[2] = { { .addr = client->addr, @@ -57,7 +67,38 @@ static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, } }; - if (i2c_transfer(client->adapter, msg, 2) != 2) { + if (priv->model == MODEL_ILI251X) { + if (i2c_transfer(client->adapter, msg, 1) != 1) { + dev_err(&client->dev, "i2c transfer failed\n"); + return -EIO; + } + + mdelay(5); + + if (i2c_transfer(client->adapter, msg + 1, 1) != 1) { + dev_err(&client->dev, "i2c transfer failed\n"); + return -EIO; + } + } else { + if (i2c_transfer(client->adapter, msg, 2) != 2) { + dev_err(&client->dev, "i2c transfer failed\n"); + return -EIO; + } + } + + return 0; +} + +static int ili210x_read(struct i2c_client *client, void *buf, size_t len) +{ + struct i2c_msg msg = { + .addr = client->addr, + .flags = I2C_M_RD, + .len = len, + .buf = buf, + }; + + if (i2c_transfer(client->adapter, &msg, 1) != 1) { dev_err(&client->dev, "i2c transfer failed\n"); return -EIO; } @@ -71,7 +112,7 @@ static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, { u8 x_low, x_high, y_low, y_high; - if (finger >= MAX_TOUCHES) + if (finger >= ILI210X_TOUCHES) return false; if (touchdata[0] & BIT(finger)) @@ -87,16 +128,50 @@ static bool ili210x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, return true; } +static bool ili251x_touchdata_to_coords(struct ili210x *priv, u8 *touchdata, + unsigned int finger, + unsigned int *x, unsigned int *y) +{ + u8 x_low, x_high, y_low, y_high; + + if (finger >= ILI251X_TOUCHES) + return false; + + x_high = touchdata[1 + (finger * 5) + 0]; + if (!(x_high & BIT(7))) /* Touch indication */ + return false; + + x_high &= 0x3f; + x_low = touchdata[1 + (finger * 5) + 1]; + y_high = touchdata[1 + (finger * 5) + 2]; + y_low = touchdata[1 + (finger * 5) + 3]; + + *x = x_low | (x_high << 8); + *y = y_low | (y_high << 8); + + return true; +} + static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) { + struct input_dev *input = priv->input; int i; - bool touch; - unsigned int x, y; + bool contact = false, touch = false; + unsigned int x = 0, y = 0; - for (i = 0; i < MAX_TOUCHES; i++) { + for (i = 0; i < priv->max_touches; i++) { input_mt_slot(input, i); - touch = ili210x_touchdata_to_coords(priv, touchdata, i, &x, &y); + if (priv->model == MODEL_ILI210X) { + touch = ili210x_touchdata_to_coords(priv, touchdata, + i, &x, &y); + } else if (priv->model == MODEL_ILI251X) { + touch = ili251x_touchdata_to_coords(priv, touchdata, + i, &x, &y); + if (touch) + contact = true; + } + input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); if (touch) { input_report_abs(input, ABS_MT_POSITION_X, x); @@ -107,7 +182,10 @@ static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) input_mt_report_pointer_emulation(input, false); input_sync(input); - return touchdata[0] & 0xf3; + if (priv->model == MODEL_ILI210X) + contact = touchdata[0] & 0xf3; + + return contact; } static void ili210x_work(struct work_struct *work) @@ -115,12 +193,20 @@ static void ili210x_work(struct work_struct *work) struct ili210x *priv = container_of(work, struct ili210x, dwork.work); struct i2c_client *client = priv->client; - u8 touchdata[1 + 4 * MAX_TOUCHES]; + u8 touchdata[64] = { 0 }; bool touch; - int error; + int error = -EINVAL; + + if (priv->model == MODEL_ILI210X) { + error = ili210x_read_reg(client, REG_TOUCHDATA, + touchdata, sizeof(touchdata)); + } else if (priv->model == MODEL_ILI251X) { + error = ili210x_read_reg(client, REG_TOUCHDATA, + touchdata, 31); + if (!error && touchdata[0] == 2) + error = ili210x_read(client, &touchdata[31], 20); + } - error = ili210x_read_reg(client, REG_TOUCHDATA, - touchdata, sizeof(touchdata)); if (error) { dev_err(&client->dev, "Unable to get touchdata, err = %d\n", error); @@ -178,6 +264,8 @@ static const struct attribute_group ili210x_attr_group = { .attrs = ili210x_attributes, }; +static const struct i2c_device_id ili210x_i2c_id[]; + static int ili210x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -187,9 +275,12 @@ static int ili210x_i2c_probe(struct i2c_client *client, struct input_dev *input; struct panel_info panel; struct firmware_version firmware; + enum ili2xxx_model model; int xmax, ymax; int error; + model = (enum ili2xxx_model)id->driver_data; + dev_dbg(dev, "Probing for ILI210X I2C Touschreen driver"); if (client->irq <= 0) { @@ -218,6 +309,11 @@ static int ili210x_i2c_probe(struct i2c_client *client, priv->poll_period = DEFAULT_POLL_PERIOD; INIT_DELAYED_WORK(&priv->dwork, ili210x_work); priv->reset_gpio = reset_gpio; + priv->model = model; + if (model == MODEL_ILI210X) + priv->max_touches = ILI210X_TOUCHES; + if (model == MODEL_ILI251X) + priv->max_touches = ILI251X_TOUCHES; i2c_set_clientdata(client, priv); @@ -256,7 +352,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, input_set_abs_params(input, ABS_Y, 0, ymax, 0, 0); /* Multi touch */ - input_mt_init_slots(input, MAX_TOUCHES, 0); + input_mt_init_slots(input, priv->max_touches, 0); input_set_abs_params(input, ABS_MT_POSITION_X, 0, xmax, 0, 0); input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ymax, 0, 0); @@ -331,13 +427,15 @@ static SIMPLE_DEV_PM_OPS(ili210x_i2c_pm, ili210x_i2c_suspend, ili210x_i2c_resume); static const struct i2c_device_id ili210x_i2c_id[] = { - { "ili210x", 0 }, + { "ili210x", MODEL_ILI210X }, + { "ili251x", MODEL_ILI251X }, { } }; MODULE_DEVICE_TABLE(i2c, ili210x_i2c_id); static const struct of_device_id ili210x_dt_ids[] = { - { .compatible = "ilitek,ili210x", }, + { .compatible = "ilitek,ili210x", .data = (void *)MODEL_ILI210X }, + { .compatible = "ilitek,ili251x", .data = (void *)MODEL_ILI251X }, { }, }; MODULE_DEVICE_TABLE(of, ili210x_dt_ids);