From patchwork Tue Feb 11 08:41:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 11375081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28A34924 for ; Tue, 11 Feb 2020 08:46:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF9482070A for ; Tue, 11 Feb 2020 08:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727634AbgBKIqy (ORCPT ); Tue, 11 Feb 2020 03:46:54 -0500 Received: from inva020.nxp.com ([92.121.34.13]:58700 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727582AbgBKIqx (ORCPT ); Tue, 11 Feb 2020 03:46:53 -0500 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 07E7E1A311B; Tue, 11 Feb 2020 09:46:52 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 744291A3129; Tue, 11 Feb 2020 09:46:49 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 71C43402CF; Tue, 11 Feb 2020 16:46:46 +0800 (SGT) From: haibo.chen@nxp.com To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org Cc: haibo.chen@nxp.com, linux-imx@nxp.com Subject: [PATCH 1/2] input: egalax_ts: switch to i2c interface before wake up Date: Tue, 11 Feb 2020 16:41:11 +0800 Message-Id: <1581410472-3225-1-git-send-email-haibo.chen@nxp.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Haibo Chen For HannStar (HSD100PXN1 Rev: 1-A00C11 F/W:0634) LVDS touch screen, it has a special request for the EETI touch controller. The host needs to trigger I2C event to device FW at booting first, and then the FW can switch to I2C interface. Otherwise, the FW can’t work with I2C interface, and can't generate any interrupt when touch the screen. This patch send an I2C command before the device wake up, make sure the device switch to I2C interface first. Signed-off-by: Haibo Chen --- drivers/input/touchscreen/egalax_ts.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 83ac8c128192..5e35ca5edc7b 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c @@ -183,6 +183,20 @@ static int egalax_ts_probe(struct i2c_client *client, ts->client = client; ts->input_dev = input_dev; + /* HannStar (HSD100PXN1 Rev: 1-A00C11 F/W:0634) LVDS touch + * screen needs to trigger I2C event to device FW at booting + * first, and then the FW can switch to I2C interface. + * Otherwise, the FW can’t work with I2C interface. So here + * just use the exist function egalax_firmware_version() to + * send a I2C command to the device, make sure the device FW + * switch to I2C interface. + */ + error = egalax_firmware_version(client); + if (error) { + dev_err(&client->dev, "Failed to switch to I2C interface\n"); + return error; + } + /* controller may be in sleep, wake it up. */ error = egalax_wake_up_device(client); if (error) { From patchwork Tue Feb 11 08:41:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 11375083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F6A81580 for ; Tue, 11 Feb 2020 08:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CB8F2070A for ; Tue, 11 Feb 2020 08:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbgBKIqz (ORCPT ); Tue, 11 Feb 2020 03:46:55 -0500 Received: from inva020.nxp.com ([92.121.34.13]:58718 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727600AbgBKIqz (ORCPT ); Tue, 11 Feb 2020 03:46:55 -0500 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0CF981A3123; Tue, 11 Feb 2020 09:46:53 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 6AA351A3125; Tue, 11 Feb 2020 09:46:50 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id EDB89402DF; Tue, 11 Feb 2020 16:46:46 +0800 (SGT) From: haibo.chen@nxp.com To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org Cc: haibo.chen@nxp.com, linux-imx@nxp.com Subject: [PATCH 2/2] input: egalax_ts: free irq resource before request the line as GPIO Date: Tue, 11 Feb 2020 16:41:12 +0800 Message-Id: <1581410472-3225-2-git-send-email-haibo.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1581410472-3225-1-git-send-email-haibo.chen@nxp.com> References: <1581410472-3225-1-git-send-email-haibo.chen@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Haibo Chen If GPIO is connected to an IRQ then it should not request it as GPIO function only when free its IRQ resource. Signed-off-by: Haibo Chen --- drivers/input/touchscreen/egalax_ts.c | 44 +++++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c index 5e35ca5edc7b..c7983104a0b9 100644 --- a/drivers/input/touchscreen/egalax_ts.c +++ b/drivers/input/touchscreen/egalax_ts.c @@ -116,6 +116,26 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static int egalax_irq_request(struct egalax_ts *ts) +{ + int ret; + struct i2c_client *client = ts->client; + + ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, + egalax_ts_interrupt, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "egalax_ts", ts); + if (ret < 0) + dev_err(&client->dev, "Failed to register interrupt\n"); + + return ret; +} + +static void egalax_free_irq(struct egalax_ts *ts) +{ + devm_free_irq(&ts->client->dev, ts->client->irq, ts); +} + /* wake up controller by an falling edge of interrupt gpio. */ static int egalax_wake_up_device(struct i2c_client *client) { @@ -225,19 +245,15 @@ static int egalax_ts_probe(struct i2c_client *client, ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0); input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0); - error = devm_request_threaded_irq(&client->dev, client->irq, NULL, - egalax_ts_interrupt, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "egalax_ts", ts); - if (error < 0) { - dev_err(&client->dev, "Failed to register interrupt\n"); + error = egalax_irq_request(ts); + if (error) return error; - } error = input_register_device(ts->input_dev); if (error) return error; + i2c_set_clientdata(client, ts); return 0; } @@ -253,11 +269,10 @@ static int __maybe_unused egalax_ts_suspend(struct device *dev) 0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0 }; struct i2c_client *client = to_i2c_client(dev); + struct egalax_ts *ts = i2c_get_clientdata(client); int ret; - if (device_may_wakeup(dev)) - return enable_irq_wake(client->irq); - + egalax_free_irq(ts); ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN); return ret > 0 ? 0 : ret; } @@ -265,11 +280,14 @@ static int __maybe_unused egalax_ts_suspend(struct device *dev) static int __maybe_unused egalax_ts_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct egalax_ts *ts = i2c_get_clientdata(client); + int ret; - if (device_may_wakeup(dev)) - return disable_irq_wake(client->irq); + ret = egalax_wake_up_device(client); + if (!ret) + ret = egalax_irq_request(ts); - return egalax_wake_up_device(client); + return ret; } static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume);