Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers
@ 2026-11-25 10:19 Nuno Sá
  2026-11-25 10:19 ` [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic Nuno Sá
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

The ad7266, ad7887, ad7791 and ad7793 drivers can still only be
configured through platform data headers, and nothing in tree uses them
anymore. This series removes them.

The ad7266, ad7887 and ad7791 drivers already work without platform
data, so the headers are just dropped and the drivers keep the
configuration they use today when no platform data is given. The
ad7793 driver refuses to probe without platform data, so it gets a
binding and firmware properties instead.

Patch 1 fixes an issue in ad7887 found while looking at the driver: the
on-chip reference gets disabled exactly when the driver relies on it.

For ad7266 and ad7887, the code for the modes that could only be
selected through platform data (address GPIOs, other sample modes and
input range on ad7266, dual channel mode on ad7887) is kept, so that
someone needing it can easily add firmware properties for it. I'm likely
being optimistic and odds are it will be just dead code so I'm glad to
drop all of it if that's the feedback I get.

I also want to keep changes to a minimal to not end up with big
refactors.

This series was also prepared with the help of AI tools.

---
Nuno Sá (6):
      iio: adc: ad7887: fix on-chip reference enable logic
      iio: adc: ad7887: drop platform data support
      iio: adc: ad7266: drop platform data support
      iio: adc: ad7791: drop platform data support
      dt-bindings: iio: adc: add AD7793 and similar ADCs
      iio: adc: ad7793: add firmware support and drop platform data

 .../devicetree/bindings/iio/adc/adi,ad7793.yaml    | 236 +++++++++++++++
 MAINTAINERS                                        |   9 +
 drivers/iio/adc/ad7266.c                           |  58 ++--
 drivers/iio/adc/ad7791.c                           |  26 +-
 drivers/iio/adc/ad7793.c                           | 315 ++++++++++++++++++---
 drivers/iio/adc/ad7887.c                           |  15 +-
 include/linux/platform_data/ad7266.h               |  50 ----
 include/linux/platform_data/ad7791.h               |  18 --
 include/linux/platform_data/ad7793.h               | 111 --------
 include/linux/platform_data/ad7887.h               |  21 --
 10 files changed, 575 insertions(+), 284 deletions(-)
---
base-commit: b70566610b48ba49dec636019da4d696db64b085
change-id: 20261111-iio-adi-legacy-platdata-63eaa0e33063
--

Thanks!
- Nuno Sá


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
@ 2026-11-25 10:19 ` Nuno Sá
  2026-11-25 10:25   ` sashiko-bot
  2026-11-25 10:19 ` [PATCH 2/6] iio: adc: ad7887: drop platform data support Nuno Sá
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

The REF bit in the control register disables the on-chip 2.5 V
reference when set. Before commit 5483b8d5015b ("iio: adc: ad7887:
invert/rework external ref logic"), the driver set it when an external
reference was used. That commit replaced the use_onchip_ref platform
data flag with the presence of the vref regulator, but kept the
condition as is. As a result, the bit is now set when there is no
external reference, so the on-chip reference gets disabled exactly
when the driver relies on it, and is left enabled when an external
reference is supplied.

Only disable the on-chip reference when a vref regulator is present.

Fixes: 5483b8d5015b ("iio: adc: ad7887: invert/rework external ref logic")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7887.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 827d0c2598ba..980e6a303047 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -271,7 +271,7 @@ static int ad7887_probe(struct spi_device *spi)
 	/* Setup default message */
 
 	mode = AD7887_PM_MODE4;
-	if (!st->reg)
+	if (st->reg)
 		mode |= AD7887_REF_DIS;
 	if (pdata && pdata->en_dual)
 		mode |= AD7887_DUAL;

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] iio: adc: ad7887: drop platform data support
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
  2026-11-25 10:19 ` [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic Nuno Sá
@ 2026-11-25 10:19 ` Nuno Sá
  2026-11-25 10:19 ` [PATCH 3/6] iio: adc: ad7266: " Nuno Sá
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

There are no in-tree users of struct ad7887_platform_data, and the
driver works fine without it. Its only knob, en_dual, selects dual
channel mode, where the AIN1/VREF pin is used as a second input.

Drop the platform data header and default to single channel mode, which
is what the driver does when no platform data is given. The dual
channel code is kept so it can be enabled again should someone need it
and add a firmware property for it.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>

---
As stated in the cover, I'm glad to drop dead code if no one sees value
in keeping it for possible future changes (which are unlikely tbh).
---
 drivers/iio/adc/ad7887.c             | 13 ++++++++-----
 include/linux/platform_data/ad7887.h | 21 ---------------------
 2 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 980e6a303047..32097b387d53 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -25,8 +25,6 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-#include <linux/platform_data/ad7887.h>
-
 #define AD7887_REF_DIS		BIT(5)	/* on-chip reference disable */
 #define AD7887_DUAL		BIT(4)	/* dual-channel mode */
 #define AD7887_CH_AIN1		BIT(3)	/* convert on channel 1, DUAL=1 */
@@ -229,7 +227,12 @@ static void ad7887_reg_disable(void *data)
 
 static int ad7887_probe(struct spi_device *spi)
 {
-	const struct ad7887_platform_data *pdata = dev_get_platdata(&spi->dev);
+	/*
+	 * Dual channel mode could only be enabled through platform data, which
+	 * had no users. Keep the support around in case someone needs it and
+	 * adds a firmware property for it.
+	 */
+	bool en_dual = false;
 	struct ad7887_state *st;
 	struct iio_dev *indio_dev;
 	uint8_t mode;
@@ -273,7 +276,7 @@ static int ad7887_probe(struct spi_device *spi)
 	mode = AD7887_PM_MODE4;
 	if (st->reg)
 		mode |= AD7887_REF_DIS;
-	if (pdata && pdata->en_dual)
+	if (en_dual)
 		mode |= AD7887_DUAL;
 
 	st->tx_cmd_buf[0] = AD7887_CH_AIN0 | mode;
@@ -285,7 +288,7 @@ static int ad7887_probe(struct spi_device *spi)
 	spi_message_init(&st->msg[AD7887_CH0]);
 	spi_message_add_tail(&st->xfer[0], &st->msg[AD7887_CH0]);
 
-	if (pdata && pdata->en_dual) {
+	if (en_dual) {
 		st->tx_cmd_buf[2] = AD7887_CH_AIN1 | mode;
 
 		st->xfer[1].rx_buf = &st->data[0];
diff --git a/include/linux/platform_data/ad7887.h b/include/linux/platform_data/ad7887.h
deleted file mode 100644
index 9b4dca6ae70b..000000000000
--- a/include/linux/platform_data/ad7887.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * AD7887 SPI ADC driver
- *
- * Copyright 2010 Analog Devices Inc.
- */
-#ifndef IIO_ADC_AD7887_H_
-#define IIO_ADC_AD7887_H_
-
-/**
- * struct ad7887_platform_data - AD7887 ADC driver platform data
- * @en_dual: Whether to use dual channel mode. If set to true AIN1 becomes the
- *	second input channel, and Vref is internally connected to Vdd. If set to
- *	false the device is used in single channel mode and AIN1/Vref is used as
- *	VREF input.
- */
-struct ad7887_platform_data {
-	bool en_dual;
-};
-
-#endif /* IIO_ADC_AD7887_H_ */

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] iio: adc: ad7266: drop platform data support
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
  2026-11-25 10:19 ` [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic Nuno Sá
  2026-11-25 10:19 ` [PATCH 2/6] iio: adc: ad7887: drop platform data support Nuno Sá
@ 2026-11-25 10:19 ` Nuno Sá
  2026-11-25 10:19 ` [PATCH 4/6] iio: adc: ad7791: " Nuno Sá
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

There are no in-tree users of struct ad7266_platform_data. Without it,
the driver already falls back to a fixed address, differential mode
and the 0V - VREF input range.

Drop the platform data header and move the range and mode enums into
the driver. The code for the address GPIOs, the pseudo differential and
single-ended modes and the 0V - 2VREF range is kept so it can be
enabled again should someone need it and add firmware properties for
it.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7266.c             | 58 +++++++++++++++++++++++++-----------
 include/linux/platform_data/ad7266.h | 50 -------------------------------
 2 files changed, 41 insertions(+), 67 deletions(-)

diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 594a070c3745..2eba5d05d9b4 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -21,10 +21,35 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-#include <linux/platform_data/ad7266.h>
-
 #define AD7266_INTERNAL_REF_MV	2500
 
+/**
+ * enum ad7266_range - AD7266 reference voltage range
+ * @AD7266_RANGE_VREF: Device is configured for input range 0V - VREF
+ *			(RANGE pin set to low)
+ * @AD7266_RANGE_2VREF: Device is configured for input range 0V - 2VREF
+ *			(RANGE pin set to high)
+ */
+enum ad7266_range {
+	AD7266_RANGE_VREF,
+	AD7266_RANGE_2VREF,
+};
+
+/**
+ * enum ad7266_mode - AD7266 sample mode
+ * @AD7266_MODE_DIFF: Device is configured for full differential mode
+ *				(SGL/DIFF pin set to low, AD0 pin set to low)
+ * @AD7266_MODE_PSEUDO_DIFF: Device is configured for pseudo differential mode
+ *				(SGL/DIFF pin set to low, AD0 pin set to high)
+ * @AD7266_MODE_SINGLE_ENDED: Device is configured for single-ended mode
+ *				(SGL/DIFF pin set to high)
+ */
+enum ad7266_mode {
+	AD7266_MODE_DIFF,
+	AD7266_MODE_PSEUDO_DIFF,
+	AD7266_MODE_SINGLE_ENDED,
+};
+
 struct ad7266_state {
 	struct spi_device	*spi;
 	unsigned long		vref_mv;
@@ -381,7 +406,6 @@ static const char * const ad7266_gpio_labels[] = {
 
 static int ad7266_probe(struct spi_device *spi)
 {
-	const struct ad7266_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct iio_dev *indio_dev;
 	struct ad7266_state *st;
 	unsigned int i;
@@ -399,24 +423,24 @@ static int ad7266_probe(struct spi_device *spi)
 
 	st->vref_mv = ret == -ENODEV ? AD7266_INTERNAL_REF_MV : ret / 1000;
 
-	if (pdata) {
-		st->fixed_addr = pdata->fixed_addr;
-		st->mode = pdata->mode;
-		st->range = pdata->range;
+	/*
+	 * The address GPIOs, the other sample modes and the 0V - 2VREF range
+	 * could only be selected through platform data, which had no users.
+	 * Keep the support around in case someone needs it and adds firmware
+	 * properties for it.
+	 */
+	st->fixed_addr = true;
+	st->range = AD7266_RANGE_VREF;
+	st->mode = AD7266_MODE_DIFF;
 
-		if (!st->fixed_addr) {
-			for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) {
-				st->gpios[i] = devm_gpiod_get(&spi->dev,
+	if (!st->fixed_addr) {
+		for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) {
+			st->gpios[i] = devm_gpiod_get(&spi->dev,
 						      ad7266_gpio_labels[i],
 						      GPIOD_OUT_LOW);
-				if (IS_ERR(st->gpios[i]))
-					return PTR_ERR(st->gpios[i]);
-			}
+			if (IS_ERR(st->gpios[i]))
+				return PTR_ERR(st->gpios[i]);
 		}
-	} else {
-		st->fixed_addr = true;
-		st->range = AD7266_RANGE_VREF;
-		st->mode = AD7266_MODE_DIFF;
 	}
 
 	st->spi = spi;
diff --git a/include/linux/platform_data/ad7266.h b/include/linux/platform_data/ad7266.h
deleted file mode 100644
index f0652567afba..000000000000
--- a/include/linux/platform_data/ad7266.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AD7266/65 SPI ADC driver
- *
- * Copyright 2012 Analog Devices Inc.
- */
-
-#ifndef __IIO_ADC_AD7266_H__
-#define __IIO_ADC_AD7266_H__
-
-/**
- * enum ad7266_range - AD7266 reference voltage range
- * @AD7266_RANGE_VREF: Device is configured for input range 0V - VREF
- *			(RANGE pin set to low)
- * @AD7266_RANGE_2VREF: Device is configured for input range 0V - 2VREF
- *			(RANGE pin set to high)
- */
-enum ad7266_range {
-	AD7266_RANGE_VREF,
-	AD7266_RANGE_2VREF,
-};
-
-/**
- * enum ad7266_mode - AD7266 sample mode
- * @AD7266_MODE_DIFF: Device is configured for full differential mode
- *				(SGL/DIFF pin set to low, AD0 pin set to low)
- * @AD7266_MODE_PSEUDO_DIFF: Device is configured for pseudo differential mode
- *				(SGL/DIFF pin set to low, AD0 pin set to high)
- * @AD7266_MODE_SINGLE_ENDED: Device is configured for single-ended mode
- *				(SGL/DIFF pin set to high)
- */
-enum ad7266_mode {
-	AD7266_MODE_DIFF,
-	AD7266_MODE_PSEUDO_DIFF,
-	AD7266_MODE_SINGLE_ENDED,
-};
-
-/**
- * struct ad7266_platform_data - Platform data for the AD7266 driver
- * @range: Reference voltage range the device is configured for
- * @mode: Sample mode the device is configured for
- * @fixed_addr: Whether the address pins are hard-wired
- */
-struct ad7266_platform_data {
-	enum ad7266_range range;
-	enum ad7266_mode mode;
-	bool fixed_addr;
-};
-
-#endif

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] iio: adc: ad7791: drop platform data support
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
                   ` (2 preceding siblings ...)
  2026-11-25 10:19 ` [PATCH 3/6] iio: adc: ad7266: " Nuno Sá
@ 2026-11-25 10:19 ` Nuno Sá
  2026-11-25 10:40   ` Andy Shevchenko
  2026-11-25 10:19 ` [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs Nuno Sá
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

There are no in-tree users of struct ad7791_platform_data. Without it,
the driver already keeps the power-on reset configuration: buffered
mode (on parts that have a buffer), bipolar mode and no burnout
current.

Drop the platform data header together with the code applying it. As a
result, ad7791_setup() can no longer fail, so make it return void.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7791.c             | 26 ++------------------------
 include/linux/platform_data/ad7791.h | 18 ------------------
 2 files changed, 2 insertions(+), 42 deletions(-)

diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c
index c2688307bbba..1edc2284626f 100644
--- a/drivers/iio/adc/ad7791.c
+++ b/drivers/iio/adc/ad7791.c
@@ -26,8 +26,6 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/adc/ad_sigma_delta.h>
 
-#include <linux/platform_data/ad7791.h>
-
 #define AD7791_REG_COMM			0x0 /* For writes */
 #define AD7791_REG_STATUS		0x0 /* For reads */
 #define AD7791_REG_MODE			0x1
@@ -376,28 +374,11 @@ static const struct iio_info ad7791_no_filter_info = {
 	.validate_trigger = ad_sd_validate_trigger,
 };
 
-static int ad7791_setup(struct ad7791_state *st,
-			const struct ad7791_platform_data *pdata)
+static void ad7791_setup(struct ad7791_state *st)
 {
 	/* Set to poweron-reset default values */
 	st->mode = AD7791_MODE_BUFFER;
 	st->filter = AD7791_FILTER_RATE_16_6;
-
-	if (!pdata)
-		return 0;
-
-	if ((st->info->flags & AD7791_FLAG_HAS_BUFFER) && !pdata->buffered)
-		st->mode &= ~AD7791_MODE_BUFFER;
-
-	if ((st->info->flags & AD7791_FLAG_HAS_BURNOUT) &&
-		pdata->burnout_current)
-		st->mode |= AD7791_MODE_BURNOUT;
-
-	if ((st->info->flags & AD7791_FLAG_HAS_UNIPOLAR) && pdata->unipolar)
-		st->mode |= AD7791_MODE_UNIPOLAR;
-
-	return ad_sd_write_reg(&st->sd, AD7791_REG_MODE, sizeof(st->mode),
-		st->mode);
 }
 
 static void ad7791_reg_disable(void *reg)
@@ -408,7 +389,6 @@ static void ad7791_reg_disable(void *reg)
 static int ad7791_probe(struct spi_device *spi)
 {
 	struct device *dev = &spi->dev;
-	const struct ad7791_platform_data *pdata = dev_get_platdata(dev);
 	struct iio_dev *indio_dev;
 	struct ad7791_state *st;
 	int ret;
@@ -450,9 +430,7 @@ static int ad7791_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	ret = ad7791_setup(st, pdata);
-	if (ret)
-		return ret;
+	ad7791_setup(st);
 
 	return devm_iio_device_register(dev, indio_dev);
 }
diff --git a/include/linux/platform_data/ad7791.h b/include/linux/platform_data/ad7791.h
deleted file mode 100644
index cc7533049b5b..000000000000
--- a/include/linux/platform_data/ad7791.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __LINUX_PLATFORM_DATA_AD7791__
-#define __LINUX_PLATFORM_DATA_AD7791__
-
-/**
- * struct ad7791_platform_data - AD7791 device platform data
- * @buffered: If set to true configure the device for buffered input mode.
- * @burnout_current: If set to true the 100mA burnout current is enabled.
- * @unipolar: If set to true sample in unipolar mode, if set to false sample in
- *		bipolar mode.
- */
-struct ad7791_platform_data {
-	bool buffered;
-	bool burnout_current;
-	bool unipolar;
-};
-
-#endif

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
                   ` (3 preceding siblings ...)
  2026-11-25 10:19 ` [PATCH 4/6] iio: adc: ad7791: " Nuno Sá
@ 2026-11-25 10:19 ` Nuno Sá
  2026-11-25 10:28   ` sashiko-bot
  2026-11-25 10:19 ` [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data Nuno Sá
  2026-11-25 10:36 ` [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Arnd Bergmann
  6 siblings, 1 reply; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

Add a binding for the AD7785, AD7792, AD7793, AD7794, AD7795, AD7796,
AD7797, AD7798 and AD7799 low power sigma-delta ADCs. The driver has
supported these parts for a long time, but only through platform data.

The ADC reference is described by which supplies are present: REFIN
(REFIN1 on the AD7794/AD7795), then REFIN2, and otherwise the internal
1.17 V reference. In the same way, an external clock on the CLK pin is
used if one is given, and the internal 64 kHz clock otherwise.

The remaining properties describe how the analog front end is wired:
the input buffer (enabled by default, as it is at power-up), unipolar
or bipolar coding, the burnout current sources, the bias voltage
generator and the excitation current sources.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 .../devicetree/bindings/iio/adc/adi,ad7793.yaml    | 236 +++++++++++++++++++++
 MAINTAINERS                                        |  10 +
 2 files changed, 246 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml
new file mode 100644
index 000000000000..c4a0be06e5c0
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml
@@ -0,0 +1,236 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/adi,ad7793.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD7793 and similar sigma-delta ADCs
+
+maintainers:
+  - Michael Hennerich <michael.hennerich@analog.com>
+  - Nuno Sá <nuno.sa@analog.com>
+
+description:
+  Low power, low noise sigma-delta ADCs with an SPI interface.
+
+  https://www.analog.com/media/en/technical-documentation/data-sheets/AD7785.pdf
+  https://www.analog.com/media/en/technical-documentation/data-sheets/AD7792_7793.pdf
+  https://www.analog.com/media/en/technical-documentation/data-sheets/AD7794_7795.pdf
+  https://www.analog.com/media/en/technical-documentation/data-sheets/AD7796_7797.pdf
+  https://www.analog.com/media/en/technical-documentation/data-sheets/AD7798_7799.pdf
+
+properties:
+  compatible:
+    enum:
+      - adi,ad7785
+      - adi,ad7792
+      - adi,ad7793
+      - adi,ad7794
+      - adi,ad7795
+      - adi,ad7796
+      - adi,ad7797
+      - adi,ad7798
+      - adi,ad7799
+
+  reg:
+    maxItems: 1
+
+  spi-cpol: true
+
+  spi-cpha: true
+
+  interrupts:
+    description: Interrupt connected to the DOUT/RDY pin.
+    maxItems: 1
+
+  rdy-gpios:
+    description:
+      GPIO reading the DOUT/RDY line. DOUT/RDY also toggles during SPI
+      transfers, which usually triggers spurious interrupts. Reading this GPIO
+      allows to tell those apart from real conversion done events.
+    maxItems: 1
+
+  avdd-supply: true
+
+  dvdd-supply: true
+
+  refin-supply:
+    description:
+      External reference applied between REFIN(+) and REFIN(-), or between
+      REFIN1(+) and REFIN1(-) on the AD7794 and AD7795. If present, it is used
+      as the ADC reference. If neither refin-supply nor refin2-supply are
+      present, the internal 1.17 V reference is used.
+
+  refin2-supply:
+    description:
+      External reference applied between REFIN2(+) and REFIN2(-). Used as the
+      ADC reference if refin-supply is not present.
+
+  clocks:
+    description:
+      External clock connected to the CLK pin. Either 64 kHz, or 128 kHz in
+      which case it gets divided by 2 internally. If not present, the internal
+      64 kHz clock is used.
+    maxItems: 1
+
+  bipolar:
+    description: see Documentation/devicetree/bindings/iio/adc/adc.yaml
+    type: boolean
+
+  adi,buffer-disable:
+    description:
+      Operate the analog inputs in unbuffered mode. Unbuffered mode allows the
+      inputs to go from 30 mV below GND to 30 mV above AVDD, while buffered
+      mode needs 100 mV of headroom to the supply rails but tolerates source
+      impedances in front of the inputs. Buffered mode is always used for gains
+      higher than 2.
+    type: boolean
+
+  adi,burnout-currents-enable:
+    description:
+      Enable the 100 nA burnout current sources in the signal path, which allow
+      to detect an open circuit on the selected analog input. They can only be
+      enabled when either the buffer or the in-amp is active.
+    type: boolean
+
+  adi,vbias-pin:
+    description:
+      Negative analog input (AINx(-)) to bias to AVDD / 2 with the bias voltage
+      generator.
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [ain1, ain2, ain3]
+
+  adi,vbias-boost-enable:
+    description:
+      Increase the current of the bias voltage generator, reducing its power-up
+      time.
+    type: boolean
+
+  adi,excitation-current-microamp:
+    description:
+      Enables the excitation current sources IEXC1 and IEXC2. Both are always
+      enabled together and set to this same value. Where each one is connected
+      is given by adi,excitation-pins.
+    enum: [10, 210, 1000]
+
+  adi,excitation-pins:
+    description:
+      Output pins the excitation current sources IEXC1 and IEXC2 are routed
+      to, in that order. The default routes IEXC1 to IOUT1 and IEXC2 to IOUT2.
+      Both sources can be routed to the same pin, which then outputs twice the
+      configured current. This is not allowed when
+      adi,excitation-current-microamp is 1000.
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
+    minItems: 2
+    maxItems: 2
+    items:
+      enum: [iout1, iout2]
+    default: [iout1, iout2]
+
+dependencies:
+  adi,vbias-boost-enable: [ 'adi,vbias-pin' ]
+  adi,excitation-pins: [ 'adi,excitation-current-microamp' ]
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - avdd-supply
+  - dvdd-supply
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+  - if:
+      properties:
+        adi,excitation-current-microamp:
+          const: 1000
+      required:
+        - adi,excitation-current-microamp
+    then:
+      properties:
+        adi,excitation-pins:
+          oneOf:
+            - items:
+                - const: iout1
+                - const: iout2
+            - items:
+                - const: iout2
+                - const: iout1
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad7785
+              - adi,ad7792
+              - adi,ad7793
+    then:
+      properties:
+        refin2-supply: false
+        adi,vbias-pin:
+          enum: [ain1, ain2]
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad7796
+              - adi,ad7797
+              - adi,ad7798
+              - adi,ad7799
+    then:
+      properties:
+        refin2-supply: false
+        adi,vbias-pin: false
+        adi,vbias-boost-enable: false
+        adi,excitation-current-microamp: false
+        adi,excitation-pins: false
+      required:
+        - refin-supply
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad7796
+              - adi,ad7797
+    then:
+      properties:
+        adi,buffer-disable: false
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - adi,ad7798
+              - adi,ad7799
+    then:
+      properties:
+        clocks: false
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@0 {
+            compatible = "adi,ad7793";
+            reg = <0>;
+            spi-max-frequency = <5000000>;
+            spi-cpol;
+            spi-cpha;
+            interrupts = <25 IRQ_TYPE_EDGE_FALLING>;
+            interrupt-parent = <&gpio>;
+            avdd-supply = <&avdd>;
+            dvdd-supply = <&dvdd>;
+            refin-supply = <&vref>;
+            adi,vbias-pin = "ain2";
+            adi,excitation-current-microamp = <210>;
+        };
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 658895c3b0fa..e55236f4accb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1731,6 +1731,16 @@ W:	https://ez.analog.com/linux-software-drivers
 F:	Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml
 F:	drivers/iio/adc/ad7780.c
 
+ANALOG DEVICES INC AD7793 DRIVER
+M:	Michael Hennerich <Michael.Hennerich@analog.com>
+M:	Nuno Sá <nuno.sa@analog.com>
+L:	linux-iio@vger.kernel.org
+S:	Supported
+W:	https://ez.analog.com/linux-software-drivers
+F:	Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml
+F:	drivers/iio/adc/ad7793.c
+F:	include/linux/platform_data/ad7793.h
+
 ANALOG DEVICES INC AD8366 DRIVER
 M:	Michael Hennerich <Michael.Hennerich@analog.com>
 M:	Rodrigo Alencar <rodrigo.alencar@analog.com>

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
                   ` (4 preceding siblings ...)
  2026-11-25 10:19 ` [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs Nuno Sá
@ 2026-11-25 10:19 ` Nuno Sá
  2026-11-25 10:33   ` sashiko-bot
  2026-11-25 10:43   ` Andy Shevchenko
  2026-11-25 10:36 ` [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Arnd Bergmann
  6 siblings, 2 replies; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 10:19 UTC (permalink / raw)
  To: linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Arnd Bergmann, Jonathan Cameron

The driver refuses to probe without struct ad7793_platform_data, and
there are no in-tree users of it. That means the driver can not be used
at all on a modern system.

Get the configuration from firmware properties instead, following the
new binding, and drop the platform data header:

- The reference is REFIN (REFIN1) if refin-supply is present, REFIN2 if
  refin2-supply is present, and the internal 1.17 V reference otherwise.
  Parts without an internal reference need refin-supply.
- An external clock on the CLK pin is used if given. A 128 kHz clock
  is divided by 2 internally.
- The input buffer stays enabled (as it is at power-up) unless
  adi,buffer-disable is set, and unipolar coding is used unless bipolar
  is set.
- The bias voltage generator, the burnout currents and the excitation
  current sources get their own properties.

While at it, also enable the AVDD and DVDD supplies, add an OF match
table and fold the platform data checks into the property parsing.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 MAINTAINERS                          |   1 -
 drivers/iio/adc/ad7793.c             | 315 +++++++++++++++++++++++++++++++----
 include/linux/platform_data/ad7793.h | 111 ------------
 3 files changed, 278 insertions(+), 149 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e55236f4accb..fe88746df57e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1739,7 +1739,6 @@ S:	Supported
 W:	https://ez.analog.com/linux-software-drivers
 F:	Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml
 F:	drivers/iio/adc/ad7793.c
-F:	include/linux/platform_data/ad7793.h
 
 ANALOG DEVICES INC AD8366 DRIVER
 M:	Michael Hennerich <Michael.Hennerich@analog.com>
diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index b0f44c144f20..f3e3ca724ec2 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -5,10 +5,13 @@
  * Copyright 2011-2012 Analog Devices Inc.
  */
 
+#include <linux/clk.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/property.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/sysfs.h>
 #include <linux/spi/spi.h>
 #include <linux/regulator/consumer.h>
@@ -16,6 +19,7 @@
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/units.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -24,7 +28,6 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/adc/ad_sigma_delta.h>
-#include <linux/platform_data/ad7793.h>
 
 /* Registers */
 #define AD7793_REG_COMM		0 /* Communications Register (WO, 8-bit) */
@@ -140,6 +143,107 @@
 #define AD7793_FLAG_HAS_GAIN		BIT(4)
 #define AD7793_FLAG_HAS_BUFFER		BIT(5)
 
+/**
+ * enum ad7793_clock_source - AD7793 clock source selection
+ * @AD7793_CLK_SRC_INT: Internal 64 kHz clock, not available at the CLK pin.
+ * @AD7793_CLK_SRC_INT_CO: Internal 64 kHz clock, available at the CLK pin.
+ * @AD7793_CLK_SRC_EXT: Use external clock.
+ * @AD7793_CLK_SRC_EXT_DIV2: Use external clock divided by 2.
+ */
+enum ad7793_clock_source {
+	AD7793_CLK_SRC_INT,
+	AD7793_CLK_SRC_INT_CO,
+	AD7793_CLK_SRC_EXT,
+	AD7793_CLK_SRC_EXT_DIV2,
+};
+
+/**
+ * enum ad7793_bias_voltage - AD7793 bias voltage selection
+ * @AD7793_BIAS_VOLTAGE_DISABLED: Bias voltage generator disabled
+ * @AD7793_BIAS_VOLTAGE_AIN1: Bias voltage connected to AIN1(-).
+ * @AD7793_BIAS_VOLTAGE_AIN2: Bias voltage connected to AIN2(-).
+ * @AD7793_BIAS_VOLTAGE_AIN3: Bias voltage connected to AIN3(-).
+ *	Only valid for AD7795/AD7796.
+ */
+enum ad7793_bias_voltage {
+	AD7793_BIAS_VOLTAGE_DISABLED,
+	AD7793_BIAS_VOLTAGE_AIN1,
+	AD7793_BIAS_VOLTAGE_AIN2,
+	AD7793_BIAS_VOLTAGE_AIN3,
+};
+
+/**
+ * enum ad7793_refsel - AD7793 reference voltage selection
+ * @AD7793_REFSEL_REFIN1: External reference applied between REFIN1(+)
+ *	and REFIN1(-).
+ * @AD7793_REFSEL_REFIN2: External reference applied between REFIN2(+)
+ *	and REFIN1(-). Only valid for AD7795/AD7796.
+ * @AD7793_REFSEL_INTERNAL: Internal 1.17 V reference.
+ */
+enum ad7793_refsel {
+	AD7793_REFSEL_REFIN1 = 0,
+	AD7793_REFSEL_REFIN2 = 1,
+	AD7793_REFSEL_INTERNAL = 2,
+};
+
+/**
+ * enum ad7793_current_source_direction - AD7793 excitation current direction
+ * @AD7793_IEXEC1_IOUT1_IEXEC2_IOUT2: Current source IEXC1 connected to pin
+ *	IOUT1, current source IEXC2 connected to pin IOUT2.
+ * @AD7793_IEXEC1_IOUT2_IEXEC2_IOUT1: Current source IEXC2 connected to pin
+ *	IOUT1, current source IEXC1 connected to pin IOUT2.
+ * @AD7793_IEXEC1_IEXEC2_IOUT1: Both current sources connected to pin IOUT1.
+ *	Only valid when the current sources are set to 10 uA or 210 uA.
+ * @AD7793_IEXEC1_IEXEC2_IOUT2: Both current sources connected to Pin IOUT2.
+ *	Only valid when the current ources are set to 10 uA or 210 uA.
+ */
+enum ad7793_current_source_direction {
+	AD7793_IEXEC1_IOUT1_IEXEC2_IOUT2 = 0,
+	AD7793_IEXEC1_IOUT2_IEXEC2_IOUT1 = 1,
+	AD7793_IEXEC1_IEXEC2_IOUT1 = 2,
+	AD7793_IEXEC1_IEXEC2_IOUT2 = 3,
+};
+
+/**
+ * enum ad7793_excitation_current - AD7793 excitation current selection
+ * @AD7793_IX_DISABLED: Excitation current Disabled.
+ * @AD7793_IX_10uA: Enable 10 micro-ampere excitation current.
+ * @AD7793_IX_210uA: Enable 210 micro-ampere excitation current.
+ * @AD7793_IX_1mA: Enable 1 milli-Ampere excitation current.
+ */
+enum ad7793_excitation_current {
+	AD7793_IX_DISABLED = 0,
+	AD7793_IX_10uA = 1,
+	AD7793_IX_210uA = 2,
+	AD7793_IX_1mA = 3,
+};
+
+/**
+ * struct ad7793_config - AD7793 configuration
+ * @clock_src: Clock source selection
+ * @burnout_current: If set to true the 100nA burnout current is enabled.
+ * @boost_enable: Enable boost for the bias voltage generator.
+ * @buffered: If set to true configure the device for buffered input mode.
+ * @unipolar: If set to true sample in unipolar mode, if set to false sample in
+ *		bipolar mode.
+ * @refsel: Reference voltage selection
+ * @bias_voltage: Bias voltage selection
+ * @exitation_current: Excitation current selection
+ * @current_source_direction: Excitation current direction selection
+ */
+struct ad7793_config {
+	enum ad7793_clock_source clock_src;
+	bool burnout_current;
+	bool boost_enable;
+	bool buffered;
+	bool unipolar;
+
+	enum ad7793_refsel refsel;
+	enum ad7793_bias_voltage bias_voltage;
+	enum ad7793_excitation_current exitation_current;
+	enum ad7793_current_source_direction current_source_direction;
+};
+
 struct ad7793_chip_info {
 	unsigned int id;
 	const struct iio_chan_spec *channels;
@@ -223,36 +327,36 @@ static int ad7793_calibrate_all(struct ad7793_state *st)
 				   ARRAY_SIZE(ad7793_calib_arr));
 }
 
-static int ad7793_check_platform_data(struct ad7793_state *st,
-	const struct ad7793_platform_data *pdata)
+static int ad7793_check_config(struct ad7793_state *st,
+			       const struct ad7793_config *cfg)
 {
-	if ((pdata->current_source_direction == AD7793_IEXEC1_IEXEC2_IOUT1 ||
-		pdata->current_source_direction == AD7793_IEXEC1_IEXEC2_IOUT2) &&
-		((pdata->exitation_current != AD7793_IX_10uA) &&
-		(pdata->exitation_current != AD7793_IX_210uA)))
+	if ((cfg->current_source_direction == AD7793_IEXEC1_IEXEC2_IOUT1 ||
+	     cfg->current_source_direction == AD7793_IEXEC1_IEXEC2_IOUT2) &&
+	    cfg->exitation_current != AD7793_IX_10uA &&
+	    cfg->exitation_current != AD7793_IX_210uA)
 		return -EINVAL;
 
 	if (!(st->chip_info->flags & AD7793_FLAG_HAS_CLKSEL) &&
-		pdata->clock_src != AD7793_CLK_SRC_INT)
+		cfg->clock_src != AD7793_CLK_SRC_INT)
 		return -EINVAL;
 
 	if (!(st->chip_info->flags & AD7793_FLAG_HAS_REFSEL) &&
-		pdata->refsel != AD7793_REFSEL_REFIN1)
+		cfg->refsel != AD7793_REFSEL_REFIN1)
 		return -EINVAL;
 
 	if (!(st->chip_info->flags & AD7793_FLAG_HAS_VBIAS) &&
-		pdata->bias_voltage != AD7793_BIAS_VOLTAGE_DISABLED)
+		cfg->bias_voltage != AD7793_BIAS_VOLTAGE_DISABLED)
 		return -EINVAL;
 
 	if (!(st->chip_info->flags & AD7793_HAS_EXITATION_CURRENT) &&
-		pdata->exitation_current != AD7793_IX_DISABLED)
+		cfg->exitation_current != AD7793_IX_DISABLED)
 		return -EINVAL;
 
 	return 0;
 }
 
 static int ad7793_setup(struct iio_dev *indio_dev,
-	const struct ad7793_platform_data *pdata,
+	const struct ad7793_config *cfg,
 	unsigned int vref_mv)
 {
 	struct ad7793_state *st = iio_priv(indio_dev);
@@ -260,7 +364,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
 	unsigned long long scale_uv;
 	u32 id;
 
-	ret = ad7793_check_platform_data(st, pdata);
+	ret = ad7793_check_config(st, cfg);
 	if (ret)
 		return ret;
 
@@ -292,19 +396,19 @@ static int ad7793_setup(struct iio_dev *indio_dev,
 	st->conf = 0;
 
 	if (st->chip_info->flags & AD7793_FLAG_HAS_CLKSEL)
-		st->mode |= AD7793_MODE_CLKSRC(pdata->clock_src);
+		st->mode |= AD7793_MODE_CLKSRC(cfg->clock_src);
 	if (st->chip_info->flags & AD7793_FLAG_HAS_REFSEL)
-		st->conf |= AD7793_CONF_REFSEL(pdata->refsel);
+		st->conf |= AD7793_CONF_REFSEL(cfg->refsel);
 	if (st->chip_info->flags & AD7793_FLAG_HAS_VBIAS)
-		st->conf |= AD7793_CONF_VBIAS(pdata->bias_voltage);
-	if (pdata->buffered || !(st->chip_info->flags & AD7793_FLAG_HAS_BUFFER))
+		st->conf |= AD7793_CONF_VBIAS(cfg->bias_voltage);
+	if (cfg->buffered || !(st->chip_info->flags & AD7793_FLAG_HAS_BUFFER))
 		st->conf |= AD7793_CONF_BUF;
-	if (pdata->boost_enable &&
-		(st->chip_info->flags & AD7793_FLAG_HAS_VBIAS))
+	if (cfg->boost_enable &&
+	    (st->chip_info->flags & AD7793_FLAG_HAS_VBIAS))
 		st->conf |= AD7793_CONF_BOOST;
-	if (pdata->burnout_current)
+	if (cfg->burnout_current)
 		st->conf |= AD7793_CONF_BO_EN;
-	if (pdata->unipolar)
+	if (cfg->unipolar)
 		st->conf |= AD7793_CONF_UNIPOLAR;
 
 	if (!(st->chip_info->flags & AD7793_FLAG_HAS_GAIN))
@@ -320,8 +424,8 @@ static int ad7793_setup(struct iio_dev *indio_dev,
 
 	if (st->chip_info->flags & AD7793_HAS_EXITATION_CURRENT) {
 		ret = ad_sd_write_reg(&st->sd, AD7793_REG_IO, 1,
-				pdata->exitation_current |
-				(pdata->current_source_direction << 2));
+				cfg->exitation_current |
+				(cfg->current_source_direction << 2));
 		if (ret)
 			goto out;
 	}
@@ -776,16 +880,139 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
 	},
 };
 
+static int ad7793_parse_excitation(struct device *dev,
+				   struct ad7793_config *cfg)
+{
+	static const char * const iout_pins[] = { "iout1", "iout2" };
+	u32 pins[] = { 1, 2 };
+	const char *names[2];
+	u32 val;
+	int ret;
+
+	ret = device_property_read_u32(dev, "adi,excitation-current-microamp",
+				       &val);
+	/* Excitation pins only matter if the excitation current is enabled */
+	if (ret)
+		return 0;
+
+	switch (val) {
+	case 10:
+		cfg->exitation_current = AD7793_IX_10uA;
+		break;
+	case 210:
+		cfg->exitation_current = AD7793_IX_210uA;
+		break;
+	case 1000:
+		cfg->exitation_current = AD7793_IX_1mA;
+		break;
+	default:
+		return dev_err_probe(dev, -EINVAL,
+				     "Invalid excitation current: %u\n", val);
+	}
+
+	if (device_property_present(dev, "adi,excitation-pins")) {
+		ret = device_property_read_string_array(dev,
+							"adi,excitation-pins",
+							names,
+							ARRAY_SIZE(names));
+		if (ret != ARRAY_SIZE(names))
+			return dev_err_probe(dev, ret < 0 ? ret : -EINVAL,
+					     "Invalid adi,excitation-pins\n");
+
+		/* IOUT pin number for IEXC1 and IEXC2 */
+		for (unsigned int i = 0; i < ARRAY_SIZE(names); i++) {
+			ret = match_string(iout_pins, ARRAY_SIZE(iout_pins),
+					   names[i]);
+			if (ret < 0)
+				return dev_err_probe(dev, ret,
+						     "Invalid adi,excitation-pins\n");
+
+			pins[i] = ret + 1;
+		}
+	}
+
+	if (pins[0] == 1 && pins[1] == 2)
+		cfg->current_source_direction = AD7793_IEXEC1_IOUT1_IEXEC2_IOUT2;
+	else if (pins[0] == 2 && pins[1] == 1)
+		cfg->current_source_direction = AD7793_IEXEC1_IOUT2_IEXEC2_IOUT1;
+	else if (pins[0] == 1)
+		cfg->current_source_direction = AD7793_IEXEC1_IEXEC2_IOUT1;
+	else
+		cfg->current_source_direction = AD7793_IEXEC1_IEXEC2_IOUT2;
+
+	return 0;
+}
+
+static int ad7793_parse_fw(struct device *dev, struct ad7793_config *cfg,
+			   unsigned int *vref_mv)
+{
+	static const char * const vbias_pins[] = { "ain1", "ain2", "ain3" };
+	static const char * const refin_names[] = { "refin", "refin2" };
+	unsigned long rate;
+	struct clk *clk;
+	int ret;
+
+	cfg->refsel = AD7793_REFSEL_INTERNAL;
+	for (unsigned int i = 0; i < ARRAY_SIZE(refin_names); i++) {
+		ret = devm_regulator_get_enable_read_voltage(dev, refin_names[i]);
+		if (ret < 0 && ret != -ENODEV)
+			return dev_err_probe(dev, ret, "Failed to get %s voltage\n",
+					     refin_names[i]);
+		if (ret == -ENODEV)
+			continue;
+
+		cfg->refsel = i;
+		*vref_mv = ret / 1000;
+		break;
+	}
+
+	if (cfg->refsel == AD7793_REFSEL_INTERNAL)
+		*vref_mv = 1170;
+
+	clk = devm_clk_get_optional_enabled(dev, NULL);
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "Failed to get clock\n");
+
+	if (clk) {
+		rate = clk_get_rate(clk);
+		if (rate == 64 * HZ_PER_KHZ)
+			cfg->clock_src = AD7793_CLK_SRC_EXT;
+		else if (rate == 128 * HZ_PER_KHZ)
+			cfg->clock_src = AD7793_CLK_SRC_EXT_DIV2;
+		else
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid clock rate: %lu Hz\n", rate);
+	}
+
+	if (device_property_present(dev, "adi,vbias-pin")) {
+		ret = device_property_match_property_string(dev, "adi,vbias-pin",
+							    vbias_pins,
+							    ARRAY_SIZE(vbias_pins));
+		if (ret < 0)
+			return dev_err_probe(dev, ret, "Invalid adi,vbias-pin\n");
+
+		cfg->bias_voltage = AD7793_BIAS_VOLTAGE_AIN1 + ret;
+		cfg->boost_enable = device_property_read_bool(dev,
+							      "adi,vbias-boost-enable");
+	}
+
+	cfg->burnout_current = device_property_read_bool(dev,
+							 "adi,burnout-currents-enable");
+	cfg->buffered = !device_property_read_bool(dev, "adi,buffer-disable");
+	cfg->unipolar = !device_property_read_bool(dev, "bipolar");
+
+	return ad7793_parse_excitation(dev, cfg);
+}
+
 static int ad7793_probe(struct spi_device *spi)
 {
+	static const char * const supplies[] = { "avdd", "dvdd" };
 	struct device *dev = &spi->dev;
-	const struct ad7793_platform_data *pdata = dev_get_platdata(dev);
+	struct ad7793_config cfg = { };
 	struct ad7793_state *st;
 	struct iio_dev *indio_dev;
-	int ret, vref_mv = 0;
-
-	if (!pdata)
-		return dev_err_probe(dev, -ENODEV, "no platform data?\n");
+	unsigned int vref_mv;
+	int ret;
 
 	if (!spi->irq)
 		return dev_err_probe(dev, -ENODEV, "no IRQ?\n");
@@ -798,15 +1025,14 @@ static int ad7793_probe(struct spi_device *spi)
 
 	ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
 
-	if (pdata->refsel != AD7793_REFSEL_INTERNAL) {
-		ret = devm_regulator_get_enable_read_voltage(dev, "refin");
-		if (ret < 0)
-			return ret;
+	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies),
+					     supplies);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable supplies\n");
 
-		vref_mv = ret / 1000;
-	} else {
-		vref_mv = 1170; /* Built-in ref */
-	}
+	ret = ad7793_parse_fw(dev, &cfg, &vref_mv);
+	if (ret)
+		return ret;
 
 	st->chip_info =
 		&ad7793_chip_info_tbl[spi_get_device_id(spi)->driver_data];
@@ -821,7 +1047,7 @@ static int ad7793_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	ret = ad7793_setup(indio_dev, pdata, vref_mv);
+	ret = ad7793_setup(indio_dev, &cfg, vref_mv);
 	if (ret)
 		return ret;
 
@@ -842,9 +1068,24 @@ static const struct spi_device_id ad7793_id[] = {
 };
 MODULE_DEVICE_TABLE(spi, ad7793_id);
 
+static const struct of_device_id ad7793_of_match[] = {
+	{ .compatible = "adi,ad7785", .data = &ad7793_chip_info_tbl[ID_AD7785] },
+	{ .compatible = "adi,ad7792", .data = &ad7793_chip_info_tbl[ID_AD7792] },
+	{ .compatible = "adi,ad7793", .data = &ad7793_chip_info_tbl[ID_AD7793] },
+	{ .compatible = "adi,ad7794", .data = &ad7793_chip_info_tbl[ID_AD7794] },
+	{ .compatible = "adi,ad7795", .data = &ad7793_chip_info_tbl[ID_AD7795] },
+	{ .compatible = "adi,ad7796", .data = &ad7793_chip_info_tbl[ID_AD7796] },
+	{ .compatible = "adi,ad7797", .data = &ad7793_chip_info_tbl[ID_AD7797] },
+	{ .compatible = "adi,ad7798", .data = &ad7793_chip_info_tbl[ID_AD7798] },
+	{ .compatible = "adi,ad7799", .data = &ad7793_chip_info_tbl[ID_AD7799] },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, ad7793_of_match);
+
 static struct spi_driver ad7793_driver = {
 	.driver = {
 		.name	= "ad7793",
+		.of_match_table = ad7793_of_match,
 	},
 	.probe		= ad7793_probe,
 	.id_table	= ad7793_id,
diff --git a/include/linux/platform_data/ad7793.h b/include/linux/platform_data/ad7793.h
deleted file mode 100644
index 7c697e58f02a..000000000000
--- a/include/linux/platform_data/ad7793.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AD7792/AD7793 SPI ADC driver
- *
- * Copyright 2011 Analog Devices Inc.
- */
-#ifndef __LINUX_PLATFORM_DATA_AD7793_H__
-#define __LINUX_PLATFORM_DATA_AD7793_H__
-
-/**
- * enum ad7793_clock_source - AD7793 clock source selection
- * @AD7793_CLK_SRC_INT: Internal 64 kHz clock, not available at the CLK pin.
- * @AD7793_CLK_SRC_INT_CO: Internal 64 kHz clock, available at the CLK pin.
- * @AD7793_CLK_SRC_EXT: Use external clock.
- * @AD7793_CLK_SRC_EXT_DIV2: Use external clock divided by 2.
- */
-enum ad7793_clock_source {
-	AD7793_CLK_SRC_INT,
-	AD7793_CLK_SRC_INT_CO,
-	AD7793_CLK_SRC_EXT,
-	AD7793_CLK_SRC_EXT_DIV2,
-};
-
-/**
- * enum ad7793_bias_voltage - AD7793 bias voltage selection
- * @AD7793_BIAS_VOLTAGE_DISABLED: Bias voltage generator disabled
- * @AD7793_BIAS_VOLTAGE_AIN1: Bias voltage connected to AIN1(-).
- * @AD7793_BIAS_VOLTAGE_AIN2: Bias voltage connected to AIN2(-).
- * @AD7793_BIAS_VOLTAGE_AIN3: Bias voltage connected to AIN3(-).
- *	Only valid for AD7795/AD7796.
- */
-enum ad7793_bias_voltage {
-	AD7793_BIAS_VOLTAGE_DISABLED,
-	AD7793_BIAS_VOLTAGE_AIN1,
-	AD7793_BIAS_VOLTAGE_AIN2,
-	AD7793_BIAS_VOLTAGE_AIN3,
-};
-
-/**
- * enum ad7793_refsel - AD7793 reference voltage selection
- * @AD7793_REFSEL_REFIN1: External reference applied between REFIN1(+)
- *	and REFIN1(-).
- * @AD7793_REFSEL_REFIN2: External reference applied between REFIN2(+)
- *	and REFIN1(-). Only valid for AD7795/AD7796.
- * @AD7793_REFSEL_INTERNAL: Internal 1.17 V reference.
- */
-enum ad7793_refsel {
-	AD7793_REFSEL_REFIN1 = 0,
-	AD7793_REFSEL_REFIN2 = 1,
-	AD7793_REFSEL_INTERNAL = 2,
-};
-
-/**
- * enum ad7793_current_source_direction - AD7793 excitation current direction
- * @AD7793_IEXEC1_IOUT1_IEXEC2_IOUT2: Current source IEXC1 connected to pin
- *	IOUT1, current source IEXC2 connected to pin IOUT2.
- * @AD7793_IEXEC1_IOUT2_IEXEC2_IOUT1: Current source IEXC2 connected to pin
- *	IOUT1, current source IEXC1 connected to pin IOUT2.
- * @AD7793_IEXEC1_IEXEC2_IOUT1: Both current sources connected to pin IOUT1.
- *	Only valid when the current sources are set to 10 uA or 210 uA.
- * @AD7793_IEXEC1_IEXEC2_IOUT2: Both current sources connected to Pin IOUT2.
- *	Only valid when the current ources are set to 10 uA or 210 uA.
- */
-enum ad7793_current_source_direction {
-	AD7793_IEXEC1_IOUT1_IEXEC2_IOUT2 = 0,
-	AD7793_IEXEC1_IOUT2_IEXEC2_IOUT1 = 1,
-	AD7793_IEXEC1_IEXEC2_IOUT1 = 2,
-	AD7793_IEXEC1_IEXEC2_IOUT2 = 3,
-};
-
-/**
- * enum ad7793_excitation_current - AD7793 excitation current selection
- * @AD7793_IX_DISABLED: Excitation current Disabled.
- * @AD7793_IX_10uA: Enable 10 micro-ampere excitation current.
- * @AD7793_IX_210uA: Enable 210 micro-ampere excitation current.
- * @AD7793_IX_1mA: Enable 1 milli-Ampere excitation current.
- */
-enum ad7793_excitation_current {
-	AD7793_IX_DISABLED = 0,
-	AD7793_IX_10uA = 1,
-	AD7793_IX_210uA = 2,
-	AD7793_IX_1mA = 3,
-};
-
-/**
- * struct ad7793_platform_data - AD7793 platform data
- * @clock_src: Clock source selection
- * @burnout_current: If set to true the 100nA burnout current is enabled.
- * @boost_enable: Enable boost for the bias voltage generator.
- * @buffered: If set to true configure the device for buffered input mode.
- * @unipolar: If set to true sample in unipolar mode, if set to false sample in
- *		bipolar mode.
- * @refsel: Reference voltage selection
- * @bias_voltage: Bias voltage selection
- * @exitation_current: Excitation current selection
- * @current_source_direction: Excitation current direction selection
- */
-struct ad7793_platform_data {
-	enum ad7793_clock_source clock_src;
-	bool burnout_current;
-	bool boost_enable;
-	bool buffered;
-	bool unipolar;
-
-	enum ad7793_refsel refsel;
-	enum ad7793_bias_voltage bias_voltage;
-	enum ad7793_excitation_current exitation_current;
-	enum ad7793_current_source_direction current_source_direction;
-};
-
-#endif /* IIO_ADC_AD7793_H_ */

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic
  2026-11-25 10:19 ` [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic Nuno Sá
@ 2026-11-25 10:25   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-25 10:25 UTC (permalink / raw)
  To: Nuno Sá, devicetree; +Cc: robh, conor+dt

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] iio: adc: ad7887: wrong rx_buf offset for CH1 in ad7887_probe()
  [1]
--

commit e57544891ed7d42b994441cf2725e2d373e5b02b
Author: Nuno Sá <nuno.sa@analog.com>

iio: adc: ad7887: fix on-chip reference enable logic

This commit fixes the AD7887_REF_DIS condition in ad7887_probe() so the
on-chip 2.5 V reference is disabled only when an external vref regulator is
present.

> diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
> index 827d0c2598ba6..980e6a3030479 100644
> --- a/drivers/iio/adc/ad7887.c
> +++ b/drivers/iio/adc/ad7887.c
> @@ -271,7 +271,7 @@ static int ad7887_probe(struct spi_device *spi)
>  	/* Setup default message */
>  
>  	mode = AD7887_PM_MODE4;
> -	if (!st->reg)
> +	if (st->reg)
>  		mode |= AD7887_REF_DIS;
>  	if (pdata && pdata->en_dual)
>  		mode |= AD7887_DUAL;

[Severity: High]
This problem wasn't introduced by this patch, but in dual-channel mode does
st->xfer[3].rx_buf point to the wrong offset in st->data [1]?

drivers/iio/adc/ad7887.c:ad7887_probe() {
    ...
	if (pdata && pdata->en_dual) {
		...
		st->xfer[3].rx_buf = &st->data[1];
		st->xfer[3].tx_buf = &st->tx_cmd_buf[2];
		st->xfer[3].len = 2;

		spi_message_init(&st->msg[AD7887_CH1]);
		spi_message_add_tail(&st->xfer[3], &st->msg[AD7887_CH1]);
    ...
}

Because indio_dev->available_scan_masks is not set, IIO buffer demuxing is
not used and a single active channel sample must be placed at &st->data[0].
When buffered capture is enabled with only channel 1 active,
ad7887_ring_preenable() selects st->msg[AD7887_CH1], so
ad7887_trigger_handler() writes the conversion result to &st->data[1] while
iio_push_to_buffers_with_timestamp() pushes the stale or zero sample at
&st->data[0] to userspace.

[1] https://sashiko.dev/#/bug/linux-f8b2934e-4d1f-49d5-b745-1e7bf0447de1

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-iio-adi-legacy-platdata-v1-0-54e4c8830b57@analog.com?part=1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs
  2026-11-25 10:19 ` [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs Nuno Sá
@ 2026-11-25 10:28   ` sashiko-bot
  0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-25 10:28 UTC (permalink / raw)
  To: Nuno Sá, devicetree; +Cc: robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: iio: adc: interrupts listed before clocks in
  adi,ad7793.yaml
--

commit a644054890dbc9f4a727627a933313f4001d68f3
Author: Nuno Sá <nuno.sa@analog.com>

dt-bindings: iio: adc: add AD7793 and similar ADCs

This commit adds a Device Tree binding schema and MAINTAINERS entry for the
Analog Devices AD7793 and related sigma-delta ADCs.

> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml
> new file mode 100644
> index 0000000000000..c4a0be06e5c0d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7793.yaml
> @@ -0,0 +1,236 @@

[ ... ]

> +  interrupts:
> +    description: Interrupt connected to the DOUT/RDY pin.
> +    maxItems: 1
> +
> +  rdy-gpios:
> +    description:
> +      GPIO reading the DOUT/RDY line. DOUT/RDY also toggles during SPI
> +      transfers, which usually triggers spurious interrupts. Reading this GPIO
> +      allows to tell those apart from real conversion done events.
> +    maxItems: 1
> +
> +  avdd-supply: true
> +
> +  dvdd-supply: true
> +
> +  refin-supply:
> +    description:
> +      External reference applied between REFIN(+) and REFIN(-), or between
> +      REFIN1(+) and REFIN1(-) on the AD7794 and AD7795. If present, it is used
> +      as the ADC reference. If neither refin-supply nor refin2-supply are
> +      present, the internal 1.17 V reference is used.
> +
> +  refin2-supply:
> +    description:
> +      External reference applied between REFIN2(+) and REFIN2(-). Used as the
> +      ADC reference if refin-supply is not present.
> +
> +  clocks:
> +    description:
> +      External clock connected to the CLK pin. Either 64 kHz, or 128 kHz in
> +      which case it gets divided by 2 internally. If not present, the internal
> +      64 kHz clock is used.
> +    maxItems: 1

[Severity: Low]
This isn't a bug, but in the canonical DT schema property order, clocks
comes before interrupts.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-iio-adi-legacy-platdata-v1-0-54e4c8830b57@analog.com?part=5

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data
  2026-11-25 10:19 ` [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data Nuno Sá
@ 2026-11-25 10:33   ` sashiko-bot
  2026-11-25 10:43   ` Andy Shevchenko
  1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-25 10:33 UTC (permalink / raw)
  To: Nuno Sá, devicetree; +Cc: robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] iio: adc: ad7793: unused OF match data and NULL deref in
  ad7793_probe()
--

commit dd1daa501ec1006036cacb4fca5f16bb30f78354
Author: Nuno Sá <nuno.sa@analog.com>

iio: adc: ad7793: add firmware support and drop platform data

This commit replaces ad7793_platform_data with firmware property parsing,
enables the AVDD/DVDD supplies, and adds an OF match table.

> diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> index b0f44c144f20e..f3e3ca724ec2c 100644
> --- a/drivers/iio/adc/ad7793.c
> +++ b/drivers/iio/adc/ad7793.c

[ ... ]

> @@ -798,15 +1025,14 @@ static int ad7793_probe(struct spi_device *spi)
>  
>  	ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info);
>  
> -	if (pdata->refsel != AD7793_REFSEL_INTERNAL) {
> -		ret = devm_regulator_get_enable_read_voltage(dev, "refin");
> -		if (ret < 0)
> -			return ret;
> +	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies),
> +					     supplies);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to enable supplies\n");
>  
> -		vref_mv = ret / 1000;
> -	} else {
> -		vref_mv = 1170; /* Built-in ref */
> -	}
> +	ret = ad7793_parse_fw(dev, &cfg, &vref_mv);
> +	if (ret)
> +		return ret;
>  
>  	st->chip_info =
>  		&ad7793_chip_info_tbl[spi_get_device_id(spi)->driver_data];

[ ... ]

> @@ -842,9 +1068,24 @@ static const struct spi_device_id ad7793_id[] = {
>  };
>  MODULE_DEVICE_TABLE(spi, ad7793_id);
>  
> +static const struct of_device_id ad7793_of_match[] = {
> +	{ .compatible = "adi,ad7785", .data = &ad7793_chip_info_tbl[ID_AD7785] },
> +	{ .compatible = "adi,ad7792", .data = &ad7793_chip_info_tbl[ID_AD7792] },
> +	{ .compatible = "adi,ad7793", .data = &ad7793_chip_info_tbl[ID_AD7793] },
> +	{ .compatible = "adi,ad7794", .data = &ad7793_chip_info_tbl[ID_AD7794] },
> +	{ .compatible = "adi,ad7795", .data = &ad7793_chip_info_tbl[ID_AD7795] },
> +	{ .compatible = "adi,ad7796", .data = &ad7793_chip_info_tbl[ID_AD7796] },
> +	{ .compatible = "adi,ad7797", .data = &ad7793_chip_info_tbl[ID_AD7797] },
> +	{ .compatible = "adi,ad7798", .data = &ad7793_chip_info_tbl[ID_AD7798] },
> +	{ .compatible = "adi,ad7799", .data = &ad7793_chip_info_tbl[ID_AD7799] },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, ad7793_of_match);

[Severity: High]
Can ad7793_probe() dereference NULL when a device matches via
ad7793_of_match?

ad7793_of_match stores struct ad7793_chip_info pointers in .data, while
ad7793_id stores enum indices in .driver_data, and ad7793_probe() still
looks up st->chip_info and indio_dev->name by unconditionally
dereferencing spi_get_device_id(spi).  If a device matches through
ad7793_of_match without a matching spi->modalias in ad7793_id (such as via
ACPI PRP0001 or a fallback compatible string), spi_get_device_id(spi)
returns NULL and crashes in ad7793_probe().

Should ad7793_id also point to ad7793_chip_info_tbl entries (with the chip
name stored in struct ad7793_chip_info) so ad7793_probe() can use
spi_get_device_match_data(spi)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-iio-adi-legacy-platdata-v1-0-54e4c8830b57@analog.com?part=6

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers
  2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
                   ` (5 preceding siblings ...)
  2026-11-25 10:19 ` [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data Nuno Sá
@ 2026-11-25 10:36 ` Arnd Bergmann
  2026-11-25 11:01   ` Nuno Sá
  6 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2026-11-25 10:36 UTC (permalink / raw)
  To: Nuno Sá, linux-iio, linux-kernel, devicetree
  Cc: linux, Michael Hennerich, Jonathan Cameron, David Lechner,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley

On Wed, Nov 25, 2026, at 11:19, Nuno Sá wrote:
> The ad7266, ad7887, ad7791 and ad7793 drivers can still only be
> configured through platform data headers, and nothing in tree uses them
> anymore. This series removes them.

As far as I can tell, there have never been any upstream users
of the platform data for any of these drivers.

> The ad7266, ad7887 and ad7791 drivers already work without platform
> data, so the headers are just dropped and the drivers keep the
> configuration they use today when no platform data is given. The
> ad7793 driver refuses to probe without platform data, so it gets a
> binding and firmware properties instead.
>
> Patch 1 fixes an issue in ad7887 found while looking at the driver: the
> on-chip reference gets disabled exactly when the driver relies on it.
>
> For ad7266 and ad7887, the code for the modes that could only be
> selected through platform data (address GPIOs, other sample modes and
> input range on ad7266, dual channel mode on ad7887) is kept, so that
> someone needing it can easily add firmware properties for it. I'm likely
> being optimistic and odds are it will be just dead code so I'm glad to
> drop all of it if that's the feedback I get.

The patches all look good to me, thanks for cleaning these up!

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] iio: adc: ad7791: drop platform data support
  2026-11-25 10:19 ` [PATCH 4/6] iio: adc: ad7791: " Nuno Sá
@ 2026-11-25 10:40   ` Andy Shevchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-11-25 10:40 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-iio, linux-kernel, devicetree, linux, Michael Hennerich,
	Jonathan Cameron, David Lechner, Andy Shevchenko, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann

On Wed, Nov 25, 2026 at 10:19:20AM +0000, Nuno Sá wrote:
> There are no in-tree users of struct ad7791_platform_data. Without it,
> the driver already keeps the power-on reset configuration: buffered
> mode (on parts that have a buffer), bipolar mode and no burnout
> current.
> 
> Drop the platform data header together with the code applying it. As a
> result, ad7791_setup() can no longer fail, so make it return void.

I would move 'a' to the next line.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data
  2026-11-25 10:19 ` [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data Nuno Sá
  2026-11-25 10:33   ` sashiko-bot
@ 2026-11-25 10:43   ` Andy Shevchenko
  1 sibling, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-11-25 10:43 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-iio, linux-kernel, devicetree, linux, Michael Hennerich,
	Jonathan Cameron, David Lechner, Andy Shevchenko, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Arnd Bergmann

On Wed, Nov 25, 2026 at 10:19:22AM +0000, Nuno Sá wrote:
> The driver refuses to probe without struct ad7793_platform_data, and
> there are no in-tree users of it. That means the driver can not be used
> at all on a modern system.
> 
> Get the configuration from firmware properties instead, following the
> new binding, and drop the platform data header:
> 
> - The reference is REFIN (REFIN1) if refin-supply is present, REFIN2 if
>   refin2-supply is present, and the internal 1.17 V reference otherwise.
>   Parts without an internal reference need refin-supply.
> - An external clock on the CLK pin is used if given. A 128 kHz clock
>   is divided by 2 internally.
> - The input buffer stays enabled (as it is at power-up) unless
>   adi,buffer-disable is set, and unipolar coding is used unless bipolar
>   is set.
> - The bias voltage generator, the burnout currents and the excitation
>   current sources get their own properties.
> 
> While at it, also enable the AVDD and DVDD supplies, add an OF match
> table and fold the platform data checks into the property parsing.

First of all, can this be split to a few smaller changes?
I will look at the rest later on.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers
  2026-11-25 10:36 ` [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Arnd Bergmann
@ 2026-11-25 11:01   ` Nuno Sá
  0 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá @ 2026-11-25 11:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-iio, linux-kernel, devicetree, linux, Michael Hennerich,
	Jonathan Cameron, David Lechner, Andy Shevchenko, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley

On Wed, Nov 25, 2026 at 11:36:02AM +0100, Arnd Bergmann wrote:
> On Wed, Nov 25, 2026, at 11:19, Nuno Sá wrote:
> > The ad7266, ad7887, ad7791 and ad7793 drivers can still only be
> > configured through platform data headers, and nothing in tree uses them
> > anymore. This series removes them.
> 
> As far as I can tell, there have never been any upstream users
> of the platform data for any of these drivers.
> 
> > The ad7266, ad7887 and ad7791 drivers already work without platform
> > data, so the headers are just dropped and the drivers keep the
> > configuration they use today when no platform data is given. The
> > ad7793 driver refuses to probe without platform data, so it gets a
> > binding and firmware properties instead.
> >
> > Patch 1 fixes an issue in ad7887 found while looking at the driver: the
> > on-chip reference gets disabled exactly when the driver relies on it.
> >
> > For ad7266 and ad7887, the code for the modes that could only be
> > selected through platform data (address GPIOs, other sample modes and
> > input range on ad7266, dual channel mode on ad7887) is kept, so that
> > someone needing it can easily add firmware properties for it. I'm likely
> > being optimistic and odds are it will be just dead code so I'm glad to
> > drop all of it if that's the feedback I get.
> 
> The patches all look good to me, thanks for cleaning these up!

Sure! For IIO the one missing is ad9523 and that one we still internally
have users for it and deserves a series of it's own. Will try to send it
by the end of the week.

- Nuno Sá

> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-11-25 11:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 10:19 [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Nuno Sá
2026-11-25 10:19 ` [PATCH 1/6] iio: adc: ad7887: fix on-chip reference enable logic Nuno Sá
2026-11-25 10:25   ` sashiko-bot
2026-11-25 10:19 ` [PATCH 2/6] iio: adc: ad7887: drop platform data support Nuno Sá
2026-11-25 10:19 ` [PATCH 3/6] iio: adc: ad7266: " Nuno Sá
2026-11-25 10:19 ` [PATCH 4/6] iio: adc: ad7791: " Nuno Sá
2026-11-25 10:40   ` Andy Shevchenko
2026-11-25 10:19 ` [PATCH 5/6] dt-bindings: iio: adc: add AD7793 and similar ADCs Nuno Sá
2026-11-25 10:28   ` sashiko-bot
2026-11-25 10:19 ` [PATCH 6/6] iio: adc: ad7793: add firmware support and drop platform data Nuno Sá
2026-11-25 10:33   ` sashiko-bot
2026-11-25 10:43   ` Andy Shevchenko
2026-11-25 10:36 ` [PATCH 0/6] iio: adc: drop platform data from some ADI ADC drivers Arnd Bergmann
2026-11-25 11:01   ` Nuno Sá

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox