From: Jonathan Cameron <jic23@kernel.org>
To: "David Lechner (TI)" <dlechner@baylibre.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Chris Hall" <c-hall@ti.com>, "Patrick Edwards" <pedwards@ti.com>,
"Kurt Borja" <kuurtb@gmail.com>,
"Nguyen Minh Tien" <zizuzacker@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 8/8] iio: adc: ti-ads112c14: add measurement channel support
Date: Mon, 13 Jul 2026 03:35:39 +0100 [thread overview]
Message-ID: <20260713033539.18457479@jic23-huawei> (raw)
In-Reply-To: <20260710-iio-adc-ti-ads122c14-v3-8-746d52cbf1d0@baylibre.com>
On Fri, 10 Jul 2026 17:50:41 -0500
"David Lechner (TI)" <dlechner@baylibre.com> wrote:
> Add support for parsing devicetree properties for measurement channels
> and doing direct reads on these.
>
> There are quite a lot of conditions that have to be met for each
> measurement to be made, so quite a bit of state and algorithms are
> required to handle it.
>
> Channels are created dynamically since the number of possibilities is
> unreasonably large.
>
> Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
A few little things,
Thanks,
Jonathan
> ---
> v3 changes:
> * Checked error when getting "label" property.
> * Removed call of fwnode_device_is_available().
> * Used IIO_VAL_DECIMAL64_PICO for scale.
> * Added switch in ads112c14_read_avail() to reduce future diff.
>
> v2 changes:
> * Adapted for changes in DT bindings.
> * Fixed bug in IDAC current register value calculation.
> * Fix uninitialized variable bug.
> * Fix bug in data->num_measurements calculation.
> * Use IIO_RESISTANCE instead of IIO_VOLTAGE when external reference is
> used and it is a resistor rather than a voltage source.
> * Fix bug with negative input mux selection on single-ended measurements.
> * Fixed return checks of devm_regulator_get_enable_read_voltage().
> ---
> drivers/iio/adc/ti-ads112c14.c | 551 +++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 533 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
> index 2ce4411a0d86..a310abd69d8f 100644
> --- a/drivers/iio/adc/ti-ads112c14.c
> +++ b/drivers/iio/adc/ti-ads112c14.c
> @@ -200,9 +222,32 @@ static const struct iio_chan_spec ads112c14_sys_mon_channels[] = {
> },
> };
>
> +struct ads112c14_measurement {
> + const char *label;
> + u32 vref_source;
> + u8 iunit;
> + u8 idac1_mag;
> + u8 idac2_mag;
> + u8 idac1_mux;
> + u8 idac2_mux;
> + u8 iadc_count;
> + u8 gain_val;
> + u8 burnout;
Sashiko calls out that this is set but not used.
I'd leave parsing the stuff to set it for now and bring that in when
you want burnt out support.
> + bool global_chop;
> + bool bipolar;
> + s64 scale_available[ARRAY_SIZE(ads112c14_pga_gains_x10)];
> +};
> @@ -257,12 +302,113 @@ static const struct regmap_config ads112c14_regmap_config = {
> .cache_type = REGCACHE_MAPLE,
> };
>
> +static int ads112c14_prepare_measurement_channel(struct ads112c14_data *data,
> + const struct iio_chan_spec *chan)
> +{
> + struct ads112c14_measurement *measurement = &data->measurements[chan->scan_index];
> + u32 refp_buf_en, refn_buf_en, ref_val, ref_sel;
> + int ret;
> +
> + ret = regmap_update_bits(data->regmap, ADS112C14_REG_MUX_CFG,
> + ADS112C14_MUX_CFG_AINP | ADS112C14_MUX_CFG_AINN,
> + FIELD_PREP(ADS112C14_MUX_CFG_AINP, chan->channel) |
> + FIELD_PREP(ADS112C14_MUX_CFG_AINN, chan->channel2));
> + if (ret)
> + return ret;
> +
> + ret = regmap_update_bits(data->regmap, ADS112C14_REG_DIGITAL_CFG,
> + ADS112C14_DIGITAL_CFG_CODING,
> + FIELD_PREP(ADS112C14_DIGITAL_CFG_CODING,
> + measurement->bipolar ? 0 : 1));
You could use regmap_assign_bits(data->regmap, ADS112C14_REG_DIGITAL_CFG,
ADS112C14_DIGITAL_CFG_CODING,
measurement->bipolar);
I'm not particularly sure that is any clearer however so up to you.
> @@ -436,14 +592,29 @@ static int ads112c14_read_avail(struct iio_dev *indio_dev,
> {
> struct ads112c14_data *data = iio_priv(indio_dev);
>
> - if (chan->channel == ADS112C14_SYS_MON_CHANNEL_SHORT) {
> - *vals = (const int *)data->sys_mon_chan_short_scale_available;
> - *length = 2 * ARRAY_SIZE(data->sys_mon_chan_short_scale_available);
> - *type = IIO_VAL_DECIMAL64_PICO;
> - return IIO_AVAIL_LIST;
> - }
> + switch (mask) {
> + case IIO_CHAN_INFO_SCALE:
Move introduction of switch to earlier patch? Doesn't look like it would
be wrong at that point and it would reduce churn a tiny bit.
> + if (chan->channel < ADS112C14_SYS_MON_CHANNEL_BASE) {
> + struct ads112c14_measurement *measurement;
> +
> + measurement = &data->measurements[chan->scan_index];
> + *vals = (const int *)measurement->scale_available;
> + *length = 2 * ARRAY_SIZE(measurement->scale_available);
> + *type = IIO_VAL_DECIMAL64_PICO;
> + return IIO_AVAIL_LIST;
> + }
> +
> + if (chan->channel == ADS112C14_SYS_MON_CHANNEL_SHORT) {
> + *vals = (const int *)data->sys_mon_chan_short_scale_available;
> + *length = 2 * ARRAY_SIZE(data->sys_mon_chan_short_scale_available);
> + *type = IIO_VAL_DECIMAL64_PICO;
> + return IIO_AVAIL_LIST;
> + }
>
> - return -EINVAL;
> + return -EINVAL;
> + default:
> + return -EINVAL;
> + }
> }
prev parent reply other threads:[~2026-07-13 2:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 22:50 [PATCH v3 0/8] iio: adc: new ti-ads112c14 driver David Lechner
2026-07-10 22:50 ` [PATCH v3 1/8] dt-bindings: iio: adc: Add reference-sources property David Lechner
2026-07-10 22:50 ` [PATCH v3 2/8] dt-bindings: iio: adc: Add excitation current sources properties David Lechner
2026-07-13 1:32 ` Jonathan Cameron
2026-07-10 22:50 ` [PATCH v3 3/8] dt-bindings: iio: adc: Add burn-out current properties David Lechner
2026-07-10 22:50 ` [PATCH v3 4/8] dt-bindings: iio: adc: add input-chopping property David Lechner (TI)
2026-07-13 1:34 ` Jonathan Cameron
2026-07-10 22:50 ` [PATCH v3 5/8] dt-bindings: iio: adc: add ti,ads122c14 David Lechner (TI)
2026-07-10 22:59 ` sashiko-bot
2026-07-10 23:12 ` David Lechner
2026-07-13 1:54 ` Jonathan Cameron
2026-07-10 22:50 ` [PATCH v3 6/8] iio: adc: add ti-ads112c14 driver David Lechner (TI)
2026-07-10 23:00 ` sashiko-bot
2026-07-12 9:42 ` Andy Shevchenko
2026-07-12 16:30 ` David Lechner
2026-07-13 2:11 ` Jonathan Cameron
2026-07-13 14:03 ` David Lechner
2026-07-10 22:50 ` [PATCH v3 7/8] iio: adc: ti-ads112c14: implement gain on internal short SYS_MON channel David Lechner (TI)
2026-07-10 23:04 ` sashiko-bot
2026-07-11 9:11 ` Andy Shevchenko
2026-07-13 2:21 ` Jonathan Cameron
2026-07-10 22:50 ` [PATCH v3 8/8] iio: adc: ti-ads112c14: add measurement channel support David Lechner (TI)
2026-07-10 23:08 ` sashiko-bot
2026-07-11 13:00 ` Andy Shevchenko
2026-07-13 2:35 ` Jonathan Cameron [this message]
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=20260713033539.18457479@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=c-hall@ti.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=kuurtb@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pedwards@ti.com \
--cc=robh@kernel.org \
--cc=zizuzacker@gmail.com \
/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