Skip to content

Commit aaa2f1c

Browse files
PIoandanjic23
authored andcommitted
iio: adc: adi-axi-adc: add axi_adc_oversampling_ratio_set
Add support for setting decimation rate. Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com> Link: https://patch.msgid.link/20250605150948.3091827-4-pop.ioan-daniel@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 69f00e4 commit aaa2f1c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/iio/adc/adi-axi-adc.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
#define ADI_AXI_ADC_REG_CHAN_CTRL_3(c) (0x0418 + (c) * 0x40)
8787
#define ADI_AXI_ADC_CHAN_PN_SEL_MASK GENMASK(19, 16)
8888

89+
#define ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(c) (0x0424 + (c) * 0x40)
90+
#define ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK GENMASK(15, 0)
91+
8992
/* IO Delays */
9093
#define ADI_AXI_ADC_REG_DELAY(l) (0x0800 + (l) * 0x4)
9194
#define AXI_ADC_DELAY_CTRL_MASK GENMASK(4, 0)
@@ -248,6 +251,19 @@ static int axi_adc_test_pattern_set(struct iio_backend *back,
248251
}
249252
}
250253

254+
static int axi_adc_oversampling_ratio_set(struct iio_backend *back,
255+
unsigned int chan,
256+
unsigned int rate)
257+
{
258+
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
259+
260+
return regmap_update_bits(st->regmap,
261+
ADI_AXI_ADC_REG_CHAN_USR_CTRL_2(chan),
262+
ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK,
263+
FIELD_PREP(ADI_AXI_ADC_CHAN_USR_CTRL_2_DEC_RATE_N_MASK,
264+
rate));
265+
}
266+
251267
static int axi_adc_read_chan_status(struct adi_axi_adc_state *st, unsigned int chan,
252268
unsigned int *status)
253269
{
@@ -600,6 +616,7 @@ static const struct iio_backend_ops adi_axi_adc_ops = {
600616
.test_pattern_set = axi_adc_test_pattern_set,
601617
.chan_status = axi_adc_chan_status,
602618
.interface_type_get = axi_adc_interface_type_get,
619+
.oversampling_ratio_set = axi_adc_oversampling_ratio_set,
603620
.debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access),
604621
.debugfs_print_chan_status = iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status),
605622
};

0 commit comments

Comments
 (0)