From patchwork Thu Jul 23 14:54:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 6854051 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9D640C05AC for ; Thu, 23 Jul 2015 14:56:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6EEE2074E for ; Thu, 23 Jul 2015 14:56:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A42A72077F for ; Thu, 23 Jul 2015 14:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753769AbbGWOzi (ORCPT ); Thu, 23 Jul 2015 10:55:38 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:33615 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753702AbbGWOze (ORCPT ); Thu, 23 Jul 2015 10:55:34 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t6NEsbpH022230; Thu, 23 Jul 2015 09:54:37 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t6NEsaGq020017; Thu, 23 Jul 2015 09:54:37 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Thu, 23 Jul 2015 09:54:36 -0500 Received: from uda0132425.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t6NEsP84026457; Thu, 23 Jul 2015 09:54:31 -0500 From: Vignesh R To: Dmitry Torokhov , Tony Lindgren , Benoit Cousson , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Russell King CC: Roger Quadros , Henrik Rydberg , Frodo Lai , Jingoo Han , , , , , , Vignesh R Subject: [PATCH v3 1/2] input: touchscreen: pixcir_i2c_ts: Add support for optional wakeup interrupt Date: Thu, 23 Jul 2015 20:24:05 +0530 Message-ID: <1437663246-16049-2-git-send-email-vigneshr@ti.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1437663246-16049-1-git-send-email-vigneshr@ti.com> References: <1437663246-16049-1-git-send-email-vigneshr@ti.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On am437x-gp-evm, pixcir touchscreen can wake the system from low power state by generating wake-up interrupt via pinctrl and IO daisy chain. Add support for optional wakeup interrupt source by regsitering to automated wake IRQ framework introduced by commit 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling"). This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add support for optional wake-up") Signed-off-by: Vignesh R --- v3: * handle error code returned by of_irq_get_byname() v2: * use of_irq_get_byname() * remove enable/disable_wake_irq() drivers/input/touchscreen/pixcir_i2c_ts.c | 22 ++++++++++++++++++---- include/linux/input/pixcir_ts.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 8f3e243a62bf..3a4ab358bf52 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #define PIXCIR_MAX_SLOTS 5 /* Max fingers supported by driver */ @@ -364,8 +366,6 @@ static int __maybe_unused pixcir_i2c_ts_suspend(struct device *dev) goto unlock; } } - - enable_irq_wake(client->irq); } else if (input->users) { ret = pixcir_stop(ts); } @@ -386,8 +386,6 @@ static int __maybe_unused pixcir_i2c_ts_resume(struct device *dev) mutex_lock(&input->mutex); if (device_may_wakeup(&client->dev)) { - disable_irq_wake(client->irq); - if (!input->users) { ret = pixcir_stop(ts); if (ret) { @@ -445,6 +443,13 @@ static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__, pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb); + pdata->wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); + if (pdata->wakeirq < 0 && pdata->wakeirq != -ENODATA && + pdata->wakeirq != -EINVAL) { + dev_err(dev, "Failed to get wakeirq\n"); + return ERR_PTR(pdata->wakeirq); + } + return pdata; } #else @@ -564,11 +569,20 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, i2c_set_clientdata(client, tsdata); device_init_wakeup(&client->dev, 1); + /* Register wakeirq */ + error = (pdata->wakeirq > 0) ? + dev_pm_set_dedicated_wake_irq(dev, pdata->wakeirq) : + dev_pm_set_wake_irq(dev, client->irq); + if (error) + dev_info(dev, "unable to setup wakeirq %d\n", + error); + return 0; } static int pixcir_i2c_ts_remove(struct i2c_client *client) { + dev_pm_clear_wake_irq(&client->dev); device_init_wakeup(&client->dev, 0); return 0; diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h index 7bae83b7c396..da573de5a5ee 100644 --- a/include/linux/input/pixcir_ts.h +++ b/include/linux/input/pixcir_ts.h @@ -58,6 +58,7 @@ struct pixcir_ts_platform_data { int x_max; int y_max; int gpio_attb; /* GPIO connected to ATTB line */ + int wakeirq; struct pixcir_i2c_chip_data chip; };