From patchwork Mon Apr 22 08:35:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10910849 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 3485713B5 for ; Mon, 22 Apr 2019 08:35:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2707928113 for ; Mon, 22 Apr 2019 08:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1512E2859A; Mon, 22 Apr 2019 08:35:53 +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 73B8928113 for ; Mon, 22 Apr 2019 08:35:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727002AbfDVIfw (ORCPT ); Mon, 22 Apr 2019 04:35:52 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:50078 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbfDVIfv (ORCPT ); Mon, 22 Apr 2019 04:35:51 -0400 Received: from localhost.localdomain (pD95EFAF2.dip0.t-ipconnect.de [217.94.250.242]) by mail.bugwerft.de (Postfix) with ESMTPSA id 262122A9DBE; Mon, 22 Apr 2019 08:33:59 +0000 (UTC) From: Daniel Mack To: dmitry.torokhov@gmail.com, robh+dt@kernel.org Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, Daniel Mack Subject: [PATCH 1/2] input: touch: eeti: move ISR code to own function Date: Mon, 22 Apr 2019 10:35:39 +0200 Message-Id: <20190422083540.8380-1-daniel@zonque.org> X-Mailer: git-send-email 2.20.1 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 Move the ISR handling code to its own function and change the logic to bail immediately in case of .running is false or if the attn_gpio is available but unasserted. This allows us to call the function at any time to check for the state of attn_gpio. Signed-off-by: Daniel Mack --- drivers/input/touchscreen/eeti_ts.c | 30 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 7fe41965c5d1..f5724aaa815b 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -75,14 +75,19 @@ static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf) input_sync(eeti->input); } -static irqreturn_t eeti_ts_isr(int irq, void *dev_id) +static void eeti_ts_read(struct eeti_ts *eeti) { - struct eeti_ts *eeti = dev_id; - int len; - int error; + int len, error; char buf[6]; - do { + for (;;) { + if (!eeti->running) + break; + + if (eeti->attn_gpio && + gpiod_get_value_cansleep(eeti->attn_gpio) == 0) + break; + len = i2c_master_recv(eeti->client, buf, sizeof(buf)); if (len != sizeof(buf)) { error = len < 0 ? len : -EIO; @@ -92,12 +97,17 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id) break; } - if (buf[0] & 0x80) { - /* Motion packet */ + /* Motion packet */ + if (buf[0] & 0x80) eeti_ts_report_event(eeti, buf); - } - } while (eeti->running && - eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)); + } +} + +static irqreturn_t eeti_ts_isr(int irq, void *dev_id) +{ + struct eeti_ts *eeti = dev_id; + + eeti_ts_read(eeti); return IRQ_HANDLED; } From patchwork Mon Apr 22 08:35:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10910851 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 8B9C91575 for ; Mon, 22 Apr 2019 08:36:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D29428113 for ; Mon, 22 Apr 2019 08:36:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C6372859A; Mon, 22 Apr 2019 08:36:05 +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 966C128113 for ; Mon, 22 Apr 2019 08:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbfDVIgE (ORCPT ); Mon, 22 Apr 2019 04:36:04 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:50092 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbfDVIgE (ORCPT ); Mon, 22 Apr 2019 04:36:04 -0400 Received: from localhost.localdomain (pD95EFAF2.dip0.t-ipconnect.de [217.94.250.242]) by mail.bugwerft.de (Postfix) with ESMTPSA id 719362A9DC0; Mon, 22 Apr 2019 08:34:11 +0000 (UTC) From: Daniel Mack To: dmitry.torokhov@gmail.com, robh+dt@kernel.org Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, Daniel Mack , Sven Neumann Subject: [PATCH 2/2] input: touch: eeti: read hardware state once after wakeup Date: Mon, 22 Apr 2019 10:35:40 +0200 Message-Id: <20190422083540.8380-2-daniel@zonque.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190422083540.8380-1-daniel@zonque.org> References: <20190422083540.8380-1-daniel@zonque.org> 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 For systems in which the touch IRQ is acting as wakeup source, the interrupt controller might not latch the GPIO IRQ during sleep. In such cases, the interrupt will never occur again after resume, hence the touch screen appears dead. To fix this, call into eeti_ts_read() once to read the hardware status and to arm the IRQ again. Signed-off-by: Daniel Mack Reported-by: Sven Neumann --- drivers/input/touchscreen/eeti_ts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index f5724aaa815b..674386f910ba 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -117,6 +117,7 @@ static void eeti_ts_start(struct eeti_ts *eeti) eeti->running = true; wmb(); enable_irq(eeti->client->irq); + eeti_ts_read(eeti); } static void eeti_ts_stop(struct eeti_ts *eeti)