From: Rodrigo Alencar <[email protected]>

Add RESET pin GPIO support through an optional reset controller, which is
local to the probe function and deasserted by default.

Signed-off-by: Rodrigo Alencar <[email protected]>
---
 drivers/iio/dac/ad5686.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index cfbc1624e01c..f239880d1cc7 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -12,6 +12,7 @@
 #include <linux/export.h>
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
+#include <linux/reset.h>
 #include <linux/sysfs.h>
 #include <linux/wordpart.h>
 
@@ -509,6 +510,7 @@ int ad5686_probe(struct device *dev,
                 const struct ad5686_chip_info *chip_info,
                 const char *name, const struct ad5686_bus_ops *ops)
 {
+       struct reset_control *rstc;
        struct iio_dev *indio_dev;
        struct ad5686_state *st;
        int ret, i, shift;
@@ -544,6 +546,11 @@ int ad5686_probe(struct device *dev,
                return dev_err_probe(dev, -EINVAL,
                                     "invalid or not provided vref voltage\n");
 
+       rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
+       if (IS_ERR(rstc))
+               return dev_err_probe(dev, PTR_ERR(rstc),
+                                    "Failed to get reset controller\n");
+
        /* Set all the power down mode for all channels to 1K pulldown */
        st->pwr_down_mode = ~0U;
        st->pwr_down_mask = ~0U;

-- 
2.43.0



Reply via email to