Lines Matching +full:axi +full:- +full:adc +full:- +full:10

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Analog Devices Generic AXI ADC IP core
6 * Copyright 2012-2020 Analog Devices Inc.
23 #include <linux/fpga/adi-axi-common.h>
26 #include <linux/iio/buffer-dmaengine.h>
35 /* ADC controls */
48 /* ADC Channel controls */
52 #define ADI_AXI_REG_CHAN_CTRL_PN_SEL_OWR BIT(10)
96 guard(mutex)(&st->lock); in axi_adc_enable()
97 ret = regmap_set_bits(st->regmap, ADI_AXI_REG_RSTN, in axi_adc_enable()
107 ret = regmap_read_poll_timeout(st->regmap, ADI_AXI_ADC_REG_DRP_STATUS, in axi_adc_enable()
113 return regmap_set_bits(st->regmap, ADI_AXI_REG_RSTN, in axi_adc_enable()
121 guard(mutex)(&st->lock); in axi_adc_disable()
122 regmap_write(st->regmap, ADI_AXI_REG_RSTN, 0); in axi_adc_disable()
131 if (!data->enable) in axi_adc_data_format_set()
132 return regmap_clear_bits(st->regmap, in axi_adc_data_format_set()
137 if (data->sign_extend) in axi_adc_data_format_set()
139 if (data->type == IIO_BACKEND_OFFSET_BINARY) in axi_adc_data_format_set()
142 return regmap_update_bits(st->regmap, ADI_AXI_REG_CHAN_CTRL(chan), in axi_adc_data_format_set()
153 return regmap_clear_bits(st->regmap, ADI_AXI_ADC_REG_CTRL, in axi_adc_data_sample_trigger()
156 return regmap_set_bits(st->regmap, ADI_AXI_ADC_REG_CTRL, in axi_adc_data_sample_trigger()
159 return -EINVAL; in axi_adc_data_sample_trigger()
171 return -EINVAL; in axi_adc_iodelays_set()
173 return -EINVAL; in axi_adc_iodelays_set()
175 guard(mutex)(&st->lock); in axi_adc_iodelays_set()
176 ret = regmap_write(st->regmap, ADI_AXI_ADC_REG_DELAY(lane), tap); in axi_adc_iodelays_set()
183 ret = regmap_read(st->regmap, ADI_AXI_ADC_REG_DELAY(lane), &val); in axi_adc_iodelays_set()
187 return -EIO; in axi_adc_iodelays_set()
203 return regmap_update_bits(st->regmap, ADI_AXI_ADC_REG_CHAN_CTRL_3(chan), in axi_adc_test_pattern_set()
207 return regmap_update_bits(st->regmap, ADI_AXI_ADC_REG_CHAN_CTRL_3(chan), in axi_adc_test_pattern_set()
211 return -EINVAL; in axi_adc_test_pattern_set()
220 guard(mutex)(&st->lock); in axi_adc_read_chan_status()
222 ret = regmap_write(st->regmap, ADI_AXI_ADC_REG_CHAN_STATUS(chan), in axi_adc_read_chan_status()
230 return regmap_read(st->regmap, ADI_AXI_ADC_REG_CHAN_STATUS(chan), in axi_adc_read_chan_status()
281 return regmap_set_bits(st->regmap, ADI_AXI_REG_CHAN_CTRL(chan), in axi_adc_chan_enable()
289 return regmap_clear_bits(st->regmap, ADI_AXI_REG_CHAN_CTRL(chan), in axi_adc_chan_disable()
299 if (device_property_read_string(st->dev, "dma-names", &dma_name)) in axi_adc_request_buffer()
302 return iio_dmaengine_buffer_setup(st->dev, indio_dev, dma_name); in axi_adc_request_buffer()
317 return regmap_read(st->regmap, reg, readval); in axi_adc_reg_access()
319 return regmap_write(st->regmap, reg, writeval); in axi_adc_reg_access()
345 .name = "axi-adc",
358 st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL); in adi_axi_adc_probe()
360 return -ENOMEM; in adi_axi_adc_probe()
366 st->dev = &pdev->dev; in adi_axi_adc_probe()
367 st->regmap = devm_regmap_init_mmio(&pdev->dev, base, in adi_axi_adc_probe()
369 if (IS_ERR(st->regmap)) in adi_axi_adc_probe()
370 return dev_err_probe(&pdev->dev, PTR_ERR(st->regmap), in adi_axi_adc_probe()
373 expected_ver = device_get_match_data(&pdev->dev); in adi_axi_adc_probe()
375 return -ENODEV; in adi_axi_adc_probe()
377 clk = devm_clk_get_enabled(&pdev->dev, NULL); in adi_axi_adc_probe()
379 return dev_err_probe(&pdev->dev, PTR_ERR(clk), in adi_axi_adc_probe()
386 ret = regmap_write(st->regmap, ADI_AXI_REG_RSTN, 0); in adi_axi_adc_probe()
390 ret = regmap_read(st->regmap, ADI_AXI_REG_VERSION, &ver); in adi_axi_adc_probe()
395 dev_err(&pdev->dev, in adi_axi_adc_probe()
403 return -ENODEV; in adi_axi_adc_probe()
406 ret = devm_iio_backend_register(&pdev->dev, &adi_axi_adc_generic, st); in adi_axi_adc_probe()
408 return dev_err_probe(&pdev->dev, ret, in adi_axi_adc_probe()
411 dev_info(&pdev->dev, "AXI ADC IP core (%d.%.2d.%c) probed\n", in adi_axi_adc_probe()
419 static unsigned int adi_axi_adc_10_0_a_info = ADI_AXI_PCORE_VER(10, 0, 'a');
423 { .compatible = "adi,axi-adc-10.0.a", .data = &adi_axi_adc_10_0_a_info },
438 MODULE_DESCRIPTION("Analog Devices Generic AXI ADC IP core driver");