From: Marcelo Schmitt <marcelo.schmitt@analog.com>
To: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <jic23@kernel.org>, <lars@metafoo.de>,
<Michael.Hennerich@analog.com>, <dlechner@baylibre.com>,
<nuno.sa@analog.com>, <andy@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<linus.walleij@linaro.org>, <brgl@bgdev.pl>, <broonie@kernel.org>,
<lgirdwood@gmail.com>, <marcelo.schmitt1@gmail.com>
Subject: [PATCH v7 03/12] iio: adc: ad4170-4: Add support for calibration gain
Date: Mon, 30 Jun 2025 10:58:50 -0300 [thread overview]
Message-ID: <f87b5dd7ffa08f366feb2b977ffcbfb8b67bdf1c.1751289747.git.marcelo.schmitt@analog.com> (raw)
In-Reply-To: <cover.1751289747.git.marcelo.schmitt@analog.com>
Add support for ADC calibration gain configuration.
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
---
No changes since v5.
drivers/iio/adc/ad4170-4.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/iio/adc/ad4170-4.c b/drivers/iio/adc/ad4170-4.c
index ecda8e8a41eb..c45203c0b479 100644
--- a/drivers/iio/adc/ad4170-4.c
+++ b/drivers/iio/adc/ad4170-4.c
@@ -623,6 +623,7 @@ static const struct iio_chan_spec ad4170_channel_template = {
.differential = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_OFFSET),
.info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE),
.scan_type = {
@@ -940,6 +941,9 @@ static int ad4170_read_raw(struct iio_dev *indio_dev,
pga = FIELD_GET(AD4170_AFE_PGA_GAIN_MSK, setup->afe);
*val = chan_info->offset_tbl[pga];
return IIO_VAL_INT;
+ case IIO_CHAN_INFO_CALIBSCALE:
+ *val = setup->gain;
+ return IIO_VAL_INT;
default:
return -EINVAL;
}
@@ -1054,6 +1058,18 @@ static int ad4170_set_pga(struct ad4170_state *st,
return ad4170_write_channel_setup(st, chan->address, false);
}
+static int ad4170_set_calib_gain(struct ad4170_state *st,
+ struct iio_chan_spec const *chan, int val)
+{
+ struct ad4170_chan_info *chan_info = &st->chan_infos[chan->address];
+ struct ad4170_setup *setup = &chan_info->setup;
+
+ guard(mutex)(&st->lock);
+ setup->gain = val;
+
+ return ad4170_write_channel_setup(st, chan->address, false);
+}
+
static int __ad4170_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int val,
int val2, long info)
@@ -1063,6 +1079,8 @@ static int __ad4170_write_raw(struct iio_dev *indio_dev,
switch (info) {
case IIO_CHAN_INFO_SCALE:
return ad4170_set_pga(st, chan, val, val2);
+ case IIO_CHAN_INFO_CALIBSCALE:
+ return ad4170_set_calib_gain(st, chan, val);
default:
return -EINVAL;
}
@@ -1089,6 +1107,8 @@ static int ad4170_write_raw_get_fmt(struct iio_dev *indio_dev,
switch (info) {
case IIO_CHAN_INFO_SCALE:
return IIO_VAL_INT_PLUS_NANO;
+ case IIO_CHAN_INFO_CALIBSCALE:
+ return IIO_VAL_INT;
default:
return -EINVAL;
}
--
2.47.2
next prev parent reply other threads:[~2025-06-30 13:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 13:57 [PATCH v7 00/12] iio: adc: Add support for AD4170 series of ADCs Marcelo Schmitt
2025-06-30 13:57 ` [PATCH v7 01/12] dt-bindings: iio: adc: Add AD4170 Marcelo Schmitt
2025-07-06 17:08 ` Jonathan Cameron
2025-06-30 13:58 ` [PATCH v7 02/12] iio: adc: Add basic support for AD4170-4 Marcelo Schmitt
2025-06-30 13:58 ` Marcelo Schmitt [this message]
2025-06-30 13:59 ` [PATCH v7 04/12] iio: adc: ad4170-4: Add support for calibration bias Marcelo Schmitt
2025-06-30 13:59 ` [PATCH v7 05/12] Documentation: ABI: IIO: Add sinc5+avg to the filter_type_available list Marcelo Schmitt
2025-06-30 13:59 ` [PATCH v7 06/12] iio: adc: ad4170-4: Add digital filter and sample frequency config support Marcelo Schmitt
2025-06-30 14:00 ` [PATCH v7 07/12] iio: adc: ad4170-4: Add support for buffered data capture Marcelo Schmitt
2025-06-30 14:00 ` [PATCH v7 08/12] iio: adc: ad4170-4: Add clock provider support Marcelo Schmitt
2025-06-30 14:00 ` [PATCH v7 09/12] iio: adc: ad4170-4: Add GPIO controller support Marcelo Schmitt
2025-06-30 14:01 ` [PATCH v7 10/12] iio: adc: ad4170-4: Add support for internal temperature sensor Marcelo Schmitt
2025-06-30 14:01 ` [PATCH v7 11/12] iio: adc: ad4170-4: Add support for weigh scale and RTD sensors Marcelo Schmitt
2025-06-30 14:01 ` [PATCH v7 12/12] iio: adc: ad4170-4: Add timestamp channel Marcelo Schmitt
2025-07-02 8:09 ` [PATCH v7 00/12] iio: adc: Add support for AD4170 series of ADCs Andy Shevchenko
2025-07-02 12:00 ` Marcelo Schmitt
2025-07-02 12:15 ` Andy Shevchenko
2025-07-02 18:59 ` Marcelo Schmitt
2025-07-03 14:13 ` Andy Shevchenko
2025-07-03 20:24 ` Marcelo Schmitt
2025-07-06 17:10 ` 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=f87b5dd7ffa08f366feb2b977ffcbfb8b67bdf1c.1751289747.git.marcelo.schmitt@analog.com \
--to=marcelo.schmitt@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=nuno.sa@analog.com \
--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
all inboxes | Powered by JetHome®