[PATCH 3/5] iio: ABI: add sinc4+sinc1+pf1 filter_type

From: David Lechner (TI)

Date: Fri Aug 07 2026 - 20:21:35 EST


Document "sinc4+sinc1+pf1" as a valid value for the filter_type
attributes (used by the ti-ads112c14 driver).

Signed-off-by: David Lechner (TI) <dlechner@xxxxxxxxxxxx>
---
Documentation/ABI/testing/sysfs-bus-iio | 1 +
drivers/iio/adc/ti-ads112c14.c | 158 ++++++++++++++++----------------
2 files changed, 80 insertions(+), 79 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index a4f5595722ad..a8e1cb8e7490 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -2380,6 +2380,7 @@ Description:
* "sinc4+lp" - Sinc4 + Low Pass Filter.
* "sinc4+sinc1" - Sinc4 + averaging by 8. Low 1st conversion
time.
+ * "sinc4+sinc1+pf1" - Sinc4 + Sinc1 + device specific Post Filter 1.
* "sinc4+rej60" - Sinc4 + 60Hz rejection.
* "sinc5" - The digital sinc5 filter. Excellent noise
performance
diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
index a73c0d6f0f65..ff22d0716abe 100644
--- a/drivers/iio/adc/ti-ads112c14.c
+++ b/drivers/iio/adc/ti-ads112c14.c
@@ -1358,85 +1358,6 @@ static const struct iio_info ads112c14_info = {
.read_label = ads112c14_read_label,
};

-static int ads112c14_get_filter_type_from_state(struct ads112c14_channel_state *channel_state)
-{
- switch (channel_state->filter_osr) {
- case ADS112C14_DATA_RATE_CFG_FLTR_OSR_16...ADS112C14_DATA_RATE_CFG_FLTR_OSR_32:
- return ADS112C14_FILTER_TYPE_SINC4;
- case ADS112C14_DATA_RATE_CFG_FLTR_OSR_128...ADS112C14_DATA_RATE_CFG_FLTR_OSR_1024:
- return ADS112C14_FILTER_TYPE_SINC4_SINC1;
- case ADS112C14_DATA_RATE_CFG_FLTR_OSR_25SPS...ADS112C14_DATA_RATE_CFG_FLTR_OSR_20SPS:
- return ADS112C14_FILTER_TYPE_SINC4_SINC1_PF1;
- default:
- return -EINVAL;
- }
-}
-
-static int ads112c14_set_filter_type(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- unsigned int val)
-{
- struct ads112c14_data *data = iio_priv(indio_dev);
- struct ads112c14_channel_state *channel_state;
- int ret;
-
- IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
- if (IIO_DEV_ACQUIRE_FAILED(claim))
- return -EBUSY;
-
- guard(mutex)(&data->lock);
-
- channel_state = &data->channel_states[chan->scan_index];
-
- ret = ads112c14_get_filter_type_from_state(channel_state);
- if (ret < 0)
- return ret;
-
- /*
- * channel_state->filter_osr affects multiple attributes, so don't modify
- * it if the filter type is already set to the requested value.
- */
- if (ret == val)
- return 0;
-
- /* Otherwise, pick an arbitrary default for each type. */
- switch (val) {
- case ADS112C14_FILTER_TYPE_SINC4:
- channel_state->filter_osr = ADS112C14_DATA_RATE_CFG_FLTR_OSR_16;
- break;
- case ADS112C14_FILTER_TYPE_SINC4_SINC1:
- channel_state->filter_osr = ADS112C14_DATA_RATE_CFG_FLTR_OSR_128;
- break;
- case ADS112C14_FILTER_TYPE_SINC4_SINC1_PF1:
- channel_state->filter_osr = ADS112C14_DATA_RATE_CFG_FLTR_OSR_25SPS;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int ads112c14_get_filter_type(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan)
-{
- struct ads112c14_data *data = iio_priv(indio_dev);
- struct ads112c14_channel_state *channel_state;
-
- guard(mutex)(&data->lock);
-
- channel_state = &data->channel_states[chan->scan_index];
-
- return ads112c14_get_filter_type_from_state(channel_state);
-}
-
-static const struct iio_enum ads112c14_filter_type_enum = {
- .items = ads112c14_filter_type_names,
- .num_items = ARRAY_SIZE(ads112c14_filter_type_names),
- .set = ads112c14_set_filter_type,
- .get = ads112c14_get_filter_type,
-};
-
static bool ads112c14_using_drdy_trigger(struct iio_dev *indio_dev)
{
struct ads112c14_data *data = iio_priv(indio_dev);
@@ -1584,6 +1505,85 @@ static ssize_t ads112c14_read_burnout_raw(struct iio_dev *indio_dev,
return sysfs_emit(buf, "%d\n", val);
}

+static int ads112c14_get_filter_type_from_state(struct ads112c14_channel_state *channel_state)
+{
+ switch (channel_state->filter_osr) {
+ case ADS112C14_DATA_RATE_CFG_FLTR_OSR_16...ADS112C14_DATA_RATE_CFG_FLTR_OSR_32:
+ return ADS112C14_FILTER_TYPE_SINC4;
+ case ADS112C14_DATA_RATE_CFG_FLTR_OSR_128...ADS112C14_DATA_RATE_CFG_FLTR_OSR_1024:
+ return ADS112C14_FILTER_TYPE_SINC4_SINC1;
+ case ADS112C14_DATA_RATE_CFG_FLTR_OSR_25SPS...ADS112C14_DATA_RATE_CFG_FLTR_OSR_20SPS:
+ return ADS112C14_FILTER_TYPE_SINC4_SINC1_PF1;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int ads112c14_set_filter_type(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ unsigned int val)
+{
+ struct ads112c14_data *data = iio_priv(indio_dev);
+ struct ads112c14_channel_state *channel_state;
+ int ret;
+
+ IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
+ if (IIO_DEV_ACQUIRE_FAILED(claim))
+ return -EBUSY;
+
+ guard(mutex)(&data->lock);
+
+ channel_state = &data->channel_states[chan->scan_index];
+
+ ret = ads112c14_get_filter_type_from_state(channel_state);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * channel_state->filter_osr affects multiple attributes, so don't modify
+ * it if the filter type is already set to the requested value.
+ */
+ if (ret == val)
+ return 0;
+
+ /* Otherwise, pick an arbitrary default for each type. */
+ switch (val) {
+ case ADS112C14_FILTER_TYPE_SINC4:
+ channel_state->filter_osr = ADS112C14_DATA_RATE_CFG_FLTR_OSR_16;
+ break;
+ case ADS112C14_FILTER_TYPE_SINC4_SINC1:
+ channel_state->filter_osr = ADS112C14_DATA_RATE_CFG_FLTR_OSR_128;
+ break;
+ case ADS112C14_FILTER_TYPE_SINC4_SINC1_PF1:
+ channel_state->filter_osr = ADS112C14_DATA_RATE_CFG_FLTR_OSR_25SPS;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int ads112c14_get_filter_type(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan)
+{
+ struct ads112c14_data *data = iio_priv(indio_dev);
+ struct ads112c14_channel_state *channel_state;
+
+ guard(mutex)(&data->lock);
+
+ channel_state = &data->channel_states[chan->scan_index];
+
+ return ads112c14_get_filter_type_from_state(channel_state);
+}
+
+static const struct iio_enum ads112c14_filter_type_enum = {
+ .items = ads112c14_filter_type_names,
+ .num_items = ARRAY_SIZE(ads112c14_filter_type_names),
+ .set = ads112c14_set_filter_type,
+ .get = ads112c14_get_filter_type,
+};
+
static const struct iio_chan_spec_ext_info ads112c14_ext_info[] = {
IIO_ENUM("filter_type", IIO_SEPARATE, &ads112c14_filter_type_enum),
IIO_ENUM_AVAILABLE("filter_type", IIO_SEPARATE, &ads112c14_filter_type_enum),

--
2.43.0