diff mbox series

[4/6] iio: dac: ad5791: Add reset, clr and ldac gpios

Message ID 20241028071118.699951-5-ahaslam@baylibre.com (mailing list archive)
State Changes Requested
Headers show
Series Improvements and Enhancements for AD5791 DAC Driver | expand

Commit Message

Axel Haslam Oct. 28, 2024, 7:11 a.m. UTC
From: Axel Haslam <ahaslam@baylibre.com>

The ad7591 has reset, clr and ldac gpios. For the DAC to output data
continuously written to the data register the state of these gpios needs
to be set by the driver.

Add these gpios to the driver making them optional in case they are fixed
on the pcb.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/iio/dac/ad5791.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

Comments

kernel test robot Oct. 28, 2024, 6:46 p.m. UTC | #1
Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linus/master v6.12-rc5 next-20241028]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/ahaslam-baylibre-com/dt-bindings-iio-dac-ad5791-Add-optional-reset-clr-and-ldac-gpios/20241028-151319
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link:    https://lore.kernel.org/r/20241028071118.699951-5-ahaslam%40baylibre.com
patch subject: [PATCH 4/6] iio: dac: ad5791: Add reset, clr and ldac gpios
config: parisc-randconfig-r071-20241028 (https://download.01.org/0day-ci/archive/20241029/202410290242.TjrDXcKG-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241029/202410290242.TjrDXcKG-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410290242.TjrDXcKG-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/iio/dac/ad5791.c:72: warning: Function parameter or struct member 'name' not described in 'ad5791_chip_info'
   drivers/iio/dac/ad5791.c:72: warning: Function parameter or struct member 'channel' not described in 'ad5791_chip_info'
>> drivers/iio/dac/ad5791.c:105: warning: Function parameter or struct member 'gpio_reset' not described in 'ad5791_state'
>> drivers/iio/dac/ad5791.c:105: warning: Function parameter or struct member 'gpio_clear' not described in 'ad5791_state'
>> drivers/iio/dac/ad5791.c:105: warning: Function parameter or struct member 'gpio_ldac' not described in 'ad5791_state'


vim +105 drivers/iio/dac/ad5791.c

20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   73  
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   74  /**
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   75   * struct ad5791_state - driver instance specific data
ff96bf519acdb3 drivers/iio/dac/ad5791.c         Peter Meerwald     2014-12-06   76   * @spi:			spi_device
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   77   * @reg_vdd:		positive supply regulator
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   78   * @reg_vss:		negative supply regulator
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   79   * @chip_info:		chip model specific constants
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   80   * @vref_mv:		actual reference voltage used
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   81   * @vref_neg_mv:	voltage of the negative supply
0071aa300271a4 drivers/iio/dac/ad5791.c         zuoqilin           2021-01-28   82   * @ctrl:		control register cache
3b1c0b129590d7 drivers/iio/dac/ad5791.c         Lee Jones          2020-07-16   83   * @pwr_down_mode:	current power down mode
3b1c0b129590d7 drivers/iio/dac/ad5791.c         Lee Jones          2020-07-16   84   * @pwr_down:		true if device is powered down
3b1c0b129590d7 drivers/iio/dac/ad5791.c         Lee Jones          2020-07-16   85   * @data:		spi transfer buffers
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   86   */
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   87  struct ad5791_state {
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   88  	struct spi_device		*spi;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   89  	struct regulator		*reg_vdd;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   90  	struct regulator		*reg_vss;
fcc5d80fd09f4c drivers/iio/dac/ad5791.c         Axel Haslam        2024-10-28   91  	struct gpio_desc		*gpio_reset;
fcc5d80fd09f4c drivers/iio/dac/ad5791.c         Axel Haslam        2024-10-28   92  	struct gpio_desc		*gpio_clear;
fcc5d80fd09f4c drivers/iio/dac/ad5791.c         Axel Haslam        2024-10-28   93  	struct gpio_desc		*gpio_ldac;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   94  	const struct ad5791_chip_info	*chip_info;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   95  	unsigned short			vref_mv;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   96  	unsigned int			vref_neg_mv;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   97  	unsigned			ctrl;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   98  	unsigned			pwr_down_mode;
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04   99  	bool				pwr_down;
791bb52a0cd2cc drivers/iio/dac/ad5791.c         Lars-Peter Clausen 2013-11-25  100  
791bb52a0cd2cc drivers/iio/dac/ad5791.c         Lars-Peter Clausen 2013-11-25  101  	union {
791bb52a0cd2cc drivers/iio/dac/ad5791.c         Lars-Peter Clausen 2013-11-25  102  		__be32 d32;
791bb52a0cd2cc drivers/iio/dac/ad5791.c         Lars-Peter Clausen 2013-11-25  103  		u8 d8[4];
b2d5e9de77c877 drivers/iio/dac/ad5791.c         Jonathan Cameron   2022-05-08  104  	} data[3] __aligned(IIO_DMA_MINALIGN);
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04 @105  };
20374d1a36df3e drivers/staging/iio/dac/ad5791.c Lars-Peter Clausen 2012-06-04  106
diff mbox series

Patch

diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index a11e81211669..a7cf19346cf0 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -9,6 +9,7 @@ 
 #include <linux/interrupt.h>
 #include <linux/fs.h>
 #include <linux/device.h>
+#include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
@@ -87,6 +88,9 @@  struct ad5791_state {
 	struct spi_device		*spi;
 	struct regulator		*reg_vdd;
 	struct regulator		*reg_vss;
+	struct gpio_desc		*gpio_reset;
+	struct gpio_desc		*gpio_clear;
+	struct gpio_desc		*gpio_ldac;
 	const struct ad5791_chip_info	*chip_info;
 	unsigned short			vref_mv;
 	unsigned int			vref_neg_mv;
@@ -336,6 +340,22 @@  static int ad5791_probe(struct spi_device *spi)
 	if (!indio_dev)
 		return -ENOMEM;
 	st = iio_priv(indio_dev);
+
+	st->gpio_reset = devm_gpiod_get_optional(&spi->dev, "reset",
+						 GPIOD_OUT_HIGH);
+	if (IS_ERR(st->gpio_reset))
+		return PTR_ERR(st->gpio_reset);
+
+	st->gpio_clear = devm_gpiod_get_optional(&spi->dev, "clear",
+						 GPIOD_OUT_LOW);
+	if (IS_ERR(st->gpio_clear))
+		return PTR_ERR(st->gpio_clear);
+
+	st->gpio_ldac = devm_gpiod_get_optional(&spi->dev, "ldac",
+						GPIOD_OUT_HIGH);
+	if (IS_ERR(st->gpio_ldac))
+		return PTR_ERR(st->gpio_ldac);
+
 	st->reg_vdd = devm_regulator_get(&spi->dev, "vdd");
 	if (!IS_ERR(st->reg_vdd)) {
 		ret = regulator_enable(st->reg_vdd);
@@ -381,9 +401,14 @@  static int ad5791_probe(struct spi_device *spi)
 		dev_warn(&spi->dev, "reference voltage unspecified\n");
 	}
 
-	ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
-	if (ret)
-		goto error_disable_reg_neg;
+	if (st->gpio_reset) {
+		fsleep(20);
+		gpiod_set_value_cansleep(st->gpio_reset, 0);
+	} else {
+		ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
+		if (ret)
+			goto error_disable_reg_neg;
+	}
 
 	st->chip_info = spi_get_device_match_data(spi);
 	if (!st->chip_info)