Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3594426imu; Tue, 18 Dec 2018 00:38:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/XIcStKNEiawQu/pxSwaLUumymGkZGNqYp5r3V/KE7RB0IcbcTj5A/WCF3jHRHHe+ZmVnms X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr15934019plk.291.1545122285678; Tue, 18 Dec 2018 00:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545122285; cv=none; d=google.com; s=arc-20160816; b=vatZ+P+5DcfMTNFVKOPAdbZnzrhumSZfSv1Tu/D6mHaHQrlc+QZJFJgBu07sbCh6P+ RIGaOqYNAwUXy/7yfs7NECFWCsx4pwdqYgXS4+X+HTM+zWiS1LRWIOC/EvM5gOJsDnyM Cojed5bsacZHIrP/20mrvxzdZ9fupeNR3GkQ4M8Giwho9t00qz47YOGPjq40d75P5baF GmaqKS5aZAum5MSAdIY/BxF1b2jVUfjo15RIdtFOldj/+v9MsfT/ysEZaMhTd40Ce5tu u2ITeZD1QrzBckrp4TLuQv3frxiXcdoFblGQtE9KnvjvIWYYjcca1GSd4klMh2xf3Y8o 7hfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KZDyW4J+4RjDVtT2jwBOxWATKsReQrWqvRjkMNWKH8g=; b=07dUdb55HCA2XxVJ4efaHEJes41PspFGOUY6GnlP06GLdnAtg8RLdcOkqJ0Nob7ltJ s7DrXOYbUWbWjMdZY9/BASVUi87IR2UAsCtBb3aRNH2q97GUxPeSgO5BxHzakJ/IyGWX e4Ps/OJ4PBvHUgsK+wZUst+xOZHhxxNxCfrpZOmB5iFYDzxIdpyLbxFf8cU++Pehhsgp TlTQKjBOmuhTqI3li0mdNPJkAVMZ0QbbBdEWUriF3Ydlpn2s/qhodTpUppXBN9JRkwcN meN8qYEMfgNTh6/JSMXN+f/toUGzdjqg5Mv6IOCZ1/iVlfDfqtiP/YcOvlV3W9lKmFKP g7vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w67si12709910pgb.45.2018.12.18.00.37.50; Tue, 18 Dec 2018 00:38:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbeLRIgr (ORCPT + 99 others); Tue, 18 Dec 2018 03:36:47 -0500 Received: from mail2.skidata.com ([91.230.2.91]:32226 "EHLO mail2.skidata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbeLRIgn (ORCPT ); Tue, 18 Dec 2018 03:36:43 -0500 X-IronPort-AV: E=Sophos;i="5.56,367,1539640800"; d="scan'208";a="1873949" From: Richard Leitner To: , CC: , , , , Subject: [RESEND PATCH v2 2/8] Input: sx8654 - add reset-gpio support Date: Tue, 18 Dec 2018 09:36:00 +0100 Message-ID: <20181218083606.25795-3-richard.leitner@skidata.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181218083606.25795-1-richard.leitner@skidata.com> References: <20181218083606.25795-1-richard.leitner@skidata.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [192.168.111.252] X-ClientProxiedBy: sdex3srv.skidata.net (192.168.111.81) To sdex5srv.skidata.net (192.168.111.83) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The sx8654 features a NRST input which may be connected to a GPIO. Therefore add support for hard-resetting the sx8654 via this NRST. If the reset-gpio property is provided the sx8654 is resetted via NRST instead of the soft-reset via I2C. Signed-off-by: Richard Leitner --- drivers/input/touchscreen/sx8654.c | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c index ed29db3ec731..238f56b1581b 100644 --- a/drivers/input/touchscreen/sx8654.c +++ b/drivers/input/touchscreen/sx8654.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include /* register addresses */ #define I2C_REG_TOUCH0 0x00 @@ -74,6 +76,7 @@ struct sx8654 { struct input_dev *input; struct i2c_client *client; + struct gpio_desc *gpio_reset; }; static irqreturn_t sx8654_irq(int irq, void *handle) @@ -124,6 +127,27 @@ static irqreturn_t sx8654_irq(int irq, void *handle) return IRQ_HANDLED; } +static int sx8654_reset(struct sx8654 *ts) +{ + int err; + + if (ts->gpio_reset) { + gpiod_set_value_cansleep(ts->gpio_reset, 1); + udelay(2); /* Tpulse > 1µs */ + gpiod_set_value_cansleep(ts->gpio_reset, 0); + + return 0; + } + + dev_dbg(&ts->client->dev, "NRST unavailable, try softreset\n"); + err = i2c_smbus_write_byte_data(ts->client, I2C_REG_SOFTRESET, + SOFTRESET_VALUE); + if (err) + return err; + else + return 0; +} + static int sx8654_open(struct input_dev *dev) { struct sx8654 *sx8654 = input_get_drvdata(dev); @@ -186,6 +210,17 @@ static int sx8654_probe(struct i2c_client *client, if (!sx8654) return -ENOMEM; + sx8654->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(sx8654->gpio_reset)) { + error = PTR_ERR(sx8654->gpio_reset); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, "unable to get reset-gpio: %d\n", + error); + return error; + } + dev_dbg(&client->dev, "got GPIO reset pin\n"); + input = devm_input_allocate_device(&client->dev); if (!input) return -ENOMEM; @@ -206,10 +241,9 @@ static int sx8654_probe(struct i2c_client *client, input_set_drvdata(sx8654->input, sx8654); - error = i2c_smbus_write_byte_data(client, I2C_REG_SOFTRESET, - SOFTRESET_VALUE); + error = sx8654_reset(sx8654); if (error) { - dev_err(&client->dev, "writing softreset value failed"); + dev_err(&client->dev, "reset failed"); return error; } -- 2.11.0