]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
Input: goodix - add regulators suppot
authorJagan Teki <jagan@amarulasolutions.com>
Wed, 3 Apr 2019 22:20:26 +0000 (15:20 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 3 Apr 2019 23:10:42 +0000 (16:10 -0700)
Goodix CTP controllers require AVDD28, VDDIO regulators for power-on
sequence.

The delay between these regualtor operations as per Power-on Timing
from datasheet[1] is 0 (T1 >= 0 usec).

So, enable and disable these regulators in proper order using normal
regulator functions without any delay in between.

[1] GT5663 Datasheet_English_20151106_Rev.01

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Documentation/devicetree/bindings/input/touchscreen/goodix.txt
drivers/input/touchscreen/goodix.c

index 8cf0b4d38a7e374e3c5d3eb3cfbcaf28e03dd377..255673250bbd469ae2d16167996e5e839305c7e3 100644 (file)
@@ -19,6 +19,8 @@ Optional properties:
  - irq-gpios           : GPIO pin used for IRQ. The driver uses the
                          interrupt gpio pin as output to reset the device.
  - reset-gpios         : GPIO pin used for reset
+ - AVDD28-supply       : Analog power supply regulator on AVDD28 pin
+ - VDDIO-supply                : GPIO power supply regulator on VDDIO pin
  - touchscreen-inverted-x
  - touchscreen-inverted-y
  - touchscreen-size-x
index f57d82220a881cca3bef6f76be902e4792dbabda..b1c071fd243a1335cda1a5af73f2c18832a12417 100644 (file)
@@ -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,8 @@ struct goodix_ts_data {
        struct touchscreen_properties prop;
        unsigned int max_touch_num;
        unsigned int int_trigger_type;
+       struct regulator *avdd28;
+       struct regulator *vddio;
        struct gpio_desc *gpiod_int;
        struct gpio_desc *gpiod_rst;
        u16 id;
@@ -532,6 +535,24 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
                return -EINVAL;
        dev = &ts->client->dev;
 
+       ts->avdd28 = devm_regulator_get(dev, "AVDD28");
+       if (IS_ERR(ts->avdd28)) {
+               error = PTR_ERR(ts->avdd28);
+               if (error != -EPROBE_DEFER)
+                       dev_err(dev,
+                               "Failed to get AVDD28 regulator: %d\n", error);
+               return error;
+       }
+
+       ts->vddio = devm_regulator_get(dev, "VDDIO");
+       if (IS_ERR(ts->vddio)) {
+               error = PTR_ERR(ts->vddio);
+               if (error != -EPROBE_DEFER)
+                       dev_err(dev,
+                               "Failed to get VDDIO regulator: %d\n", error);
+               return error;
+       }
+
        /* Get the interrupt GPIO pin number */
        gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN);
        if (IS_ERR(gpiod)) {
@@ -764,6 +785,14 @@ err_release_cfg:
        complete_all(&ts->firmware_loading_complete);
 }
 
+static void goodix_disable_regulators(void *arg)
+{
+       struct goodix_ts_data *ts = arg;
+
+       regulator_disable(ts->vddio);
+       regulator_disable(ts->avdd28);
+}
+
 static int goodix_ts_probe(struct i2c_client *client,
                           const struct i2c_device_id *id)
 {
@@ -789,6 +818,29 @@ static int goodix_ts_probe(struct i2c_client *client,
        if (error)
                return error;
 
+       /* power up the controller */
+       error = regulator_enable(ts->avdd28);
+       if (error) {
+               dev_err(&client->dev,
+                       "Failed to enable AVDD28 regulator: %d\n",
+                       error);
+               return error;
+       }
+
+       error = regulator_enable(ts->vddio);
+       if (error) {
+               dev_err(&client->dev,
+                       "Failed to enable VDDIO regulator: %d\n",
+                       error);
+               regulator_disable(ts->avdd28);
+               return error;
+       }
+
+       error = devm_add_action_or_reset(&client->dev,
+                                        goodix_disable_regulators, ts);
+       if (error)
+               return error;
+
        if (ts->gpiod_int && ts->gpiod_rst) {
                /* reset the controller */
                error = goodix_reset(ts);