Skip to content

Commit 13807bd

Browse files
committed
iio: adc: adi-axi-adc: set data format
Add support for selecting the data format within the AXI ADC ip. Signed-off-by: Antoniu Miclaus <[email protected]>
1 parent 683e3f6 commit 13807bd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#define ADI_AXI_ADC_REG_CTRL 0x0044
4646
#define ADI_AXI_ADC_CTRL_DDR_EDGESEL_MASK BIT(1)
4747

48+
#define ADI_AXI_ADC_REG_CNTRL_3 0x004c
49+
4850
/* ADC Channel controls */
4951

5052
#define ADI_AXI_REG_CHAN_CTRL(c) (0x0400 + (c) * 0x40)
@@ -255,6 +257,24 @@ static int axi_adc_interface_type_get(struct iio_backend *back,
255257
return 0;
256258
}
257259

260+
static int axi_adc_data_size_set(struct iio_backend *back,
261+
ssize_t size)
262+
{
263+
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
264+
unsigned int val;
265+
266+
if (size <= 20)
267+
val = 0;
268+
else if (size <= 24)
269+
val = 1;
270+
else if (size <= 32)
271+
val = 3;
272+
else
273+
return -EINVAL;
274+
275+
return regmap_write(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, val);
276+
}
277+
258278
static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back,
259279
struct iio_dev *indio_dev)
260280
{
@@ -292,6 +312,7 @@ static const struct iio_backend_ops adi_axi_adc_generic = {
292312
.test_pattern_set = axi_adc_test_pattern_set,
293313
.chan_status = axi_adc_chan_status,
294314
.interface_type_get = axi_adc_interface_type_get,
315+
.data_size_set = axi_adc_data_size_set,
295316
};
296317

297318
static int adi_axi_adc_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)