]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mfd: adp5585: Add support for a reset pin
authorNuno Sá <nuno.sa@analog.com>
Tue, 1 Jul 2025 14:32:15 +0000 (15:32 +0100)
committerLee Jones <lee@kernel.org>
Tue, 1 Jul 2025 20:50:51 +0000 (21:50 +0100)
Make sure to perform an Hardware reset during probe  if the pin is given
in FW.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250701-dev-adp5589-fw-v7-20-b1fcfe9e9826@analog.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/adp5585.c

index 11a26f668653439378f9eb31d053c45772a940d0..58f7cebe2ea4f2c68f64370449f5fbce8a2f14ed 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
+#include <linux/gpio/consumer.h>
 #include <linux/mfd/adp5585.h>
 #include <linux/mfd/core.h>
 #include <linux/mod_devicetable.h>
@@ -690,6 +691,7 @@ static int adp5585_i2c_probe(struct i2c_client *i2c)
 {
        struct regmap_config *regmap_config;
        struct adp5585_dev *adp5585;
+       struct gpio_desc *gpio;
        unsigned int id;
        int ret;
 
@@ -714,6 +716,20 @@ static int adp5585_i2c_probe(struct i2c_client *i2c)
        if (ret)
                return ret;
 
+       gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH);
+       if (IS_ERR(gpio))
+               return PTR_ERR(gpio);
+
+       /*
+        * Note the timings are not documented anywhere in the datasheet. They are just
+        * reasonable values that work.
+        */
+       if (gpio) {
+               fsleep(30);
+               gpiod_set_value_cansleep(gpio, 0);
+               fsleep(60);
+       }
+
        adp5585->regmap = devm_regmap_init_i2c(i2c, regmap_config);
        if (IS_ERR(adp5585->regmap))
                return dev_err_probe(&i2c->dev, PTR_ERR(adp5585->regmap),