From patchwork Mon Apr 29 15:24:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10921947 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 C542514D5 for ; Mon, 29 Apr 2019 15:24:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3BE61FFE6 for ; Mon, 29 Apr 2019 15:24:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A71542842D; Mon, 29 Apr 2019 15:24: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 58BFC1FFE6 for ; Mon, 29 Apr 2019 15:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728681AbfD2PYU (ORCPT ); Mon, 29 Apr 2019 11:24:20 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:50614 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728645AbfD2PYU (ORCPT ); Mon, 29 Apr 2019 11:24:20 -0400 Received: from localhost.localdomain (pD95EFAD5.dip0.t-ipconnect.de [217.94.250.213]) by mail.bugwerft.de (Postfix) with ESMTPSA id C83DC2A9DB0; Mon, 29 Apr 2019 15:22:19 +0000 (UTC) From: Daniel Mack To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, Daniel Mack Subject: [PATCH v4 1/2] input: touch: eeti: move ISR code to own function Date: Mon, 29 Apr 2019 17:24:10 +0200 Message-Id: <20190429152411.12835-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 This allows us to call it at resume time to read the hardware state. Signed-off-by: Daniel Mack Signed-off-by: Daniel Mack Reported-by: Sven Neumann Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/eeti_ts.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 7fe41965c5d1..3e13cc12aaaf 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -75,11 +75,9 @@ 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 { @@ -92,12 +90,18 @@ 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 29 15:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10921949 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 EACA914D5 for ; Mon, 29 Apr 2019 15:24:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB54526222 for ; Mon, 29 Apr 2019 15:24:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF05E28399; Mon, 29 Apr 2019 15:24: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 7989926222 for ; Mon, 29 Apr 2019 15:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728645AbfD2PYV (ORCPT ); Mon, 29 Apr 2019 11:24:21 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:50624 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbfD2PYU (ORCPT ); Mon, 29 Apr 2019 11:24:20 -0400 Received: from localhost.localdomain (pD95EFAD5.dip0.t-ipconnect.de [217.94.250.213]) by mail.bugwerft.de (Postfix) with ESMTPSA id 295582A9DC0; Mon, 29 Apr 2019 15:22:20 +0000 (UTC) From: Daniel Mack To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, Daniel Mack , Sven Neumann Subject: [PATCH v4 2/2] input: touch: eeti: read hardware state once after wakeup Date: Mon, 29 Apr 2019 17:24:11 +0200 Message-Id: <20190429152411.12835-2-daniel@zonque.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429152411.12835-1-daniel@zonque.org> References: <20190429152411.12835-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, and that do not support level-driven interrupts, 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, check for the assertion of the attn gpio, and call into eeti_ts_read() once in the resume path to read the hardware status and to arm the IRQ again. Introduce a mutex to guard eeti_ts_read() against parallel invocations from different contexts. Signed-off-by: Daniel Mack Reported-by: Sven Neumann --- drivers/input/touchscreen/eeti_ts.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 3e13cc12aaaf..48cecdd484a5 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -41,6 +41,7 @@ struct eeti_ts { struct input_dev *input; struct gpio_desc *attn_gpio; struct touchscreen_properties props; + struct mutex mutex; bool running; }; @@ -80,6 +81,8 @@ static void eeti_ts_read(struct eeti_ts *eeti) int len, error; char buf[6]; + mutex_lock(&eeti->mutex); + do { len = i2c_master_recv(eeti->client, buf, sizeof(buf)); if (len != sizeof(buf)) { @@ -95,6 +98,8 @@ static void eeti_ts_read(struct eeti_ts *eeti) eeti_ts_report_event(eeti, buf); } while (eeti->running && eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)); + + mutex_unlock(&eeti->mutex); } static irqreturn_t eeti_ts_isr(int irq, void *dev_id) @@ -111,6 +116,9 @@ static void eeti_ts_start(struct eeti_ts *eeti) eeti->running = true; wmb(); enable_irq(eeti->client->irq); + + if (eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)) + eeti_ts_read(eeti); } static void eeti_ts_stop(struct eeti_ts *eeti) @@ -157,6 +165,8 @@ static int eeti_ts_probe(struct i2c_client *client, return -ENOMEM; } + mutex_init(&eeti->mutex); + input = devm_input_allocate_device(dev); if (!input) { dev_err(dev, "Failed to allocate input device.\n");