Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp845028imm; Wed, 17 Oct 2018 09:09:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV63X1NjeDeTGbvc013FaQ2C7jEUUd9wyHL9d3b68XIY9HqkFXANl6pbAtngJaZJPpVJqWACt X-Received: by 2002:a63:e505:: with SMTP id r5-v6mr24496679pgh.170.1539792556765; Wed, 17 Oct 2018 09:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539792556; cv=none; d=google.com; s=arc-20160816; b=yb28yRz+C9w8ZcaKG1bFgINUxsSShhSxRt77y+3kT6AZRhkU36T2aPgzBAA/g64SRf zs3KtEydZEc7Za2Z5Wsdj7oHeH0Hn91+nIyC9ioq5hTPVTI2jjexl6mETHVPA/izOsYl q0qh1zxBx1/XA7FWtsfKkMISv6p4KjRroZL2kSFseUVig/IBVYJ/fnce6YYt+C2Gw+wd fag0KQjrV3JTrh/rV6ixq03SPJvkrNGG+hPi8BhMd4w/F7uCyMfr/3L0pyNRLdxU6d1u x0omtMKzUOm6wd9By8PVmtVx/Cz5JxAwKwQZsPcQta3CkCwyzZStDYZUm9rtLZ1staqQ 0yhQ== 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=J1HMXrpwsu1SXCTBdnUOVmipwCZBXFdXfT1ILKZ/d6mNd3Ggq+8493g5DGRbOy6Spj pbf9jTcngfOpAV0oAfH51Q8I8dMSoCdlpg535t+kw4vDETWAjTsc3wBF4iYVS272L6q7 RYWsmVyKsNLsaTDo5m58rYmYv8keZU/rqB0uFWXNEhjH7NBJU3wNQBAq1/0AnlsDlBu2 n2Qu7EeO9gmpsLIjPmaTow3eGi/7mARIXFt6BSJUxanWlI2NM4XuR4/cuSFh8mrTzbLX 7dLBWexVK4IrPqvbiBr1lieWABksa/lbG9ttuZk70eYp4hxrCum8islhKBPWDPhod+SP XCRA== 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 w2-v6si17468301pll.171.2018.10.17.09.08.59; Wed, 17 Oct 2018 09:09:16 -0700 (PDT) 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 S1728016AbeJRAES (ORCPT + 99 others); Wed, 17 Oct 2018 20:04:18 -0400 Received: from mail1.skidata.com ([91.230.2.99]:30719 "EHLO mail1.skidata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727014AbeJRAER (ORCPT ); Wed, 17 Oct 2018 20:04:17 -0400 X-IronPort-AV: E=Sophos;i="5.54,393,1534802400"; d="scan'208";a="12919542" From: Richard Leitner To: , , CC: , , , Richard Leitner Subject: [PATCH v2 2/8] Input: sx8654 - add reset-gpio support Date: Wed, 17 Oct 2018 14:51:10 +0200 Message-ID: <20181017125116.20077-3-richard.leitner@skidata.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181017125116.20077-1-richard.leitner@skidata.com> References: <20181017125116.20077-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: sdex5srv.skidata.net (192.168.111.83) 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