Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246
@ 2026-11-16 22:59 Joseph Telaak
  2026-11-16 22:59 ` [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Joseph Telaak @ 2026-11-16 22:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Joseph Telaak
  Cc: linux-iio, linux-kernel, linux, devicetree

The AD5246 is a 128-position I2C rheostat that speaks the MCP4017/18/19
protocol. This series adds it to the mcp4018 driver, so it can be an IIO
channel provider for an in-kernel consumer, here one that sets a fan's
speed through the channel.

Patch 1 moves the out_resistance*_raw_available ABI to the generic file,
patch 2 reports the wiper range, patch 3 adds the binding, patch 4 turns
on the vdd supply, and patch 5 adds the parts.

---
Joseph Telaak (5):
      iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio
      iio: potentiometer: mcp4018: Report the available wiper positions
      dt-bindings: iio: potentiometer: Add Analog Devices AD5246
      iio: potentiometer: mcp4018: Turn on the vdd supply
      iio: potentiometer: mcp4018: Add Analog Devices AD5246

 Documentation/ABI/testing/sysfs-bus-iio            |  9 ++++
 .../testing/sysfs-bus-iio-potentiometer-mcp4531    |  8 ---
 .../bindings/iio/potentiometer/adi,ad5246.yaml     | 54 ++++++++++++++++++++
 MAINTAINERS                                        |  2 +-
 drivers/iio/potentiometer/Kconfig                  |  6 +--
 drivers/iio/potentiometer/mcp4018.c                | 59 +++++++++++++++++++---
 6 files changed, 120 insertions(+), 18 deletions(-)
---
base-commit: 94921bc9eb214f838481faa847cda5c42e486013
change-id: 20261116-iio-ad5246-8d4377128747

Best regards,
--  
Joseph Telaak <joseph@telaak.dev>


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

* [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio
  2026-11-16 22:59 [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-16 22:59 ` Joseph Telaak
  2026-11-17  8:10   ` Andy Shevchenko
  2026-11-16 22:59 ` [PATCH 2/5] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Joseph Telaak @ 2026-11-16 22:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Joseph Telaak
  Cc: linux-iio, linux-kernel, linux, devicetree

The available raw values of a resistance output were documented only
for the mcp4531, without the channel index. ds1803, mcp4531, tpl0102
and x9250 all report them, and indexed channels name the attribute
out_resistanceY_raw_available. Document both forms with the other
generic resistance attributes and drop the driver-specific file.

Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
 Documentation/ABI/testing/sysfs-bus-iio                       | 9 +++++++++
 Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 | 8 --------
 MAINTAINERS                                                   | 1 -
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 5e987c502b13..28ce219caf81 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -2017,6 +2017,15 @@ Description:
 		Raw (unscaled no offset etc.) resistance reading.
 		Units after application of scale and offset are ohms.
 
+What:		/sys/bus/iio/devices/iio:deviceX/out_resistance_raw_available
+What:		/sys/bus/iio/devices/iio:deviceX/out_resistanceY_raw_available
+KernelVersion:	4.9
+Contact:	linux-iio@vger.kernel.org
+Description:
+		The range of available raw values, as the minimum value, the
+		step and the maximum value, all enclosed in square brackets.
+		Example: [0 1 256]
+
 What:		/sys/bus/iio/devices/iio:deviceX/in_coverageY_raw
 KernelVersion:	7.2
 Contact:	linux-iio@vger.kernel.org
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 b/Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531
deleted file mode 100644
index 2a91fbe394fc..000000000000
--- a/Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531
+++ /dev/null
@@ -1,8 +0,0 @@
-What:		/sys/bus/iio/devices/iio:deviceX/out_resistance_raw_available
-Date:		October 2016
-KernelVersion:	4.9
-Contact:	Peter Rosin <peda@axentia.se>
-Description:
-		The range of available values represented as the minimum value,
-		the step and the maximum value, all enclosed in square brackets.
-		Example: [0 1 256]
diff --git a/MAINTAINERS b/MAINTAINERS
index 02015eaec312..9cb91ee8a56d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16680,7 +16680,6 @@ MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS
 M:	Peter Rosin <peda@lysator.liu.se>
 L:	linux-iio@vger.kernel.org
 S:	Maintained
-F:	Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531
 F:	drivers/iio/potentiometer/mcp4018.c
 F:	drivers/iio/potentiometer/mcp4531.c
 

-- 
Git-155)


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

* [PATCH 2/5] iio: potentiometer: mcp4018: Report the available wiper positions
  2026-11-16 22:59 [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
  2026-11-16 22:59 ` [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
@ 2026-11-16 22:59 ` Joseph Telaak
  2026-11-17  8:13   ` Andy Shevchenko
  2026-11-16 22:59 ` [PATCH 3/5] dt-bindings: iio: potentiometer: Add Analog Devices AD5246 Joseph Telaak
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Joseph Telaak @ 2026-11-16 22:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Joseph Telaak
  Cc: linux-iio, linux-kernel, linux, devicetree

Implement read_avail for the raw value, as ds1803, mcp4531, tpl0102 and
x9250 already do. User space then sees out_resistance0_raw_available,
and an in-kernel consumer can learn the wiper range with
iio_read_max_channel_raw() instead of hardcoding it.

Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
 drivers/iio/potentiometer/mcp4018.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index b10b4b920dc0..53471bd24640 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -49,9 +49,12 @@ static const struct iio_chan_spec mcp4018_channel = {
 	.output = 1,
 	.channel = 0,
 	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+	.info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW),
 	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
 };
 
+static const int mcp4018_wiper_avail[] = { 0, 1, MCP4018_WIPER_MAX };
+
 static int mcp4018_read_raw(struct iio_dev *indio_dev,
 			    struct iio_chan_spec const *chan,
 			    int *val, int *val2, long mask)
@@ -93,9 +96,26 @@ static int mcp4018_write_raw(struct iio_dev *indio_dev,
 	return i2c_smbus_write_byte(data->client, val);
 }
 
+static int mcp4018_read_avail(struct iio_dev *indio_dev,
+			      struct iio_chan_spec const *chan,
+			      const int **vals, int *type, int *length,
+			      long mask)
+{
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		*vals = mcp4018_wiper_avail;
+		*type = IIO_VAL_INT;
+		*length = ARRAY_SIZE(mcp4018_wiper_avail);
+		return IIO_AVAIL_RANGE;
+	default:
+		return -EINVAL;
+	}
+}
+
 static const struct iio_info mcp4018_info = {
 	.read_raw = mcp4018_read_raw,
 	.write_raw = mcp4018_write_raw,
+	.read_avail = mcp4018_read_avail,
 };
 
 #define MCP4018_ID_TABLE(_name, cfg) {				\

-- 
Git-155)


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

* [PATCH 3/5] dt-bindings: iio: potentiometer: Add Analog Devices AD5246
  2026-11-16 22:59 [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
  2026-11-16 22:59 ` [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
  2026-11-16 22:59 ` [PATCH 2/5] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
@ 2026-11-16 22:59 ` Joseph Telaak
  2026-11-16 22:59 ` [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply Joseph Telaak
  2026-11-16 22:59 ` [PATCH 5/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
  4 siblings, 0 replies; 12+ messages in thread
From: Joseph Telaak @ 2026-11-16 22:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Joseph Telaak
  Cc: linux-iio, linux-kernel, linux, devicetree

The AD5246 is a 128-position digital rheostat on I2C, in 5, 10, 50 and
100 kOhm versions. The compatible names the resistance in kOhm, as for
the AD5272. It uses the same protocol as the MCP4017/18/19, and the
mcp4018 driver supports it, so list the binding with that driver in
MAINTAINERS.

It gets its own binding rather than a trivial-devices entry so that it
can describe its supply and be an IIO channel provider
(#io-channel-cells) for a consumer such as dpot-dac. There is no
fallback to the MCP4017 compatibles: its resistance step is 1/128 of
the end-to-end value, not 1/127.

Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
 .../bindings/iio/potentiometer/adi,ad5246.yaml     | 54 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 55 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246.yaml b/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246.yaml
new file mode 100644
index 000000000000..a6642746f002
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246.yaml
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/potentiometer/adi,ad5246.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD5246 digital rheostat
+
+maintainers:
+  - Joseph Telaak <joseph@telaak.dev>
+
+description: |
+  128-position digital rheostat with an I2C interface. The compatible
+  names the end-to-end resistance in kOhm.
+
+  Datasheet: https://www.analog.com/en/products/ad5246.html
+
+properties:
+  compatible:
+    enum:
+      - adi,ad5246-005
+      - adi,ad5246-010
+      - adi,ad5246-050
+      - adi,ad5246-100
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  "#io-channel-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        potentiometer@2e {
+            compatible = "adi,ad5246-010";
+            reg = <0x2e>;
+            vdd-supply = <&reg_3v3>;
+            #io-channel-cells = <0>;
+        };
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 9cb91ee8a56d..81069fdbd778 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16680,6 +16680,7 @@ MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS
 M:	Peter Rosin <peda@lysator.liu.se>
 L:	linux-iio@vger.kernel.org
 S:	Maintained
+F:	Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246.yaml
 F:	drivers/iio/potentiometer/mcp4018.c
 F:	drivers/iio/potentiometer/mcp4531.c
 

-- 
Git-155)


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

* [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply
  2026-11-16 22:59 [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
                   ` (2 preceding siblings ...)
  2026-11-16 22:59 ` [PATCH 3/5] dt-bindings: iio: potentiometer: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-16 22:59 ` Joseph Telaak
  2026-11-17  8:16   ` Andy Shevchenko
  2026-11-16 22:59 ` [PATCH 5/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
  4 siblings, 1 reply; 12+ messages in thread
From: Joseph Telaak @ 2026-11-16 22:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Joseph Telaak
  Cc: linux-iio, linux-kernel, linux, devicetree

Get and enable the vdd supply at probe, so a board that switches the
potentiometer's supply gets it powered before the wiper is used. On
boards that describe no supply, this gets the dummy regulator.

Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
 drivers/iio/potentiometer/mcp4018.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index 53471bd24640..0d80bdfdf243 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -17,6 +17,7 @@
 #include <linux/iio/iio.h>
 #include <linux/module.h>
 #include <linux/property.h>
+#include <linux/regulator/consumer.h>
 
 #define MCP4018_WIPER_MAX 127
 
@@ -167,6 +168,7 @@ static int mcp4018_probe(struct i2c_client *client)
 	struct device *dev = &client->dev;
 	struct mcp4018_data *data;
 	struct iio_dev *indio_dev;
+	int ret;
 
 	if (!i2c_check_functionality(client->adapter,
 				     I2C_FUNC_SMBUS_BYTE)) {
@@ -174,6 +176,10 @@ static int mcp4018_probe(struct i2c_client *client)
 		return -EOPNOTSUPP;
 	}
 
+	ret = devm_regulator_get_enable(dev, "vdd");
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to enable vdd supply\n");
+
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
 	if (!indio_dev)
 		return -ENOMEM;

-- 
Git-155)


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

* [PATCH 5/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246
  2026-11-16 22:59 [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
                   ` (3 preceding siblings ...)
  2026-11-16 22:59 ` [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply Joseph Telaak
@ 2026-11-16 22:59 ` Joseph Telaak
  2026-11-17  8:27   ` Andy Shevchenko
  4 siblings, 1 reply; 12+ messages in thread
From: Joseph Telaak @ 2026-11-16 22:59 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Joseph Telaak
  Cc: linux-iio, linux-kernel, linux, devicetree

The AD5246 is a 128-position digital rheostat with the same I2C
interface as the MCP4017/18/19: a single data byte writes the 7-bit
wiper and a single-byte read returns it, with no command byte. Add its
four resistance options.

Its resistance is D/128 of the end-to-end value, where the MCP401x's is
D/127, so the scale divisor moves into the per-part config.

The misc ad525x_dpot driver also knows the AD5246, by I2C id only and
through its own sysfs files. It can't provide an IIO channel, which a
consumer such as dpot-dac needs. The AD5272 is likewise in both drivers.

Tested on an AD5246 at 0x2e that sets a fan's speed, described as
adi,ad5246-010 with a vdd-supply. It probes, out_resistance0_raw_available
reads [0 1 127] and out_resistance_scale reads 78.125000000. Raw writes
of 0, 64, 100 and 127 read back the same value, and 128 is rejected.
Writes through iio_write_channel_raw() from an in-kernel consumer of the
channel read back as well (127, 38, 0 and 76).

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5246.pdf
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
 drivers/iio/potentiometer/Kconfig   |  6 +++---
 drivers/iio/potentiometer/mcp4018.c | 33 +++++++++++++++++++++++++++------
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig
index e6a9a3c67845..7945c75f06da 100644
--- a/drivers/iio/potentiometer/Kconfig
+++ b/drivers/iio/potentiometer/Kconfig
@@ -70,12 +70,12 @@ config MAX5487
 	  module will be called max5487.
 
 config MCP4018
-	tristate "Microchip MCP4017/18/19 Digital Potentiometer driver"
+	tristate "Microchip MCP4017/18/19 and Analog Devices AD5246 Digital Potentiometer driver"
 	depends on I2C
 	help
 	  Say yes here to build support for the Microchip
-	  MCP4017, MCP4018, MCP4019
-	  digital potentiometer chips.
+	  MCP4017, MCP4018, MCP4019 digital potentiometer chips
+	  and the Analog Devices AD5246 digital rheostat.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called mcp4018.
diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index 0d80bdfdf243..1368d7cfa5b0 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -5,11 +5,13 @@
  * Author: Peter Rosin <peda@axentia.se>
  *
  * Datasheet: http://www.microchip.com/downloads/en/DeviceDoc/22147a.pdf
+ * Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5246.pdf
  *
  * DEVID	#Wipers	#Positions	Resistor Opts (kOhm)
  * mcp4017	1	128		5, 10, 50, 100
  * mcp4018	1	128		5, 10, 50, 100
  * mcp4019	1	128		5, 10, 50, 100
+ * ad5246	1	128		5, 10, 50, 100
  */
 
 #include <linux/err.h>
@@ -23,6 +25,8 @@
 
 struct mcp4018_cfg {
 	int kohms;
+	/* Wiper position divisor: R = raw * kohms / div. */
+	int div;
 };
 
 enum mcp4018_type {
@@ -30,13 +34,22 @@ enum mcp4018_type {
 	MCP4018_103,
 	MCP4018_503,
 	MCP4018_104,
+	AD5246_005,
+	AD5246_010,
+	AD5246_050,
+	AD5246_100,
 };
 
 static const struct mcp4018_cfg mcp4018_cfg[] = {
-	[MCP4018_502] = { .kohms =   5, },
-	[MCP4018_103] = { .kohms =  10, },
-	[MCP4018_503] = { .kohms =  50, },
-	[MCP4018_104] = { .kohms = 100, },
+	[MCP4018_502] = { .kohms =   5, .div = MCP4018_WIPER_MAX, },
+	[MCP4018_103] = { .kohms =  10, .div = MCP4018_WIPER_MAX, },
+	[MCP4018_503] = { .kohms =  50, .div = MCP4018_WIPER_MAX, },
+	[MCP4018_104] = { .kohms = 100, .div = MCP4018_WIPER_MAX, },
+	/* The AD5246's resistance is D / 128 of the end-to-end value. */
+	[AD5246_005] = { .kohms =   5, .div = 128, },
+	[AD5246_010] = { .kohms =  10, .div = 128, },
+	[AD5246_050] = { .kohms =  50, .div = 128, },
+	[AD5246_100] = { .kohms = 100, .div = 128, },
 };
 
 struct mcp4018_data {
@@ -72,7 +85,7 @@ static int mcp4018_read_raw(struct iio_dev *indio_dev,
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
 		*val = 1000 * data->cfg->kohms;
-		*val2 = MCP4018_WIPER_MAX;
+		*val2 = data->cfg->div;
 		return IIO_VAL_FRACTIONAL;
 	}
 
@@ -125,6 +138,10 @@ static const struct iio_info mcp4018_info = {
 }
 
 static const struct i2c_device_id mcp4018_id[] = {
+	MCP4018_ID_TABLE("ad5246-005", AD5246_005),
+	MCP4018_ID_TABLE("ad5246-010", AD5246_010),
+	MCP4018_ID_TABLE("ad5246-050", AD5246_050),
+	MCP4018_ID_TABLE("ad5246-100", AD5246_100),
 	MCP4018_ID_TABLE("mcp4017-502", MCP4018_502),
 	MCP4018_ID_TABLE("mcp4017-103", MCP4018_103),
 	MCP4018_ID_TABLE("mcp4017-503", MCP4018_503),
@@ -147,6 +164,10 @@ MODULE_DEVICE_TABLE(i2c, mcp4018_id);
 }
 
 static const struct of_device_id mcp4018_of_match[] = {
+	MCP4018_COMPATIBLE("adi,ad5246-005", AD5246_005),
+	MCP4018_COMPATIBLE("adi,ad5246-010", AD5246_010),
+	MCP4018_COMPATIBLE("adi,ad5246-050", AD5246_050),
+	MCP4018_COMPATIBLE("adi,ad5246-100", AD5246_100),
 	MCP4018_COMPATIBLE("microchip,mcp4017-502", MCP4018_502),
 	MCP4018_COMPATIBLE("microchip,mcp4017-103", MCP4018_103),
 	MCP4018_COMPATIBLE("microchip,mcp4017-503", MCP4018_503),
@@ -209,5 +230,5 @@ static struct i2c_driver mcp4018_driver = {
 module_i2c_driver(mcp4018_driver);
 
 MODULE_AUTHOR("Peter Rosin <peda@axentia.se>");
-MODULE_DESCRIPTION("MCP4018 digital potentiometer");
+MODULE_DESCRIPTION("MCP4018 and AD5246 digital potentiometer");
 MODULE_LICENSE("GPL v2");

-- 
Git-155)


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

* Re: [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio
  2026-11-16 22:59 ` [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
@ 2026-11-17  8:10   ` Andy Shevchenko
  2026-11-17  8:20     ` Joseph Telaak
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Shevchenko @ 2026-11-17  8:10 UTC (permalink / raw)
  To: Joseph Telaak
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, linux, devicetree

On Mon, Nov 16, 2026 at 05:59:50PM -0500, Joseph Telaak wrote:
> The available raw values of a resistance output were documented only
> for the mcp4531, without the channel index. ds1803, mcp4531, tpl0102
> and x9250 all report them, and indexed channels name the attribute
> out_resistanceY_raw_available. Document both forms with the other
> generic resistance attributes and drop the driver-specific file.

...

> +What:		/sys/bus/iio/devices/iio:deviceX/out_resistance_raw_available
> +What:		/sys/bus/iio/devices/iio:deviceX/out_resistanceY_raw_available
> +KernelVersion:	4.9
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		The range of available raw values, as the minimum value, the
> +		step and the maximum value, all enclosed in square brackets.
> +		Example: [0 1 256]

...

> -Date:		October 2016

This is missing in the copied case.

> -Contact:	Peter Rosin <peda@axentia.se>

This is also, but I think Contact for generic is the IIO as a whole
(maintainer level).

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 2/5] iio: potentiometer: mcp4018: Report the available wiper positions
  2026-11-16 22:59 ` [PATCH 2/5] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
@ 2026-11-17  8:13   ` Andy Shevchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2026-11-17  8:13 UTC (permalink / raw)
  To: Joseph Telaak
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, linux, devicetree

On Mon, Nov 16, 2026 at 05:59:51PM -0500, Joseph Telaak wrote:
> Implement read_avail for the raw value, as ds1803, mcp4531, tpl0102 and
> x9250 already do. User space then sees out_resistance0_raw_available,
> and an in-kernel consumer can learn the wiper range with
> iio_read_max_channel_raw() instead of hardcoding it.

...

>  	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +	.info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW),
>  	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
>  };

> +		*length = ARRAY_SIZE(mcp4018_wiper_avail);

Take a chance to add missing headers at the same time, id est
+ array_size.h // ARRAY_SIZE()
+ bits.h // BIT()

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply
  2026-11-16 22:59 ` [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply Joseph Telaak
@ 2026-11-17  8:16   ` Andy Shevchenko
  2026-11-17  8:25     ` Joseph Telaak
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Shevchenko @ 2026-11-17  8:16 UTC (permalink / raw)
  To: Joseph Telaak
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, linux, devicetree

On Mon, Nov 16, 2026 at 05:59:53PM -0500, Joseph Telaak wrote:
> Get and enable the vdd supply at probe, so a board that switches the
> potentiometer's supply gets it powered before the wiper is used. On
> boards that describe no supply, this gets the dummy regulator.


+ dev_printk.h // dev_err*()

>  #include <linux/iio/iio.h>
>  #include <linux/module.h>
>  #include <linux/property.h>
> +#include <linux/regulator/consumer.h>

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio
  2026-11-17  8:10   ` Andy Shevchenko
@ 2026-11-17  8:20     ` Joseph Telaak
  0 siblings, 0 replies; 12+ messages in thread
From: Joseph Telaak @ 2026-11-17  8:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, linux, devicetree

On Tue, Nov 17, 2026 at 03:10, Andy Shevchenko wrote:
> > -Date:                October 2016
>
> This is missing in the copied case.

Right, v2 will keep it.

> > -Contact:     Peter Rosin <peda@axentia.se>
>
> This is also, but I think Contact for generic is the IIO as a whole
> (maintainer level).

Agreed, so I'll leave the IIO list as the contact.

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

* Re: [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply
  2026-11-17  8:16   ` Andy Shevchenko
@ 2026-11-17  8:25     ` Joseph Telaak
  0 siblings, 0 replies; 12+ messages in thread
From: Joseph Telaak @ 2026-11-17  8:25 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, linux, devicetree

On Tue, Nov 17, 2026 at 03:20, Andy Shevchenko wrote:
> + dev_printk.h // dev_err*()

Will add in v2.

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

* Re: [PATCH 5/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246
  2026-11-16 22:59 ` [PATCH 5/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-17  8:27   ` Andy Shevchenko
  0 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2026-11-17  8:27 UTC (permalink / raw)
  To: Joseph Telaak
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Peter Rosin, Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, linux-kernel, linux, devicetree

On Mon, Nov 16, 2026 at 05:59:54PM -0500, Joseph Telaak wrote:
> The AD5246 is a 128-position digital rheostat with the same I2C
> interface as the MCP4017/18/19: a single data byte writes the 7-bit
> wiper and a single-byte read returns it, with no command byte. Add its
> four resistance options.
> 
> Its resistance is D/128 of the end-to-end value, where the MCP401x's is
> D/127, so the scale divisor moves into the per-part config.
> 
> The misc ad525x_dpot driver also knows the AD5246, by I2C id only and
> through its own sysfs files. It can't provide an IIO channel, which a
> consumer such as dpot-dac needs. The AD5272 is likewise in both drivers.
> 
> Tested on an AD5246 at 0x2e that sets a fan's speed, described as
> adi,ad5246-010 with a vdd-supply. It probes, out_resistance0_raw_available
> reads [0 1 127] and out_resistance_scale reads 78.125000000. Raw writes
> of 0, 64, 100 and 127 read back the same value, and 128 is rejected.
> Writes through iio_write_channel_raw() from an in-kernel consumer of the
> channel read back as well (127, 38, 0 and 76).

...

>  config MCP4018
> -	tristate "Microchip MCP4017/18/19 Digital Potentiometer driver"
> +	tristate "Microchip MCP4017/18/19 and Analog Devices AD5246 Digital Potentiometer driver"

Make it shorter and more generic, in this way you spread the same text to the
top comment in the file

- * Industrial I/O driver for Microchip digital potentiometers
+ * Industrial I/O driver for $SAME_TEXT_AS_PER_ABOVE

and to MODULE_DESCRIPTION().

For example,

	tristate "Microchip MCP4018 and compatible Digital Potentiometer driver"

 * Industrial I/O driver for Microchip MCP4018 and compatible Digital Potentiometer

MODULE_DESCRIPTION("Microchip MCP4018 and compatible Digital Potentiometer driver").

>  	depends on I2C
>  	help
>  	  Say yes here to build support for the Microchip
> -	  MCP4017, MCP4018, MCP4019
> -	  digital potentiometer chips.
> +	  MCP4017, MCP4018, MCP4019 digital potentiometer chips
> +	  and the Analog Devices AD5246 digital rheostat.

And here make it list that is scalable to expand

	  Say yes here to build support for the Microchip
	  digital potentiometer chips:

	  - MCP4017, MCP4018, MCP4019

	  and Analog Devices digital rheostats:

	  - AD5246

>  	  To compile this driver as a module, choose M here: the
>  	  module will be called mcp4018.

...

>   * DEVID	#Wipers	#Positions	Resistor Opts (kOhm)
>   * mcp4017	1	128		5, 10, 50, 100
>   * mcp4018	1	128		5, 10, 50, 100
>   * mcp4019	1	128		5, 10, 50, 100
> + * ad5246	1	128		5, 10, 50, 100

Keep it sorted.

...

>  struct mcp4018_cfg {
>  	int kohms;
> +	/* Wiper position divisor: R = raw * kohms / div. */
> +	int div;

Why signed? Can the HW return something negative?

>  };

...

>  enum mcp4018_type {

>  	MCP4018_103,
>  	MCP4018_503,
>  	MCP4018_104,
> +	AD5246_005,
> +	AD5246_010,
> +	AD5246_050,
> +	AD5246_100,

Keep it sorted.

>  };

...

>  static const struct mcp4018_cfg mcp4018_cfg[] = {
> -	[MCP4018_502] = { .kohms =   5, },
> -	[MCP4018_103] = { .kohms =  10, },
> -	[MCP4018_503] = { .kohms =  50, },
> -	[MCP4018_104] = { .kohms = 100, },
> +	[MCP4018_502] = { .kohms =   5, .div = MCP4018_WIPER_MAX, },
> +	[MCP4018_103] = { .kohms =  10, .div = MCP4018_WIPER_MAX, },
> +	[MCP4018_503] = { .kohms =  50, .div = MCP4018_WIPER_MAX, },
> +	[MCP4018_104] = { .kohms = 100, .div = MCP4018_WIPER_MAX, },

Strictly speaking this patch can be split to two:
- adding 'div' member and providing it for the existing chips
- adding new chip support

> +	/* The AD5246's resistance is D / 128 of the end-to-end value. */
> +	[AD5246_005] = { .kohms =   5, .div = 128, },
> +	[AD5246_010] = { .kohms =  10, .div = 128, },
> +	[AD5246_050] = { .kohms =  50, .div = 128, },
> +	[AD5246_100] = { .kohms = 100, .div = 128, },

Keep it sorted.

>  };

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-11-17  8:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 22:59 [PATCH 0/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
2026-11-16 22:59 ` [PATCH 1/5] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
2026-11-17  8:10   ` Andy Shevchenko
2026-11-17  8:20     ` Joseph Telaak
2026-11-16 22:59 ` [PATCH 2/5] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
2026-11-17  8:13   ` Andy Shevchenko
2026-11-16 22:59 ` [PATCH 3/5] dt-bindings: iio: potentiometer: Add Analog Devices AD5246 Joseph Telaak
2026-11-16 22:59 ` [PATCH 4/5] iio: potentiometer: mcp4018: Turn on the vdd supply Joseph Telaak
2026-11-17  8:16   ` Andy Shevchenko
2026-11-17  8:25     ` Joseph Telaak
2026-11-16 22:59 ` [PATCH 5/5] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
2026-11-17  8:27   ` Andy Shevchenko

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