Skip to content

Commit 683e3f6

Browse files
committed
iio: adc: adi-axi-adc: add interface type
Add support for getting the interface (CMOS or LVDS) used by the AXI ADC ip. Signed-off-by: Antoniu Miclaus <[email protected]>
1 parent 18e7ad3 commit 683e3f6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#define ADI_AXI_REG_RSTN_MMCM_RSTN BIT(1)
4040
#define ADI_AXI_REG_RSTN_RSTN BIT(0)
4141

42+
#define ADI_AXI_ADC_REG_CONFIG 0x000c
43+
#define ADI_AXI_ADC_REG_CONFIG_CMOS_OR_LVDS_N BIT(7)
44+
4245
#define ADI_AXI_ADC_REG_CTRL 0x0044
4346
#define ADI_AXI_ADC_CTRL_DDR_EDGESEL_MASK BIT(1)
4447

@@ -233,6 +236,25 @@ static int axi_adc_chan_disable(struct iio_backend *back, unsigned int chan)
233236
ADI_AXI_REG_CHAN_CTRL_ENABLE);
234237
}
235238

239+
static int axi_adc_interface_type_get(struct iio_backend *back,
240+
enum iio_backend_interface_type *type)
241+
{
242+
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
243+
unsigned int val;
244+
int ret;
245+
246+
ret = regmap_read(st->regmap, ADI_AXI_ADC_REG_CONFIG, &val);
247+
if (ret)
248+
return ret;
249+
250+
if (val & ADI_AXI_ADC_REG_CONFIG_CMOS_OR_LVDS_N)
251+
*type = IIO_BACKEND_INTERFACE_CMOS;
252+
else
253+
*type = IIO_BACKEND_INTERFACE_LVDS;
254+
255+
return 0;
256+
}
257+
236258
static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back,
237259
struct iio_dev *indio_dev)
238260
{
@@ -269,6 +291,7 @@ static const struct iio_backend_ops adi_axi_adc_generic = {
269291
.iodelay_set = axi_adc_iodelays_set,
270292
.test_pattern_set = axi_adc_test_pattern_set,
271293
.chan_status = axi_adc_chan_status,
294+
.interface_type_get = axi_adc_interface_type_get,
272295
};
273296

274297
static int adi_axi_adc_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)