From: Richard Leitner <richard.leitner@skidata.com>
To: <dmitry.torokhov@gmail.com>, <mark.rutland@arm.com>
Cc: <robh+dt@kernel.org>, <linux-input@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<richard.leitner@skidata.com>
Subject: [RESEND PATCH v2 2/8] Input: sx8654 - add reset-gpio support
Date: Tue, 18 Dec 2018 09:36:00 +0100 [thread overview]
Message-ID: <20181218083606.25795-3-richard.leitner@skidata.com> (raw)
In-Reply-To: <20181218083606.25795-1-richard.leitner@skidata.com>
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 <richard.leitner@skidata.com>
---
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 <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
+#include <linux/gpio/consumer.h>
+#include <linux/delay.h>
/* 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
next prev parent reply other threads:[~2018-12-18 8:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 8:35 [RESEND PATCH v2 0/8] Input: sx8654 - reset-gpio, sx865[056] support, etc Richard Leitner
2018-12-18 8:35 ` [RESEND PATCH v2 1/8] dt-bindings: input: touchscreen: sx8654: add reset-gpio property Richard Leitner
2018-12-18 8:36 ` Richard Leitner [this message]
2019-01-29 0:26 ` [RESEND PATCH v2 2/8] Input: sx8654 - add reset-gpio support Dmitry Torokhov
2018-12-18 8:36 ` [RESEND PATCH v2 3/8] dt-bindings: input: touchscreen: sx8654: add compatible models Richard Leitner
2018-12-18 8:36 ` [RESEND PATCH v2 4/8] Input: sx8654 - add sx8655 and sx8656 to compatibles Richard Leitner
2019-01-29 0:26 ` Dmitry Torokhov
2018-12-18 8:39 ` [RESEND PATCH v2 5/8] dt-bindings: input: touchscreen: sx8654: add sx8650 to comatibles Richard Leitner
2018-12-18 8:39 ` [RESEND PATCH v2 6/8] Input: sx8654 - add sx8650 support Richard Leitner
2019-01-29 0:12 ` Dmitry Torokhov
2018-12-18 8:39 ` [RESEND PATCH v2 7/8] Input: sx8654 - use common of_touchscreen functions Richard Leitner
2019-01-29 0:25 ` Dmitry Torokhov
2018-12-18 8:40 ` [RESEND PATCH v2 8/8] Input: sx8654 - convert #defined flags to BIT(x) Richard Leitner
2019-01-29 0:25 ` Dmitry Torokhov
2019-01-29 5:40 ` Joe Perches
2019-01-29 11:23 ` Richard Leitner
2019-02-05 7:27 ` Dmitry Torokhov
2019-01-03 10:08 ` [RESEND PATCH v2 0/8] Input: sx8654 - reset-gpio, sx865[056] support, etc Richard Leitner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181218083606.25795-3-richard.leitner@skidata.com \
--to=richard.leitner@skidata.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®