Add support for setting decimation rate.
Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
---
no changes in v4.
drivers/iio/adc/adi-axi-adc.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 4116c44197b8..0b8673668745 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -80,6 +80,9 @@
#define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40)
#define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16)
+#define ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(c) (0x0424 + (c) * 0x40)
+#define ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK GENMASK(15, 0)
+
/* IO Delays */
#define ADI_AXI_ADC_REG_DELAY(l) (0x0800 + (l) * 0x4)
#define AXI_ADC_DELAY_CTRL_MASK GENMASK(4, 0)
@@ -242,6 +245,19 @@ static int axi_adc_test_pattern_set(struct iio_backend *back,
}
}
+static int axi_adc_oversampling_ratio_set(struct iio_backend *back,
+ unsigned int chan,
+ unsigned int rate)
+{
+ struct adi_axi_adc_state *st = iio_backend_get_priv(back);
+
+ return regmap_update_bits(st->regmap,
+ ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(chan),
+ ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK,
+ FIELD_PREP(ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK,
+ rate));
+}
+
static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned int chan,
unsigned int *status)
{
@@ -381,7 +397,8 @@ static int axi_adc_ad485x_data_size_set(struct iio_backend *back,
}
static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back,
- unsigned int ratio)
+ unsigned int chan,
+ unsigned int ratio)
{
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
@@ -549,6 +566,7 @@ static const struct iio_backend_ops adi_axi_adc_ops = {
.test_pattern_set = axi_adc_test_pattern_set,
.chan_status = axi_adc_chan_status,
.interface_type_get = axi_adc_interface_type_get,
+ .oversampling_ratio_set = axi_adc_oversampling_ratio_set,
.debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access),
.debugfs_print_chan_status = iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status),
};
--
2.34.1
On Mon, 2025-05-19 at 17:02 +0300, Pop Ioan Daniel wrote:
> Add support for setting decimation rate.
>
> Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
> ---
And with the requested change:
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> no changes in v4.
> drivers/iio/adc/adi-axi-adc.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
> index 4116c44197b8..0b8673668745 100644
> --- a/drivers/iio/adc/adi-axi-adc.c
> +++ b/drivers/iio/adc/adi-axi-adc.c
> @@ -80,6 +80,9 @@
> #define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40)
> #define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16)
>
> +#define ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(c) (0x0424 + (c) * 0x40)
> +#define ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK GENMASK(15,
> 0)
> +
> /* IO Delays */
> #define ADI_AXI_ADC_REG_DELAY(l) (0x0800 + (l) * 0x4)
> #define AXI_ADC_DELAY_CTRL_MASK GENMASK(4, 0)
> @@ -242,6 +245,19 @@ static int axi_adc_test_pattern_set(struct iio_backend
> *back,
> }
> }
>
> +static int axi_adc_oversampling_ratio_set(struct iio_backend *back,
> + unsigned int chan,
> + unsigned int rate)
> +{
> + struct adi_axi_adc_state *st = iio_backend_get_priv(back);
> +
> + return regmap_update_bits(st->regmap,
> + ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(chan),
> +
> ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK,
> +
> FIELD_PREP(ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK,
> + rate));
> +}
> +
> static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned
> int chan,
> unsigned int *status)
> {
> @@ -381,7 +397,8 @@ static int axi_adc_ad485x_data_size_set(struct iio_backend
> *back,
> }
>
> static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back,
> - unsigned int ratio)
> + unsigned int chan,
> + unsigned int ratio)
> {
> struct adi_axi_adc_state *st = iio_backend_get_priv(back);
>
> @@ -549,6 +566,7 @@ static const struct iio_backend_ops adi_axi_adc_ops = {
> .test_pattern_set = axi_adc_test_pattern_set,
> .chan_status = axi_adc_chan_status,
> .interface_type_get = axi_adc_interface_type_get,
> + .oversampling_ratio_set = axi_adc_oversampling_ratio_set,
> .debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access),
> .debugfs_print_chan_status =
> iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status),
> };
On 5/19/25 9:02 AM, Pop Ioan Daniel wrote:
> Add support for setting decimation rate.
>
> Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
> ---
With the bit below fixed:
Reviewed-by: David Lechner <dlechner@baylibre.com>
...
> @@ -381,7 +397,8 @@ static int axi_adc_ad485x_data_size_set(struct iio_backend *back,
> }
>
> static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back,
> - unsigned int ratio)
> + unsigned int chan,
> + unsigned int ratio)
I think this change belongs in the previous patch. Most importantly because
it could cause a compile error during a git bisect, but also because that
is where it logically belongs.
> {
> struct adi_axi_adc_state *st = iio_backend_get_priv(back);
>
On Mon, 2025-05-19 at 10:15 -0500, David Lechner wrote:
> On 5/19/25 9:02 AM, Pop Ioan Daniel wrote:
> > Add support for setting decimation rate.
> >
> > Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
> > ---
>
> With the bit below fixed:
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
>
> ...
> > @@ -381,7 +397,8 @@ static int axi_adc_ad485x_data_size_set(struct
> > iio_backend *back,
> > }
> >
> > static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back,
> > - unsigned int ratio)
> > + unsigned int chan,
> > + unsigned int ratio)
>
> I think this change belongs in the previous patch. Most importantly because
> it could cause a compile error during a git bisect, but also because that
> is where it logically belongs.
I was wondering about this. Definitely needs to be in the previous one...
>
> > {
> > struct adi_axi_adc_state *st = iio_backend_get_priv(back);
> >
© 2016 - 2025 Red Hat, Inc.