From patchwork Tue Sep 17 15:58:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 11149031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 692E3112B for ; Tue, 17 Sep 2019 15:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44EF7214AF for ; Tue, 17 Sep 2019 15:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727244AbfIQP6V (ORCPT ); Tue, 17 Sep 2019 11:58:21 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:43707 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbfIQP6V (ORCPT ); Tue, 17 Sep 2019 11:58:21 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAFro-0005CH-Lh; Tue, 17 Sep 2019 17:58:12 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iAFrn-0007Mf-Jf; Tue, 17 Sep 2019 17:58:11 +0200 From: Marco Felsch To: robh+dt@kernel.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, bparrot@ti.com, andy.shevchenko@gmail.com, simon.budig@kernelconcepts.de, hdegoede@redhat.com, fcooper@ti.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 1/6] Input: edt-ft5x06 - alphabetical include reorder Date: Tue, 17 Sep 2019 17:58:03 +0200 Message-Id: <20190917155808.27818-2-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190917155808.27818-1-m.felsch@pengutronix.de> References: <20190917155808.27818-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org It seems that the include order is historical increased and no one takes care of it. Fix this to align it with the common rule to be in a alphabetical order. Signed-off-by: Marco Felsch --- drivers/input/touchscreen/edt-ft5x06.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 3cc4341bbdff..9e328a82b765 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -13,21 +13,21 @@ * http://www.glyn.com/Products/Displays */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include +#include #include +#include +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include #define WORK_REGISTER_THRESHOLD 0x00 #define WORK_REGISTER_REPORT_RATE 0x08 From patchwork Tue Sep 17 15:58:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 11149037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1218416B1 for ; Tue, 17 Sep 2019 15:58:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4CB4214AF for ; Tue, 17 Sep 2019 15:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbfIQP6X (ORCPT ); Tue, 17 Sep 2019 11:58:23 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58057 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727212AbfIQP6W (ORCPT ); Tue, 17 Sep 2019 11:58:22 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAFro-0005CI-Li; Tue, 17 Sep 2019 17:58:12 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iAFrn-0007Mi-K3; Tue, 17 Sep 2019 17:58:11 +0200 From: Marco Felsch To: robh+dt@kernel.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, bparrot@ti.com, andy.shevchenko@gmail.com, simon.budig@kernelconcepts.de, hdegoede@redhat.com, fcooper@ti.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 2/6] dt-bindings: Input: edt-ft5x06 - add disable wakeup-source documentation Date: Tue, 17 Sep 2019 17:58:04 +0200 Message-Id: <20190917155808.27818-3-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190917155808.27818-1-m.felsch@pengutronix.de> References: <20190917155808.27818-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The default driver behaviour is to enable the wakeup-source everytime. There are hardware designs which have a dedicated gpio to act as wakeup device. So it must be allowed to disable the wakeup-source capability. This patch adds the binding documentation to disable the wakeup-source capability. Signed-off-by: Marco Felsch Acked-by: Alexandre Belloni Acked-by: Shawn Guo --- .../devicetree/bindings/input/touchscreen/edt-ft5x06.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt index 870b8c5cce9b..4d6524fe3cf4 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt @@ -35,6 +35,10 @@ Optional properties: - pinctrl-0: a phandle pointing to the pin settings for the control gpios + - edt,disable-wakeup-source: If left the device will act as wakeup-source + (for legacy compatibility). Add the property + so the device won't act as wakeup-source. + - threshold: allows setting the "click"-threshold in the range from 0 to 80. From patchwork Tue Sep 17 15:58:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 11149035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08C3B1708 for ; Tue, 17 Sep 2019 15:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E54B8214AF for ; Tue, 17 Sep 2019 15:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727099AbfIQP6W (ORCPT ); Tue, 17 Sep 2019 11:58:22 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:49363 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbfIQP6W (ORCPT ); Tue, 17 Sep 2019 11:58:22 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAFro-0005CJ-Lj; Tue, 17 Sep 2019 17:58:12 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iAFrn-0007Ml-Ka; Tue, 17 Sep 2019 17:58:11 +0200 From: Marco Felsch To: robh+dt@kernel.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, bparrot@ti.com, andy.shevchenko@gmail.com, simon.budig@kernelconcepts.de, hdegoede@redhat.com, fcooper@ti.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 3/6] Input: edt-ft5x06 - add support to disable the wakeup-source Date: Tue, 17 Sep 2019 17:58:05 +0200 Message-Id: <20190917155808.27818-4-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190917155808.27818-1-m.felsch@pengutronix.de> References: <20190917155808.27818-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Since day one the touch controller acts as wakeup-source. This seems to be wrong since the device supports deep-sleep mechanism [1] which requires a reset to leave it. Also some designs won't use the touchscreen as wakeup-source. Add a firmware property to address this. The common 'wakeup-source' property can't be used for that because the driver must be backward compatible with old firmwares which may assume the default on wakeup-source behaviour. So we need to go the other way by explicit disable the wakeup-source capability. [1] https://www.newhavendisplay.com/appnotes/datasheets/touchpanel/ \ FT5x26.pdf Signed-off-by: Marco Felsch --- drivers/input/touchscreen/edt-ft5x06.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 9e328a82b765..aafb6f4e34d7 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1047,6 +1048,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, unsigned long irq_flags; int error; char fw_version[EDT_NAME_LEN]; + bool en_wakeup; dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n"); @@ -1084,6 +1086,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, return error; } + /* + * We need to go this way to keep backward compatibility with old DT's + * which may assume the default-on mechanism. + */ + en_wakeup = !device_property_present(&client->dev, + "edt,disable-wakeup-source"); + if (tsdata->wake_gpio) { usleep_range(5000, 6000); gpiod_set_value_cansleep(tsdata->wake_gpio, 1); @@ -1172,7 +1181,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, return error; edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); - device_init_wakeup(&client->dev, 1); + device_init_wakeup(&client->dev, en_wakeup); dev_dbg(&client->dev, "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n", From patchwork Tue Sep 17 15:58:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 11149041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37171112B for ; Tue, 17 Sep 2019 15:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EE752171F for ; Tue, 17 Sep 2019 15:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbfIQP6W (ORCPT ); Tue, 17 Sep 2019 11:58:22 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:37397 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbfIQP6W (ORCPT ); Tue, 17 Sep 2019 11:58:22 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAFro-0005CK-Lh; Tue, 17 Sep 2019 17:58:12 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iAFrn-0007Mo-Kz; Tue, 17 Sep 2019 17:58:11 +0200 From: Marco Felsch To: robh+dt@kernel.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, bparrot@ti.com, andy.shevchenko@gmail.com, simon.budig@kernelconcepts.de, hdegoede@redhat.com, fcooper@ti.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 4/6] Input: edt-ft5x06 - add deep sleep mechanism Date: Tue, 17 Sep 2019 17:58:06 +0200 Message-Id: <20190917155808.27818-5-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190917155808.27818-1-m.felsch@pengutronix.de> References: <20190917155808.27818-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org It is possible to bring the device into a deep sleep state. To exit this state the reset or wakeup pin must be toggeled as documented in [1]. Because of the poor documentation I used the several downstream kernels [2] and other applications notes [3] to indentify the related registers. [1] https://www.newhavendisplay.com/appnotes/datasheets/touchpanel/ \ FT5x26.pdf [2] https://github.com/linux-sunxi/linux-sunxi/blob/sunxi-3.4/drivers/ \ input/touchscreen/ft5x_ts.c https://github.com/Pablito2020/focaltech-touch-driver/blob/master/ \ ft5336_driver.c [3] https://www.newhavendisplay.com/appnotes/datasheets/touchpanel/ \ FT5x16_registers.pdf Signed-off-by: Marco Felsch --- drivers/input/touchscreen/edt-ft5x06.c | 42 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index aafb6f4e34d7..b95ce5a7482d 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -37,6 +37,9 @@ #define WORK_REGISTER_NUM_X 0x33 #define WORK_REGISTER_NUM_Y 0x34 +#define PMOD_REGISTER_ACTIVE 0x00 +#define PMOD_REGISTER_HIBERNATE 0x03 + #define M09_REGISTER_THRESHOLD 0x80 #define M09_REGISTER_GAIN 0x92 #define M09_REGISTER_OFFSET 0x93 @@ -52,6 +55,7 @@ #define WORK_REGISTER_OPMODE 0x3c #define FACTORY_REGISTER_OPMODE 0x01 +#define PMOD_REGISTER_OPMODE 0xa5 #define TOUCH_EVENT_DOWN 0x00 #define TOUCH_EVENT_UP 0x01 @@ -1204,19 +1208,51 @@ 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); + int ret; - if (device_may_wakeup(dev)) + if (device_may_wakeup(dev)) { enable_irq_wake(client->irq); + return 0; + } - return 0; + /* + * Hibernate mode requires reset or wake signal to recover to active + * state. + */ + if (!tsdata->wake_gpio && !tsdata->reset_gpio) + return 0; + + ret = edt_ft5x06_register_write(tsdata, PMOD_REGISTER_OPMODE, + PMOD_REGISTER_HIBERNATE); + if (ret) + dev_err(dev, "Failed to set hibernate mode\n"); + + return ret; } 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)) + if (device_may_wakeup(dev)) { disable_irq_wake(client->irq); + return 0; + } + + /* Recover from hibernate mode if hardware supports it */ + if (tsdata->wake_gpio) { + gpiod_set_value_cansleep(tsdata->wake_gpio, 0); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->wake_gpio, 1); + msleep(300); + } else if (tsdata->reset_gpio) { + gpiod_set_value_cansleep(tsdata->reset_gpio, 1); + usleep_range(5000, 6000); + gpiod_set_value_cansleep(tsdata->reset_gpio, 0); + msleep(300); + } return 0; } From patchwork Tue Sep 17 15:58:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 11149029 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27E2216B1 for ; Tue, 17 Sep 2019 15:58:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FF93214AF for ; Tue, 17 Sep 2019 15:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbfIQP6U (ORCPT ); Tue, 17 Sep 2019 11:58:20 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:47863 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbfIQP6U (ORCPT ); Tue, 17 Sep 2019 11:58:20 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAFro-0005CL-Ln; Tue, 17 Sep 2019 17:58:12 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iAFrn-0007Mr-LX; Tue, 17 Sep 2019 17:58:11 +0200 From: Marco Felsch To: robh+dt@kernel.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, bparrot@ti.com, andy.shevchenko@gmail.com, simon.budig@kernelconcepts.de, hdegoede@redhat.com, fcooper@ti.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 5/6] dt-bindings: Input: edt-ft5x06 - add vdd supply documentation Date: Tue, 17 Sep 2019 17:58:07 +0200 Message-Id: <20190917155808.27818-6-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190917155808.27818-1-m.felsch@pengutronix.de> References: <20190917155808.27818-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add DT documentation for the optional regulator. Signed-off-by: Marco Felsch Acked-by: Rob Herring --- .../devicetree/bindings/input/touchscreen/edt-ft5x06.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt index 4d6524fe3cf4..d8cd731791cc 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt @@ -30,6 +30,7 @@ Required properties: Optional properties: - reset-gpios: GPIO specification for the RESET input - wake-gpios: GPIO specification for the WAKE input + - vdd-supply: Regulator phandle for the 3.3V power supply input - pinctrl-names: should be "default" - pinctrl-0: a phandle pointing to the pin settings for the From patchwork Tue Sep 17 15:58:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 11149033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A88C716B1 for ; Tue, 17 Sep 2019 15:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90AC12171F for ; Tue, 17 Sep 2019 15:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbfIQP6W (ORCPT ); Tue, 17 Sep 2019 11:58:22 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:42813 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727224AbfIQP6V (ORCPT ); Tue, 17 Sep 2019 11:58:21 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAFro-0005CM-Lo; Tue, 17 Sep 2019 17:58:12 +0200 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1iAFrn-0007Mu-M1; Tue, 17 Sep 2019 17:58:11 +0200 From: Marco Felsch To: robh+dt@kernel.org, andriy.shevchenko@linux.intel.com, dmitry.torokhov@gmail.com, bparrot@ti.com, andy.shevchenko@gmail.com, simon.budig@kernelconcepts.de, hdegoede@redhat.com, fcooper@ti.com Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 6/6] Input: edt-ft5x06 - add supply voltage support Date: Tue, 17 Sep 2019 17:58:08 +0200 Message-Id: <20190917155808.27818-7-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190917155808.27818-1-m.felsch@pengutronix.de> References: <20190917155808.27818-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Currently the driver do not care about the regulator which supplies the controller. This can lead into problems since we support (deep-)sleep because the regulator can be turned off before we send the (deep-)sleep command to the controller. Using a own regulator improves the power consumption during sleep even more. Signed-off-by: Marco Felsch --- drivers/input/touchscreen/edt-ft5x06.c | 53 ++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index b95ce5a7482d..6429e915ec94 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -96,6 +97,7 @@ struct edt_ft5x06_ts_data { struct gpio_desc *reset_gpio; struct gpio_desc *wake_gpio; + struct regulator *vdd; #if defined(CONFIG_DEBUG_FS) struct dentry *debug_dir; @@ -1090,6 +1092,23 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, return error; } + tsdata->vdd = devm_regulator_get(&client->dev, "vdd"); + if (IS_ERR(tsdata->vdd)) { + error = PTR_ERR(tsdata->vdd); + if (error == -EPROBE_DEFER) + return error; + dev_err(&client->dev, + "Failed to request vdd-supply, error %d\n", error); + return error; + } + + error = regulator_enable(tsdata->vdd); + if (error) { + dev_err(&client->dev, + "Failed to enable vdd-supply, error %d\n", error); + return error; + } + /* * We need to go this way to keep backward compatibility with old DT's * which may assume the default-on mechanism. @@ -1111,7 +1130,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, input = devm_input_allocate_device(&client->dev); if (!input) { dev_err(&client->dev, "failed to allocate input device.\n"); - return -ENOMEM; + error = -ENOMEM; + goto err_reg_disable; } mutex_init(&tsdata->mutex); @@ -1122,7 +1142,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, error = edt_ft5x06_ts_identify(client, tsdata, fw_version); if (error) { dev_err(&client->dev, "touchscreen probe failed\n"); - return error; + goto err_reg_disable; } edt_ft5x06_ts_set_regs(tsdata); @@ -1158,7 +1178,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, INPUT_MT_DIRECT); if (error) { dev_err(&client->dev, "Unable to init MT slots.\n"); - return error; + goto err_reg_disable; } i2c_set_clientdata(client, tsdata); @@ -1173,16 +1193,16 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, client->name, tsdata); if (error) { dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); - return error; + goto err_reg_disable; } error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group); if (error) - return error; + goto err_reg_disable; error = input_register_device(input); if (error) - return error; + goto err_reg_disable; edt_ft5x06_ts_prepare_debugfs(tsdata, dev_driver_string(&client->dev)); device_init_wakeup(&client->dev, en_wakeup); @@ -1194,6 +1214,10 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, tsdata->reset_gpio ? desc_to_gpio(tsdata->reset_gpio) : -1); return 0; + +err_reg_disable: + regulator_disable(tsdata->vdd); + return error; } static int edt_ft5x06_ts_remove(struct i2c_client *client) @@ -1225,8 +1249,16 @@ static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) ret = edt_ft5x06_register_write(tsdata, PMOD_REGISTER_OPMODE, PMOD_REGISTER_HIBERNATE); - if (ret) + if (ret) { dev_err(dev, "Failed to set hibernate mode\n"); + return ret; + } + + ret = regulator_disable(tsdata->vdd); + if (ret) { + dev_err(dev, "Failed to disable vdd\n"); + return ret; + } return ret; } @@ -1235,12 +1267,19 @@ 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); + int error; if (device_may_wakeup(dev)) { disable_irq_wake(client->irq); return 0; } + error = regulator_enable(tsdata->vdd); + if (error) { + dev_err(&client->dev, "Failed to enable vdd\n"); + return error; + } + /* Recover from hibernate mode if hardware supports it */ if (tsdata->wake_gpio) { gpiod_set_value_cansleep(tsdata->wake_gpio, 0);