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: 10406033 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 04F2E60247 for ; Thu, 17 May 2018 09:06:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA25E289E4 for ; Thu, 17 May 2018 09:06:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DECE6289E6; Thu, 17 May 2018 09:06:08 +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 7AFA4289E4 for ; Thu, 17 May 2018 09:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150AbeEQJGD (ORCPT ); Thu, 17 May 2018 05:06:03 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:41370 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752291AbeEQJGB (ORCPT ); Thu, 17 May 2018 05:06:01 -0400 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 Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Daniel Mack 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> 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 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; }