* [PATCH v2 1/6] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-25 20:22 ` Joseph Telaak
2026-11-25 23:37 ` Jonathan Cameron
2026-11-25 20:22 ` [PATCH v2 2/6] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
` (5 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Joseph Telaak @ 2026-11-25 20:22 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 | 10 ++++++++++
Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 | 8 --------
MAINTAINERS | 1 -
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 54800847f2ca..83eb616862ea 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -2034,6 +2034,16 @@ 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
+Date: October 2016
+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 c74dadb6cea9..ef6033c5edf3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16691,7 +16691,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 [flat|nested] 10+ messages in thread* Re: [PATCH v2 1/6] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio
2026-11-25 20:22 ` [PATCH v2 1/6] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
@ 2026-11-25 23:37 ` Jonathan Cameron
0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-11-25 23:37 UTC (permalink / raw)
To: Joseph Telaak
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Rosin, Michael Hennerich, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-iio, linux-kernel,
linux, devicetree
On Wed, 25 Nov 2026 15:22:28 -0500
Joseph Telaak <joseph@telaak.dev> 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.
>
> Signed-off-by: Joseph Telaak <joseph@telaak.dev>
> ---
> Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++
> Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 | 8 --------
> MAINTAINERS | 1 -
> 3 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 54800847f2ca..83eb616862ea 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -2034,6 +2034,16 @@ 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
> +Date: October 2016
> +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]
Not suggesting we do it in this series but in general the ABI docs could do with
a cleanup for _available attributes. Their form is generic and what the values
mean simply comes from what we are describing as taking those values.
Ah well, a move is fine for now as this doesn't make things any worse.
Right now there is too much else going on to worry about tidying up ABI docs.
Jonathan
> +
> 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 c74dadb6cea9..ef6033c5edf3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -16691,7 +16691,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
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/6] iio: potentiometer: mcp4018: Report the available wiper positions
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 1/6] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
@ 2026-11-25 20:22 ` Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 3/6] dt-bindings: iio: potentiometer: Add Analog Devices AD5246 Joseph Telaak
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak @ 2026-11-25 20:22 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 | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index b10b4b920dc0..d6387645853d 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -12,6 +12,8 @@
* mcp4019 1 128 5, 10, 50, 100
*/
+#include <linux/array_size.h>
+#include <linux/bits.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
@@ -49,9 +51,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 +98,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 [flat|nested] 10+ messages in thread* [PATCH v2 3/6] dt-bindings: iio: potentiometer: Add Analog Devices AD5246
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 1/6] iio: ABI: Move out_resistance_raw_available to sysfs-bus-iio Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 2/6] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
@ 2026-11-25 20:22 ` Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 4/6] iio: potentiometer: mcp4018: Turn on the vdd supply Joseph Telaak
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak @ 2026-11-25 20:22 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, Conor Dooley
The AD5246 is a 128-position digital rheostat on I2C, in 5, 10, 50 and
100 kOhm versions. The end-to-end resistance sets the scale the driver
reports and cannot be read from the device, so each version gets its own
compatible, named in kOhm as for the AD5272, with no fallback between
them. There is no fallback to the MCP4017 compatibles either: the
AD5246's step is 1/128 of the end-to-end value, not 1/127. 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.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
.../bindings/iio/potentiometer/adi,ad5246-005.yaml | 54 ++++++++++++++++++++++
MAINTAINERS | 1 +
2 files changed, 55 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246-005.yaml b/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246-005.yaml
new file mode 100644
index 000000000000..9215de612a08
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5246-005.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-005.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 = <®_3v3>;
+ #io-channel-cells = <0>;
+ };
+ };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index ef6033c5edf3..b680f922d9bf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16691,6 +16691,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-005.yaml
F: drivers/iio/potentiometer/mcp4018.c
F: drivers/iio/potentiometer/mcp4531.c
--
Git-155)
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 4/6] iio: potentiometer: mcp4018: Turn on the vdd supply
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
` (2 preceding siblings ...)
2026-11-25 20:22 ` [PATCH v2 3/6] dt-bindings: iio: potentiometer: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-25 20:22 ` Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 5/6] iio: potentiometer: mcp4018: Move the scale divisor into the per-part config Joseph Telaak
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak @ 2026-11-25 20:22 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 | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index d6387645853d..6ca6cd7cbf71 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -14,11 +14,13 @@
#include <linux/array_size.h>
#include <linux/bits.h>
+#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/property.h>
+#include <linux/regulator/consumer.h>
#define MCP4018_WIPER_MAX 127
@@ -169,6 +171,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)) {
@@ -176,6 +179,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 [flat|nested] 10+ messages in thread* [PATCH v2 5/6] iio: potentiometer: mcp4018: Move the scale divisor into the per-part config
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
` (3 preceding siblings ...)
2026-11-25 20:22 ` [PATCH v2 4/6] iio: potentiometer: mcp4018: Turn on the vdd supply Joseph Telaak
@ 2026-11-25 20:22 ` Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 6/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
2026-11-26 1:29 ` [PATCH v2 0/6] " Jonathan Cameron
6 siblings, 0 replies; 10+ messages in thread
From: Joseph Telaak @ 2026-11-25 20:22 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 step is kohms / 127 for every MCP401x part. Keep the divisor in
struct mcp4018_cfg, so that parts with another step size can be added.
No functional change.
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
drivers/iio/potentiometer/mcp4018.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c
index 6ca6cd7cbf71..75a63a01acef 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -26,6 +26,8 @@
struct mcp4018_cfg {
int kohms;
+ /* Wiper position divisor: R = raw * kohms / div */
+ unsigned int div;
};
enum mcp4018_type {
@@ -36,10 +38,10 @@ enum mcp4018_type {
};
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, },
};
struct mcp4018_data {
@@ -75,7 +77,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;
}
--
Git-155)
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 6/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
` (4 preceding siblings ...)
2026-11-25 20:22 ` [PATCH v2 5/6] iio: potentiometer: mcp4018: Move the scale divisor into the per-part config Joseph Telaak
@ 2026-11-25 20:22 ` Joseph Telaak
2026-11-25 23:46 ` Jonathan Cameron
2026-11-26 1:29 ` [PATCH v2 0/6] " Jonathan Cameron
6 siblings, 1 reply; 10+ messages in thread
From: Joseph Telaak @ 2026-11-25 20:22 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. Name the driver for the MCP4018 and compatible parts.
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, 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 | 10 ++++++----
drivers/iio/potentiometer/mcp4018.c | 24 ++++++++++++++++++++++--
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig
index e6a9a3c67845..05833455e82a 100644
--- a/drivers/iio/potentiometer/Kconfig
+++ b/drivers/iio/potentiometer/Kconfig
@@ -70,12 +70,14 @@ config MAX5487
module will be called max5487.
config MCP4018
- tristate "Microchip MCP4017/18/19 Digital Potentiometer driver"
+ tristate "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.
+ Say yes here to build support for the following digital
+ potentiometers and rheostats:
+
+ - Analog Devices AD5246
+ - Microchip MCP4017, MCP4018, MCP4019
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 75a63a01acef..b593082db4bb 100644
--- a/drivers/iio/potentiometer/mcp4018.c
+++ b/drivers/iio/potentiometer/mcp4018.c
@@ -1,12 +1,15 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * Industrial I/O driver for Microchip digital potentiometers
+ * Industrial I/O driver for Microchip MCP4018 and compatible digital
+ * potentiometers
* Copyright (c) 2018 Axentia Technologies AB
* 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)
+ * ad5246 1 128 5, 10, 50, 100
* mcp4017 1 128 5, 10, 50, 100
* mcp4018 1 128 5, 10, 50, 100
* mcp4019 1 128 5, 10, 50, 100
@@ -31,6 +34,10 @@ struct mcp4018_cfg {
};
enum mcp4018_type {
+ AD5246_005,
+ AD5246_010,
+ AD5246_050,
+ AD5246_100,
MCP4018_502,
MCP4018_103,
MCP4018_503,
@@ -38,6 +45,11 @@ enum mcp4018_type {
};
static const struct mcp4018_cfg mcp4018_cfg[] = {
+ /* 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, },
[MCP4018_502] = { .kohms = 5, .div = MCP4018_WIPER_MAX, },
[MCP4018_103] = { .kohms = 10, .div = MCP4018_WIPER_MAX, },
[MCP4018_503] = { .kohms = 50, .div = MCP4018_WIPER_MAX, },
@@ -130,6 +142,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),
@@ -152,6 +168,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),
@@ -214,5 +234,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("Microchip MCP4018 and compatible Digital Potentiometer driver");
MODULE_LICENSE("GPL v2");
--
Git-155)
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 6/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246
2026-11-25 20:22 ` [PATCH v2 6/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-25 23:46 ` Jonathan Cameron
0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-11-25 23:46 UTC (permalink / raw)
To: Joseph Telaak
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Rosin, Michael Hennerich, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-iio, linux-kernel,
linux, devicetree
On Wed, 25 Nov 2026 15:22:33 -0500
Joseph Telaak <joseph@telaak.dev> 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. Name the driver for the MCP4018 and compatible parts.
>
> 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.
For this I want a view from the analog devices folk. What's the plan for
that misc driver?
However I'm not going to let a custom misc driver block this in the
meantime so that is mostly a long term question / satisfying my curiosity
thing.
>
> Tested on an AD5246 at 0x2e, 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 | 10 ++++++----
> drivers/iio/potentiometer/mcp4018.c | 24 ++++++++++++++++++++++--
> 2 files changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig
> index e6a9a3c67845..05833455e82a 100644
> --- a/drivers/iio/potentiometer/Kconfig
> +++ b/drivers/iio/potentiometer/Kconfig
> @@ -70,12 +70,14 @@ config MAX5487
> module will be called max5487.
>
> config MCP4018
> - tristate "Microchip MCP4017/18/19 Digital Potentiometer driver"
> + tristate "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.
> + Say yes here to build support for the following digital
> + potentiometers and rheostats:
> +
> + - Analog Devices AD5246
> + - Microchip MCP4017, MCP4018, MCP4019
>
> 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 75a63a01acef..b593082db4bb 100644
> --- a/drivers/iio/potentiometer/mcp4018.c
> +++ b/drivers/iio/potentiometer/mcp4018.c
> @@ -1,12 +1,15 @@
> // SPDX-License-Identifier: GPL-2.0
> /*
> - * Industrial I/O driver for Microchip digital potentiometers
> + * Industrial I/O driver for Microchip MCP4018 and compatible digital
> + * potentiometers
> * Copyright (c) 2018 Axentia Technologies AB
> * 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)
> + * ad5246 1 128 5, 10, 50, 100
> * mcp4017 1 128 5, 10, 50, 100
> * mcp4018 1 128 5, 10, 50, 100
> * mcp4019 1 128 5, 10, 50, 100
> @@ -31,6 +34,10 @@ struct mcp4018_cfg {
> };
>
> enum mcp4018_type {
> + AD5246_005,
> + AD5246_010,
> + AD5246_050,
> + AD5246_100,
> MCP4018_502,
> MCP4018_103,
> MCP4018_503,
> @@ -38,6 +45,11 @@ enum mcp4018_type {
> };
>
> static const struct mcp4018_cfg mcp4018_cfg[] = {
> + /* 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, },
> [MCP4018_502] = { .kohms = 5, .div = MCP4018_WIPER_MAX, },
> [MCP4018_103] = { .kohms = 10, .div = MCP4018_WIPER_MAX, },
> [MCP4018_503] = { .kohms = 50, .div = MCP4018_WIPER_MAX, },
> @@ -130,6 +142,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),
> @@ -152,6 +168,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),
> @@ -214,5 +234,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("Microchip MCP4018 and compatible Digital Potentiometer driver");
> MODULE_LICENSE("GPL v2");
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246
2026-11-25 20:22 [PATCH v2 0/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
` (5 preceding siblings ...)
2026-11-25 20:22 ` [PATCH v2 6/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246 Joseph Telaak
@ 2026-11-26 1:29 ` Jonathan Cameron
6 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-11-26 1:29 UTC (permalink / raw)
To: Joseph Telaak
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, Peter Rosin, Michael Hennerich, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, linux-iio, linux-kernel,
linux, devicetree, Conor Dooley
On Wed, 25 Nov 2026 15:22:27 -0500
Joseph Telaak <joseph@telaak.dev> wrote:
> 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.
>
> 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, patch 5 moves the scale divisor into the per-part
> config, and patch 6 adds the parts.
>
Applied to the testing branch of iio.git. That means it is now queued up for
the next merge window.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 10+ messages in thread