From patchwork Thu May 17 09:05:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10406049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E123960230 for ; Thu, 17 May 2018 09:09:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFE84289EE for ; Thu, 17 May 2018 09:09:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0DB7289F1; Thu, 17 May 2018 09:09: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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 56F68289EE for ; Thu, 17 May 2018 09:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HlJY5+rbvZHHq53tsgHaVhE9NBHiYp3kHgblKVgf5AA=; b=qsqZAyU8aDQegFi7hY/QGBoApc Zz2t+Pmc0dByBpbt/SFNyhIhHcW+F46pLD5TQs85uzoGWv3+iDozuEouheYSaBojHtTu6BFi3O5NU lclBZPi9RqI6ctgZ3BeLh3RX2rJ/eQOlmpqpJ990QSU3KIX//Y7foN1Qb/+qUPqW/fRVS7eu460Gt FdGjPrfGxgMjnJGfHeEyfw3YwMM9Mtor0HDmsV4QZWW+BKunsBjtHqmF653gW67jRzQjCdQOyAsXQ kDjwoOIHL4H1UOuuZG33jsksNc0JH3T4AR0+Y92c3gP8PJyEdT0qFeZneDcxiZ7KZveEVuV0zR+v/ h1hiQymA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJEuP-0005n9-LT; Thu, 17 May 2018 09:09:13 +0000 Received: from mail.bugwerft.de ([46.23.86.59]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJErT-0003nA-22 for linux-arm-kernel@lists.infradead.org; Thu, 17 May 2018 09:06:37 +0000 Received: from localhost.localdomain (mue-88-130-49-030.dsl.tropolys.de [88.130.49.30]) by mail.bugwerft.de (Postfix) with ESMTPSA id A5CE22828E1; Thu, 17 May 2018 09:03:32 +0000 (UTC) From: Daniel Mack To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com Subject: [PATCH v2 2/3] input: touchscreen: edt-ft5x06: assert reset during suspend Date: Thu, 17 May 2018 11:05:51 +0200 Message-Id: <20180517090552.5704-3-daniel@zonque.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180517090552.5704-1-daniel@zonque.org> References: <20180517090552.5704-1-daniel@zonque.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180517_020611_393714_0E713F43 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Daniel Mack , linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the device is not configured as wakeup source, it can be put in reset during suspend to save some power. Signed-off-by: Daniel Mack --- drivers/input/touchscreen/edt-ft5x06.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index e18a2f215500..145499022e1c 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -883,6 +883,20 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) } } +static void edt_ft5x06_reset(struct edt_ft5x06_ts_data *tsdata, bool reset) +{ + if (!tsdata->reset_gpio) + return; + + if (reset) { + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + } else { + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(300); + } +} + static int edt_ft5x06_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -934,11 +948,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, gpiod_set_value_cansleep(tsdata->wake_gpio, 1); } - if (tsdata->reset_gpio) { - usleep_range(5000, 6000); - gpiod_set_value_cansleep(tsdata->reset_gpio, 0); - msleep(300); - } + edt_ft5x06_reset(tsdata, false); input = devm_input_allocate_device(&client->dev); if (!input) { @@ -1034,9 +1044,12 @@ static int edt_ft5x06_ts_remove(struct i2c_client *client) static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); if (device_may_wakeup(dev)) enable_irq_wake(client->irq); + else + edt_ft5x06_reset(tsdata, true); return 0; } @@ -1044,9 +1057,12 @@ static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); if (device_may_wakeup(dev)) disable_irq_wake(client->irq); + else + edt_ft5x06_reset(tsdata, false); return 0; }