From patchwork Thu Jan 3 01:29:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10746897 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 1F6B017D2 for ; Thu, 3 Jan 2019 01:30:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F24728415 for ; Thu, 3 Jan 2019 01:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 034D82841E; Thu, 3 Jan 2019 01:30: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 995042841D for ; Thu, 3 Jan 2019 01:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727338AbfACBaV (ORCPT ); Wed, 2 Jan 2019 20:30:21 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:52746 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbfACBaV (ORCPT ); Wed, 2 Jan 2019 20:30:21 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43VVj60667z1qvSr; Thu, 3 Jan 2019 02:30:18 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43VVj570HQz1qql8; Thu, 3 Jan 2019 02:30:17 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 2R_xHErDMjJE; Thu, 3 Jan 2019 02:30:16 +0100 (CET) X-Auth-Info: ysMlM6MwmnGTjKNlUg0nQshc83CyuECV9waF7CggKEw= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 3 Jan 2019 02:30:16 +0100 (CET) From: Marek Vasut To: linux-input@vger.kernel.org Cc: Marek Vasut , Dmitry Torokhov , Henrik Rydberg , Olivier Sobrie , Philipp Puschmann Subject: [PATCH V3 06/10] input: touchscreen: ili210x: Add reset GPIO support Date: Thu, 3 Jan 2019 02:29:34 +0100 Message-Id: <20190103012938.7442-7-marex@denx.de> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103012938.7442-1-marex@denx.de> References: <20190103012938.7442-1-marex@denx.de> 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 The touchscreen can have a reset GPIO connected to it, add support for such an arrangement. Signed-off-by: Marek Vasut Cc: Dmitry Torokhov Cc: Henrik Rydberg Cc: Olivier Sobrie Cc: Philipp Puschmann To: linux-input@vger.kernel.org --- V2: No change V3: Use devm_add_action_or_reset() for reset GPIO teardown --- drivers/input/touchscreen/ili210x.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index 436bfedb6769..a193ddb06e10 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -5,6 +5,7 @@ #include #include #include +#include #define MAX_TOUCHES 2 #define DEFAULT_POLL_PERIOD 20 @@ -44,6 +45,7 @@ struct ili210x { struct input_dev *input; unsigned int poll_period; struct delayed_work dwork; + struct gpio_desc *reset_gpio; }; static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, @@ -167,11 +169,19 @@ static const struct attribute_group ili210x_attr_group = { .attrs = ili210x_attributes, }; +static void ili210x_power_down(void *data) +{ + struct gpio_desc *reset_gpio = data; + + gpiod_set_value_cansleep(reset_gpio, 1); +} + static int ili210x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct device *dev = &client->dev; struct ili210x *priv; + struct gpio_desc *reset_gpio; struct input_dev *input; struct panel_info panel; struct firmware_version firmware; @@ -185,6 +195,22 @@ static int ili210x_i2c_probe(struct i2c_client *client, return -EINVAL; } + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpio)) + return PTR_ERR(reset_gpio); + + if (reset_gpio) { + error = devm_add_action_or_reset(dev, ili210x_power_down, + reset_gpio); + if (error) + return error; + + gpiod_set_value_cansleep(reset_gpio, 1); + usleep_range(50, 100); + gpiod_set_value_cansleep(reset_gpio, 0); + mdelay(100); + } + /* Get firmware version */ error = ili210x_read_reg(client, REG_FIRMWARE_VERSION, &firmware, sizeof(firmware)); @@ -217,6 +243,7 @@ static int ili210x_i2c_probe(struct i2c_client *client, priv->input = input; priv->poll_period = DEFAULT_POLL_PERIOD; INIT_DELAYED_WORK(&priv->dwork, ili210x_work); + priv->reset_gpio = reset_gpio; /* Setup input device */ input->name = "ILI210x Touchscreen";