Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: adi-axi-adc: add oversampling

Add support for enabling/disabling oversampling.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-8-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Antoniu Miclaus and committed by
Jonathan Cameron
208a94c8 7a794e3a

+24
+24
drivers/iio/adc/adi-axi-adc.c
··· 47 47 #define ADI_AXI_ADC_CTRL_DDR_EDGESEL_MASK BIT(1) 48 48 49 49 #define ADI_AXI_ADC_REG_CNTRL_3 0x004c 50 + #define AXI_AD485X_CNTRL_3_OS_EN_MSK BIT(2) 50 51 #define AXI_AD485X_CNTRL_3_PACKET_FORMAT_MSK GENMASK(1, 0) 51 52 #define AXI_AD485X_PACKET_FORMAT_20BIT 0x0 52 53 #define AXI_AD485X_PACKET_FORMAT_24BIT 0x1 ··· 380 379 FIELD_PREP(AXI_AD485X_CNTRL_3_PACKET_FORMAT_MSK, val)); 381 380 } 382 381 382 + static int axi_adc_ad485x_oversampling_ratio_set(struct iio_backend *back, 383 + unsigned int ratio) 384 + { 385 + struct adi_axi_adc_state *st = iio_backend_get_priv(back); 386 + 387 + /* The current state of the function enables or disables the 388 + * oversampling in REG_CNTRL_3 register. A ratio equal to 1 implies no 389 + * oversampling, while a value greater than 1 implies oversampling being 390 + * enabled. 391 + */ 392 + switch (ratio) { 393 + case 0: 394 + return -EINVAL; 395 + case 1: 396 + return regmap_clear_bits(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, 397 + AXI_AD485X_CNTRL_3_OS_EN_MSK); 398 + default: 399 + return regmap_set_bits(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, 400 + AXI_AD485X_CNTRL_3_OS_EN_MSK); 401 + } 402 + } 403 + 383 404 static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, 384 405 struct iio_dev *indio_dev) 385 406 { ··· 571 548 .chan_status = axi_adc_chan_status, 572 549 .interface_type_get = axi_adc_interface_type_get, 573 550 .data_size_set = axi_adc_ad485x_data_size_set, 551 + .oversampling_ratio_set = axi_adc_ad485x_oversampling_ratio_set, 574 552 .debugfs_reg_access = iio_backend_debugfs_ptr(axi_adc_reg_access), 575 553 .debugfs_print_chan_status = 576 554 iio_backend_debugfs_ptr(axi_adc_debugfs_print_chan_status),