From: Jonathan Cameron <jic23@kernel.org>
To: Joseph Telaak <joseph@telaak.dev>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Peter Rosin" <peda@lysator.liu.se>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux@analog.com, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 6/6] iio: potentiometer: mcp4018: Add Analog Devices AD5246
Date: Wed, 25 Nov 2026 23:46:58 +0000 [thread overview]
Message-ID: <20261125234658.30fc80b4@jic23-hlaptop> (raw)
In-Reply-To: <20261125-iio-ad5246-v2-6-8feeb630f0b6@telaak.dev>
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");
>
next prev parent reply other threads:[~2026-11-25 23:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 23:37 ` Jonathan Cameron
2026-11-25 20:22 ` [PATCH v2 2/6] iio: potentiometer: mcp4018: Report the available wiper positions Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 3/6] dt-bindings: iio: potentiometer: Add Analog Devices AD5246 Joseph Telaak
2026-11-25 20:22 ` [PATCH v2 4/6] iio: potentiometer: mcp4018: Turn on the vdd supply 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
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 [this message]
2026-11-26 1:29 ` [PATCH v2 0/6] " Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125234658.30fc80b4@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=joseph@telaak.dev \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=nuno.sa@analog.com \
--cc=peda@lysator.liu.se \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox