1 // SPDX-License-Identifier: GPL-2.0-only
3 * Analog Devices AD9467 SPI ADC driver
5 * Copyright 2012-2020 Analog Devices Inc.
8 #include <linux/bitmap.h>
9 #include <linux/bitops.h>
10 #include <linux/cleanup.h>
11 #include <linux/debugfs.h>
12 #include <linux/module.h>
13 #include <linux/mutex.h>
14 #include <linux/device.h>
15 #include <linux/kernel.h>
16 #include <linux/slab.h>
17 #include <linux/spi/spi.h>
18 #include <linux/err.h>
19 #include <linux/delay.h>
20 #include <linux/gpio/consumer.h>
24 #include <linux/iio/backend.h>
25 #include <linux/iio/iio.h>
26 #include <linux/iio/sysfs.h>
28 #include <linux/clk.h>
31 * ADI High-Speed ADC common spi interface registers
32 * See Application-Note AN-877:
33 * https://www.analog.com/media/en/technical-documentation/application-notes/AN-877.pdf
36 #define AN877_ADC_REG_CHIP_PORT_CONF 0x00
37 #define AN877_ADC_REG_CHIP_ID 0x01
38 #define AN877_ADC_REG_CHIP_GRADE 0x02
39 #define AN877_ADC_REG_CHAN_INDEX 0x05
40 #define AN877_ADC_REG_TRANSFER 0xFF
41 #define AN877_ADC_REG_MODES 0x08
42 #define AN877_ADC_REG_TEST_IO 0x0D
43 #define AN877_ADC_REG_ADC_INPUT 0x0F
44 #define AN877_ADC_REG_OFFSET 0x10
45 #define AN877_ADC_REG_OUTPUT_MODE 0x14
46 #define AN877_ADC_REG_OUTPUT_ADJUST 0x15
47 #define AN877_ADC_REG_OUTPUT_PHASE 0x16
48 #define AN877_ADC_REG_OUTPUT_DELAY 0x17
49 #define AN877_ADC_REG_VREF 0x18
50 #define AN877_ADC_REG_ANALOG_INPUT 0x2C
52 /* AN877_ADC_REG_TEST_IO */
53 #define AN877_ADC_TESTMODE_OFF 0x0
54 #define AN877_ADC_TESTMODE_MIDSCALE_SHORT 0x1
55 #define AN877_ADC_TESTMODE_POS_FULLSCALE 0x2
56 #define AN877_ADC_TESTMODE_NEG_FULLSCALE 0x3
57 #define AN877_ADC_TESTMODE_ALT_CHECKERBOARD 0x4
58 #define AN877_ADC_TESTMODE_PN23_SEQ 0x5
59 #define AN877_ADC_TESTMODE_PN9_SEQ 0x6
60 #define AN877_ADC_TESTMODE_ONE_ZERO_TOGGLE 0x7
61 #define AN877_ADC_TESTMODE_USER 0x8
62 #define AN877_ADC_TESTMODE_BIT_TOGGLE 0x9
63 #define AN877_ADC_TESTMODE_SYNC 0xA
64 #define AN877_ADC_TESTMODE_ONE_BIT_HIGH 0xB
65 #define AN877_ADC_TESTMODE_MIXED_BIT_FREQUENCY 0xC
66 #define AN877_ADC_TESTMODE_RAMP 0xF
68 /* AN877_ADC_REG_TRANSFER */
69 #define AN877_ADC_TRANSFER_SYNC 0x1
71 /* AN877_ADC_REG_OUTPUT_MODE */
72 #define AN877_ADC_OUTPUT_MODE_OFFSET_BINARY 0x0
73 #define AN877_ADC_OUTPUT_MODE_TWOS_COMPLEMENT 0x1
74 #define AN877_ADC_OUTPUT_MODE_GRAY_CODE 0x2
76 /* AN877_ADC_REG_OUTPUT_PHASE */
77 #define AN877_ADC_OUTPUT_EVEN_ODD_MODE_EN 0x20
78 #define AN877_ADC_INVERT_DCO_CLK 0x80
80 /* AN877_ADC_REG_OUTPUT_DELAY */
81 #define AN877_ADC_DCO_DELAY_ENABLE 0x80
84 * Analog Devices AD9265 16-Bit, 125/105/80 MSPS ADC
87 #define CHIPID_AD9265 0x64
88 #define AD9265_DEF_OUTPUT_MODE 0x40
89 #define AD9265_REG_VREF_MASK 0xC0
92 * Analog Devices AD9434 12-Bit, 370/500 MSPS ADC
95 #define CHIPID_AD9434 0x6A
96 #define AD9434_DEF_OUTPUT_MODE 0x00
97 #define AD9434_REG_VREF_MASK 0xC0
100 * Analog Devices AD9467 16-Bit, 200/250 MSPS ADC
103 #define CHIPID_AD9467 0x50
104 #define AD9467_DEF_OUTPUT_MODE 0x08
105 #define AD9467_REG_VREF_MASK 0x0F
107 #define AD9647_MAX_TEST_POINTS 32
109 struct ad9467_chip_info {
112 const struct iio_chan_spec *channels;
113 unsigned int num_channels;
114 const unsigned int (*scale_table)[2];
116 unsigned long max_rate;
117 unsigned int default_output_mode;
118 unsigned int vref_mask;
119 unsigned int num_lanes;
120 /* data clock output */
124 struct ad9467_state {
125 const struct ad9467_chip_info *info;
126 struct iio_backend *back;
127 struct spi_device *spi;
129 unsigned int output_mode;
130 unsigned int (*scales)[2];
132 * Times 2 because we may also invert the signal polarity and run the
133 * calibration again. For some reference on the test points (ad9265) see:
134 * https://www.analog.com/media/en/technical-documentation/data-sheets/ad9265.pdf
135 * at page 38 for the dco output delay. On devices as ad9467, the
136 * calibration is done at the backend level. For the ADI axi-adc:
137 * https://wiki.analog.com/resources/fpga/docs/axi_adc_ip
138 * at the io delay control section.
140 DECLARE_BITMAP(calib_map, AD9647_MAX_TEST_POINTS * 2);
141 struct gpio_desc *pwrdown_gpio;
142 /* ensure consistent state obtained on multiple related accesses */
144 u8 buf[3] __aligned(IIO_DMA_MINALIGN);
147 static int ad9467_spi_read(struct ad9467_state *st, unsigned int reg)
149 unsigned char tbuf[2], rbuf[1];
152 tbuf[0] = 0x80 | (reg >> 8);
153 tbuf[1] = reg & 0xFF;
155 ret = spi_write_then_read(st->spi,
156 tbuf, ARRAY_SIZE(tbuf),
157 rbuf, ARRAY_SIZE(rbuf));
165 static int ad9467_spi_write(struct ad9467_state *st, unsigned int reg,
168 st->buf[0] = reg >> 8;
169 st->buf[1] = reg & 0xFF;
172 return spi_write(st->spi, st->buf, ARRAY_SIZE(st->buf));
175 static int ad9467_reg_access(struct iio_dev *indio_dev, unsigned int reg,
176 unsigned int writeval, unsigned int *readval)
178 struct ad9467_state *st = iio_priv(indio_dev);
182 guard(mutex)(&st->lock);
183 ret = ad9467_spi_write(st, reg, writeval);
186 return ad9467_spi_write(st, AN877_ADC_REG_TRANSFER,
187 AN877_ADC_TRANSFER_SYNC);
190 ret = ad9467_spi_read(st, reg);
198 static const unsigned int ad9265_scale_table[][2] = {
199 {1250, 0x00}, {1500, 0x40}, {1750, 0x80}, {2000, 0xC0},
202 static const unsigned int ad9434_scale_table[][2] = {
203 {1600, 0x1C}, {1580, 0x1D}, {1550, 0x1E}, {1520, 0x1F}, {1500, 0x00},
204 {1470, 0x01}, {1440, 0x02}, {1420, 0x03}, {1390, 0x04}, {1360, 0x05},
205 {1340, 0x06}, {1310, 0x07}, {1280, 0x08}, {1260, 0x09}, {1230, 0x0A},
206 {1200, 0x0B}, {1180, 0x0C},
209 static const unsigned int ad9467_scale_table[][2] = {
210 {2000, 0}, {2100, 6}, {2200, 7},
211 {2300, 8}, {2400, 9}, {2500, 10},
214 static void __ad9467_get_scale(struct ad9467_state *st, int index,
215 unsigned int *val, unsigned int *val2)
217 const struct ad9467_chip_info *info = st->info;
218 const struct iio_chan_spec *chan = &info->channels[0];
221 tmp = (info->scale_table[index][0] * 1000000ULL) >>
222 chan->scan_type.realbits;
223 *val = tmp / 1000000;
224 *val2 = tmp % 1000000;
227 #define AD9467_CHAN(_chan, _si, _bits, _sign) \
229 .type = IIO_VOLTAGE, \
232 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
233 BIT(IIO_CHAN_INFO_SAMP_FREQ), \
234 .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE), \
243 static const struct iio_chan_spec ad9434_channels[] = {
244 AD9467_CHAN(0, 0, 12, 's'),
247 static const struct iio_chan_spec ad9467_channels[] = {
248 AD9467_CHAN(0, 0, 16, 's'),
251 static const struct ad9467_chip_info ad9467_chip_tbl = {
254 .max_rate = 250000000UL,
255 .scale_table = ad9467_scale_table,
256 .num_scales = ARRAY_SIZE(ad9467_scale_table),
257 .channels = ad9467_channels,
258 .num_channels = ARRAY_SIZE(ad9467_channels),
259 .default_output_mode = AD9467_DEF_OUTPUT_MODE,
260 .vref_mask = AD9467_REG_VREF_MASK,
264 static const struct ad9467_chip_info ad9434_chip_tbl = {
267 .max_rate = 500000000UL,
268 .scale_table = ad9434_scale_table,
269 .num_scales = ARRAY_SIZE(ad9434_scale_table),
270 .channels = ad9434_channels,
271 .num_channels = ARRAY_SIZE(ad9434_channels),
272 .default_output_mode = AD9434_DEF_OUTPUT_MODE,
273 .vref_mask = AD9434_REG_VREF_MASK,
277 static const struct ad9467_chip_info ad9265_chip_tbl = {
280 .max_rate = 125000000UL,
281 .scale_table = ad9265_scale_table,
282 .num_scales = ARRAY_SIZE(ad9265_scale_table),
283 .channels = ad9467_channels,
284 .num_channels = ARRAY_SIZE(ad9467_channels),
285 .default_output_mode = AD9265_DEF_OUTPUT_MODE,
286 .vref_mask = AD9265_REG_VREF_MASK,
290 static int ad9467_get_scale(struct ad9467_state *st, int *val, int *val2)
292 const struct ad9467_chip_info *info = st->info;
293 unsigned int i, vref_val;
296 ret = ad9467_spi_read(st, AN877_ADC_REG_VREF);
300 vref_val = ret & info->vref_mask;
302 for (i = 0; i < info->num_scales; i++) {
303 if (vref_val == info->scale_table[i][1])
307 if (i == info->num_scales)
310 __ad9467_get_scale(st, i, val, val2);
312 return IIO_VAL_INT_PLUS_MICRO;
315 static int ad9467_set_scale(struct ad9467_state *st, int val, int val2)
317 const struct ad9467_chip_info *info = st->info;
318 unsigned int scale_val[2];
325 for (i = 0; i < info->num_scales; i++) {
326 __ad9467_get_scale(st, i, &scale_val[0], &scale_val[1]);
327 if (scale_val[0] != val || scale_val[1] != val2)
330 guard(mutex)(&st->lock);
331 ret = ad9467_spi_write(st, AN877_ADC_REG_VREF,
332 info->scale_table[i][1]);
336 return ad9467_spi_write(st, AN877_ADC_REG_TRANSFER,
337 AN877_ADC_TRANSFER_SYNC);
343 static int ad9467_outputmode_set(struct ad9467_state *st, unsigned int mode)
347 ret = ad9467_spi_write(st, AN877_ADC_REG_OUTPUT_MODE, mode);
351 return ad9467_spi_write(st, AN877_ADC_REG_TRANSFER,
352 AN877_ADC_TRANSFER_SYNC);
355 static int ad9647_calibrate_prepare(struct ad9467_state *st)
357 struct iio_backend_data_fmt data = {
363 ret = ad9467_spi_write(st, AN877_ADC_REG_TEST_IO,
364 AN877_ADC_TESTMODE_PN9_SEQ);
368 ret = ad9467_spi_write(st, AN877_ADC_REG_TRANSFER,
369 AN877_ADC_TRANSFER_SYNC);
373 ret = ad9467_outputmode_set(st, st->info->default_output_mode);
377 for (c = 0; c < st->info->num_channels; c++) {
378 ret = iio_backend_data_format_set(st->back, c, &data);
383 ret = iio_backend_test_pattern_set(st->back, 0,
384 IIO_BACKEND_ADI_PRBS_9A);
388 return iio_backend_chan_enable(st->back, 0);
391 static int ad9647_calibrate_polarity_set(struct ad9467_state *st,
394 enum iio_backend_sample_trigger trigger;
396 if (st->info->has_dco) {
397 unsigned int phase = AN877_ADC_OUTPUT_EVEN_ODD_MODE_EN;
400 phase |= AN877_ADC_INVERT_DCO_CLK;
402 return ad9467_spi_write(st, AN877_ADC_REG_OUTPUT_PHASE,
407 trigger = IIO_BACKEND_SAMPLE_TRIGGER_EDGE_FALLING;
409 trigger = IIO_BACKEND_SAMPLE_TRIGGER_EDGE_RISING;
411 return iio_backend_data_sample_trigger(st->back, trigger);
415 * The idea is pretty simple. Find the max number of successful points in a row
416 * and get the one in the middle.
418 static unsigned int ad9467_find_optimal_point(const unsigned long *calib_map,
423 unsigned int bit = start, end, start_cnt, cnt = 0;
425 for_each_clear_bitrange_from(bit, end, calib_map, nbits + start) {
426 if (end - bit > cnt) {
433 *val = start_cnt + cnt / 2;
438 static int ad9467_calibrate_apply(struct ad9467_state *st, unsigned int val)
443 if (st->info->has_dco) {
444 ret = ad9467_spi_write(st, AN877_ADC_REG_OUTPUT_DELAY,
449 return ad9467_spi_write(st, AN877_ADC_REG_TRANSFER,
450 AN877_ADC_TRANSFER_SYNC);
453 for (lane = 0; lane < st->info->num_lanes; lane++) {
454 ret = iio_backend_iodelay_set(st->back, lane, val);
462 static int ad9647_calibrate_stop(struct ad9467_state *st)
464 struct iio_backend_data_fmt data = {
468 unsigned int c, mode;
471 ret = iio_backend_chan_disable(st->back, 0);
475 ret = iio_backend_test_pattern_set(st->back, 0,
476 IIO_BACKEND_NO_TEST_PATTERN);
480 for (c = 0; c < st->info->num_channels; c++) {
481 ret = iio_backend_data_format_set(st->back, c, &data);
486 mode = st->info->default_output_mode | AN877_ADC_OUTPUT_MODE_TWOS_COMPLEMENT;
487 ret = ad9467_outputmode_set(st, mode);
491 ret = ad9467_spi_write(st, AN877_ADC_REG_TEST_IO,
492 AN877_ADC_TESTMODE_OFF);
496 return ad9467_spi_write(st, AN877_ADC_REG_TRANSFER,
497 AN877_ADC_TRANSFER_SYNC);
500 static int ad9467_calibrate(struct ad9467_state *st)
502 unsigned int point, val, inv_val, cnt, inv_cnt = 0;
504 * Half of the bitmap is for the inverted signal. The number of test
505 * points is the same though...
507 unsigned int test_points = AD9647_MAX_TEST_POINTS;
508 unsigned long sample_rate = clk_get_rate(st->clk);
509 struct device *dev = &st->spi->dev;
510 bool invert = false, stat;
513 /* all points invalid */
514 bitmap_fill(st->calib_map, BITS_PER_TYPE(st->calib_map));
516 ret = ad9647_calibrate_prepare(st);
520 ret = ad9647_calibrate_polarity_set(st, invert);
524 for (point = 0; point < test_points; point++) {
525 ret = ad9467_calibrate_apply(st, point);
529 ret = iio_backend_chan_status(st->back, 0, &stat);
533 __assign_bit(point + invert * test_points, st->calib_map, stat);
537 cnt = ad9467_find_optimal_point(st->calib_map, 0, test_points,
540 * We're happy if we find, at least, three good test points in
548 inv_cnt = ad9467_find_optimal_point(st->calib_map, test_points,
549 test_points, &inv_val);
550 if (!inv_cnt && !cnt)
555 ret = ad9647_calibrate_polarity_set(st, false);
560 * polarity inverted is the last test to run. Hence, there's no
561 * need to re-do any configuration. We just need to "normalize"
562 * the selected value.
564 val = inv_val - test_points;
567 if (st->info->has_dco)
568 dev_dbg(dev, "%sDCO 0x%X CLK %lu Hz\n", inv_cnt >= cnt ? "INVERT " : "",
571 dev_dbg(dev, "%sIDELAY 0x%x\n", inv_cnt >= cnt ? "INVERT " : "",
574 ret = ad9467_calibrate_apply(st, val);
578 /* finally apply the optimal value */
579 return ad9647_calibrate_stop(st);
582 static int ad9467_read_raw(struct iio_dev *indio_dev,
583 struct iio_chan_spec const *chan,
584 int *val, int *val2, long m)
586 struct ad9467_state *st = iio_priv(indio_dev);
589 case IIO_CHAN_INFO_SCALE:
590 return ad9467_get_scale(st, val, val2);
591 case IIO_CHAN_INFO_SAMP_FREQ:
592 *val = clk_get_rate(st->clk);
600 static int ad9467_write_raw(struct iio_dev *indio_dev,
601 struct iio_chan_spec const *chan,
602 int val, int val2, long mask)
604 struct ad9467_state *st = iio_priv(indio_dev);
605 const struct ad9467_chip_info *info = st->info;
606 unsigned long sample_rate;
611 case IIO_CHAN_INFO_SCALE:
612 return ad9467_set_scale(st, val, val2);
613 case IIO_CHAN_INFO_SAMP_FREQ:
614 r_clk = clk_round_rate(st->clk, val);
615 if (r_clk < 0 || r_clk > info->max_rate) {
616 dev_warn(&st->spi->dev,
617 "Error setting ADC sample rate %ld", r_clk);
621 sample_rate = clk_get_rate(st->clk);
623 * clk_set_rate() would also do this but since we would still
624 * need it for avoiding an unnecessary calibration, do it now.
626 if (sample_rate == r_clk)
629 iio_device_claim_direct_scoped(return -EBUSY, indio_dev) {
630 ret = clk_set_rate(st->clk, r_clk);
634 guard(mutex)(&st->lock);
635 ret = ad9467_calibrate(st);
643 static int ad9467_read_avail(struct iio_dev *indio_dev,
644 struct iio_chan_spec const *chan,
645 const int **vals, int *type, int *length,
648 struct ad9467_state *st = iio_priv(indio_dev);
649 const struct ad9467_chip_info *info = st->info;
652 case IIO_CHAN_INFO_SCALE:
653 *vals = (const int *)st->scales;
654 *type = IIO_VAL_INT_PLUS_MICRO;
655 /* Values are stored in a 2D matrix */
656 *length = info->num_scales * 2;
657 return IIO_AVAIL_LIST;
663 static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
664 const unsigned long *scan_mask)
666 struct ad9467_state *st = iio_priv(indio_dev);
670 for (c = 0; c < st->info->num_channels; c++) {
671 if (test_bit(c, scan_mask))
672 ret = iio_backend_chan_enable(st->back, c);
674 ret = iio_backend_chan_disable(st->back, c);
682 static const struct iio_info ad9467_info = {
683 .read_raw = ad9467_read_raw,
684 .write_raw = ad9467_write_raw,
685 .update_scan_mode = ad9467_update_scan_mode,
686 .debugfs_reg_access = ad9467_reg_access,
687 .read_avail = ad9467_read_avail,
690 static int ad9467_scale_fill(struct ad9467_state *st)
692 const struct ad9467_chip_info *info = st->info;
693 unsigned int i, val1, val2;
695 st->scales = devm_kmalloc_array(&st->spi->dev, info->num_scales,
696 sizeof(*st->scales), GFP_KERNEL);
700 for (i = 0; i < info->num_scales; i++) {
701 __ad9467_get_scale(st, i, &val1, &val2);
702 st->scales[i][0] = val1;
703 st->scales[i][1] = val2;
709 static int ad9467_reset(struct device *dev)
711 struct gpio_desc *gpio;
713 gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
714 if (IS_ERR_OR_NULL(gpio))
715 return PTR_ERR_OR_ZERO(gpio);
718 gpiod_set_value_cansleep(gpio, 0);
719 fsleep(10 * USEC_PER_MSEC);
724 static int ad9467_iio_backend_get(struct ad9467_state *st)
726 struct device *dev = &st->spi->dev;
727 struct device_node *__back;
729 st->back = devm_iio_backend_get(dev, NULL);
730 if (!IS_ERR(st->back))
732 /* If not found, don't error out as we might have legacy DT property */
733 if (PTR_ERR(st->back) != -ENOENT)
734 return PTR_ERR(st->back);
737 * if we don't get the backend using the normal API's, use the legacy
738 * 'adi,adc-dev' property. So we get all nodes with that property, and
739 * look for the one pointing at us. Then we directly lookup that fwnode
740 * on the backend list of registered devices. This is done so we don't
741 * make io-backends mandatory which would break DT ABI.
743 for_each_node_with_property(__back, "adi,adc-dev") {
744 struct device_node *__me;
746 __me = of_parse_phandle(__back, "adi,adc-dev", 0);
750 if (!device_match_of_node(dev, __me)) {
756 st->back = __devm_iio_backend_get_from_fwnode_lookup(dev,
757 of_fwnode_handle(__back));
759 return PTR_ERR_OR_ZERO(st->back);
765 static ssize_t ad9467_dump_calib_table(struct file *file,
766 char __user *userbuf,
767 size_t count, loff_t *ppos)
769 struct ad9467_state *st = file->private_data;
770 unsigned int bit, size = BITS_PER_TYPE(st->calib_map);
771 /* +2 for the newline and +1 for the string termination */
772 unsigned char map[AD9647_MAX_TEST_POINTS * 2 + 3];
775 guard(mutex)(&st->lock);
779 for (bit = 0; bit < size; bit++) {
781 len += scnprintf(map + len, sizeof(map) - len, "\n");
783 len += scnprintf(map + len, sizeof(map) - len, "%c",
784 test_bit(bit, st->calib_map) ? 'x' : 'o');
787 len += scnprintf(map + len, sizeof(map) - len, "\n");
789 return simple_read_from_buffer(userbuf, count, ppos, map, len);
792 static const struct file_operations ad9467_calib_table_fops = {
794 .read = ad9467_dump_calib_table,
795 .llseek = default_llseek,
796 .owner = THIS_MODULE,
799 static void ad9467_debugfs_init(struct iio_dev *indio_dev)
801 struct dentry *d = iio_get_debugfs_dentry(indio_dev);
802 struct ad9467_state *st = iio_priv(indio_dev);
804 if (!IS_ENABLED(CONFIG_DEBUG_FS))
807 debugfs_create_file("calibration_table_dump", 0400, d, st,
808 &ad9467_calib_table_fops);
811 static int ad9467_probe(struct spi_device *spi)
813 struct iio_dev *indio_dev;
814 struct ad9467_state *st;
818 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
822 st = iio_priv(indio_dev);
825 st->info = spi_get_device_match_data(spi);
829 st->clk = devm_clk_get_enabled(&spi->dev, "adc-clk");
831 return PTR_ERR(st->clk);
833 st->pwrdown_gpio = devm_gpiod_get_optional(&spi->dev, "powerdown",
835 if (IS_ERR(st->pwrdown_gpio))
836 return PTR_ERR(st->pwrdown_gpio);
838 ret = ad9467_reset(&spi->dev);
842 ret = ad9467_scale_fill(st);
846 id = ad9467_spi_read(st, AN877_ADC_REG_CHIP_ID);
847 if (id != st->info->id) {
848 dev_err(&spi->dev, "Mismatch CHIP_ID, got 0x%X, expected 0x%X\n",
853 indio_dev->name = st->info->name;
854 indio_dev->channels = st->info->channels;
855 indio_dev->num_channels = st->info->num_channels;
856 indio_dev->info = &ad9467_info;
858 ret = ad9467_iio_backend_get(st);
862 ret = devm_iio_backend_request_buffer(&spi->dev, st->back, indio_dev);
866 ret = devm_iio_backend_enable(&spi->dev, st->back);
870 ret = ad9467_calibrate(st);
874 ret = devm_iio_device_register(&spi->dev, indio_dev);
878 ad9467_debugfs_init(indio_dev);
883 static const struct of_device_id ad9467_of_match[] = {
884 { .compatible = "adi,ad9265", .data = &ad9265_chip_tbl, },
885 { .compatible = "adi,ad9434", .data = &ad9434_chip_tbl, },
886 { .compatible = "adi,ad9467", .data = &ad9467_chip_tbl, },
889 MODULE_DEVICE_TABLE(of, ad9467_of_match);
891 static const struct spi_device_id ad9467_ids[] = {
892 { "ad9265", (kernel_ulong_t)&ad9265_chip_tbl },
893 { "ad9434", (kernel_ulong_t)&ad9434_chip_tbl },
894 { "ad9467", (kernel_ulong_t)&ad9467_chip_tbl },
897 MODULE_DEVICE_TABLE(spi, ad9467_ids);
899 static struct spi_driver ad9467_driver = {
902 .of_match_table = ad9467_of_match,
904 .probe = ad9467_probe,
905 .id_table = ad9467_ids,
907 module_spi_driver(ad9467_driver);
910 MODULE_DESCRIPTION("Analog Devices AD9467 ADC driver");
911 MODULE_LICENSE("GPL v2");
912 MODULE_IMPORT_NS(IIO_BACKEND);