]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Input: adp5588-keys - add regulator support
authorNuno Sá <nuno.sa@analog.com>
Wed, 31 Aug 2022 04:13:10 +0000 (21:13 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 31 Aug 2022 04:16:33 +0000 (21:16 -0700)
Support feeding VCC through a regulator.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220829131553.690063-10-nuno.sa@analog.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/adp5588-keys.c

index 950abc1c25a33ccc93488694bcd400d73957c490..1db6b28db7bada269285a3e41ccc0fbff502d021 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
+#include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/timekeeping.h>
 
@@ -712,12 +713,18 @@ static int adp5588_fw_parse(struct adp5588_kpad *kpad)
        return 0;
 }
 
+static void adp5588_disable_regulator(void *reg)
+{
+       regulator_disable(reg);
+}
+
 static int adp5588_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
        struct adp5588_kpad *kpad;
        struct input_dev *input;
        struct gpio_desc *gpio;
+       struct regulator *vcc;
        unsigned int revid;
        int ret;
        int error;
@@ -743,6 +750,19 @@ static int adp5588_probe(struct i2c_client *client,
        if (error)
                return error;
 
+       vcc = devm_regulator_get(&client->dev, "vcc");
+       if (IS_ERR(vcc))
+               return PTR_ERR(vcc);
+
+       error = regulator_enable(vcc);
+       if (error)
+               return error;
+
+       error = devm_add_action_or_reset(&client->dev,
+                                        adp5588_disable_regulator, vcc);
+       if (error)
+               return error;
+
        gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
        if (IS_ERR(gpio))
                return PTR_ERR(gpio);