All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Chen-Yu Tsai <wens@csie.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Michael Trimarchi <michael@amarulasolutions.com>,
	linux-amarula@amarulasolutions.com,
	Jagan Teki <jagan@amarulasolutions.com>
Subject: [PATCH v3 2/4] Input: goodix - Add AVDD28-supply regulator support
Date: Sat, 15 Dec 2018 20:48:00 +0530	[thread overview]
Message-ID: <20181215151802.18592-3-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20181215151802.18592-1-jagan@amarulasolutions.com>

Goodix CTP controllers have AVDD28 pin connected to voltage
regulator which may not be turned on by default, like for GT5663.

Add support for such ctp used boards by adding voltage regulator
handling code to goodix ctp driver.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/input/touchscreen/goodix.c | 33 +++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index f2d9c2c41885..7371f6946098 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -27,6 +27,7 @@
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/of.h>
@@ -47,6 +48,7 @@ struct goodix_ts_data {
 	struct touchscreen_properties prop;
 	unsigned int max_touch_num;
 	unsigned int int_trigger_type;
+	struct regulator *avdd28;
 	struct gpio_desc *gpiod_int;
 	struct gpio_desc *gpiod_rst;
 	u16 id;
@@ -786,25 +788,41 @@ static int goodix_ts_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
+	ts->avdd28 = devm_regulator_get(&client->dev, "AVDD28");
+	if (IS_ERR(ts->avdd28)) {
+		error = PTR_ERR(ts->avdd28);
+		if (error != -EPROBE_DEFER)
+			dev_err(&client->dev,
+				"Failed to get AVDD28 regulator: %d\n", error);
+		return error;
+	}
+
+	/* power the controller */
+	error = regulator_enable(ts->avdd28);
+	if (error) {
+		dev_err(&client->dev, "Controller fail to enable AVDD28\n");
+		return error;
+	}
+
 	if (ts->gpiod_int && ts->gpiod_rst) {
 		/* reset the controller */
 		error = goodix_reset(ts);
 		if (error) {
 			dev_err(&client->dev, "Controller reset failed.\n");
-			return error;
+			goto error;
 		}
 	}
 
 	error = goodix_i2c_test(client);
 	if (error) {
 		dev_err(&client->dev, "I2C communication failure: %d\n", error);
-		return error;
+		goto error;
 	}
 
 	error = goodix_read_version(ts);
 	if (error) {
 		dev_err(&client->dev, "Read version failed.\n");
-		return error;
+		goto error;
 	}
 
 	ts->chip = goodix_get_chip_data(ts->id);
@@ -823,23 +841,28 @@ static int goodix_ts_probe(struct i2c_client *client,
 			dev_err(&client->dev,
 				"Failed to invoke firmware loader: %d\n",
 				error);
-			return error;
+			goto error;
 		}
 
 		return 0;
 	} else {
 		error = goodix_configure_dev(ts);
 		if (error)
-			return error;
+			goto error;
 	}
 
 	return 0;
+
+error:
+	regulator_disable(ts->avdd28);
+	return error;
 }
 
 static int goodix_ts_remove(struct i2c_client *client)
 {
 	struct goodix_ts_data *ts = i2c_get_clientdata(client);
 
+	regulator_disable(ts->avdd28);
 	if (ts->gpiod_int && ts->gpiod_rst)
 		wait_for_completion(&ts->firmware_loading_complete);
 
-- 
2.18.0.321.gffc6fa0e3


  parent reply	other threads:[~2018-12-15 15:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-15 15:17 [PATCH v3 0/4] input: touchscreen: Add goodix GT5553 CTP support Jagan Teki
2018-12-15 15:17 ` [PATCH v3 1/4] dt-bindings: input: touchscreen: goodix: Document AVDD28-supply property Jagan Teki
2019-01-07 22:58   ` Dmitry Torokhov
2019-01-09 13:37     ` Rob Herring
2019-01-18 16:01       ` Jagan Teki
2019-01-21 16:16         ` Rob Herring
2019-01-22 13:38           ` Jagan Teki
2019-01-24  4:32             ` Jagan Teki
2019-02-13 21:51             ` Rob Herring
2019-02-17  7:51               ` Jagan Teki
2019-02-17  9:15                 ` Jagan Teki
2019-02-18  7:12                   ` Dmitry Torokhov
2019-02-18  9:33                     ` Jagan Teki
2019-02-18 19:30                       ` Jagan Teki
2019-02-19  8:15                         ` Dmitry Torokhov
2019-02-19  8:45                           ` Jagan Teki
2018-12-15 15:18 ` Jagan Teki [this message]
2019-01-07 23:00   ` [PATCH v3 2/4] Input: goodix - Add AVDD28-supply regulator support Dmitry Torokhov
2019-01-31 20:00     ` Jagan Teki
2019-02-01  8:18       ` Dmitry Torokhov
2018-12-15 15:18 ` [PATCH v3 3/4] dt-bindings: input: touchscreen: goodix: Add GT5663 compatible Jagan Teki
2018-12-15 15:18 ` [PATCH v3 4/4] Input: goodix - Add GT5663 CTP support Jagan Teki
2019-01-06 16:38 ` [PATCH v3 0/4] input: touchscreen: Add goodix GT5553 " Jagan Teki

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=20181215151802.18592-3-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@amarulasolutions.com \
    --cc=wens@csie.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.