12985a5d8SStefan Popa // SPDX-License-Identifier: GPL-2.0
22985a5d8SStefan Popa /*
32985a5d8SStefan Popa * AD7606 SPI ADC driver
42985a5d8SStefan Popa *
52985a5d8SStefan Popa * Copyright 2011 Analog Devices Inc.
62985a5d8SStefan Popa */
72985a5d8SStefan Popa
82985a5d8SStefan Popa #include <linux/module.h>
92985a5d8SStefan Popa #include <linux/spi/spi.h>
102985a5d8SStefan Popa #include <linux/types.h>
112985a5d8SStefan Popa #include <linux/err.h>
122985a5d8SStefan Popa
132985a5d8SStefan Popa #include <linux/iio/iio.h>
142985a5d8SStefan Popa #include "ad7606.h"
152985a5d8SStefan Popa
162985a5d8SStefan Popa #define MAX_SPI_FREQ_HZ 23500000 /* VDRIVE above 4.75 V */
172985a5d8SStefan Popa
18f2a22e1eSBeniamin Bia #define AD7616_CONFIGURATION_REGISTER 0x02
19f2a22e1eSBeniamin Bia #define AD7616_OS_MASK GENMASK(4, 2)
20f2a22e1eSBeniamin Bia #define AD7616_BURST_MODE BIT(6)
21f2a22e1eSBeniamin Bia #define AD7616_SEQEN_MODE BIT(5)
22f2a22e1eSBeniamin Bia #define AD7616_RANGE_CH_A_ADDR_OFF 0x04
23f2a22e1eSBeniamin Bia #define AD7616_RANGE_CH_B_ADDR_OFF 0x06
24f2a22e1eSBeniamin Bia /*
25f2a22e1eSBeniamin Bia * Range of channels from a group are stored in 2 registers.
26f2a22e1eSBeniamin Bia * 0, 1, 2, 3 in a register followed by 4, 5, 6, 7 in second register.
27f2a22e1eSBeniamin Bia * For channels from second group(8-15) the order is the same, only with
28f2a22e1eSBeniamin Bia * an offset of 2 for register address.
29f2a22e1eSBeniamin Bia */
30f2a22e1eSBeniamin Bia #define AD7616_RANGE_CH_ADDR(ch) ((ch) >> 2)
31d2a415c8SStefan Popa /* The range of the channel is stored in 2 bits */
32f2a22e1eSBeniamin Bia #define AD7616_RANGE_CH_MSK(ch) (0b11 << (((ch) & 0b11) * 2))
33f2a22e1eSBeniamin Bia #define AD7616_RANGE_CH_MODE(ch, mode) ((mode) << ((((ch) & 0b11)) * 2))
34d2a415c8SStefan Popa
35d2a415c8SStefan Popa #define AD7606_CONFIGURATION_REGISTER 0x02
36d2a415c8SStefan Popa #define AD7606_SINGLE_DOUT 0x00
37d2a415c8SStefan Popa
38d2a415c8SStefan Popa /*
39d2a415c8SStefan Popa * Range for AD7606B channels are stored in registers starting with address 0x3.
40d2a415c8SStefan Popa * Each register stores range for 2 channels(4 bits per channel).
41d2a415c8SStefan Popa */
42d2a415c8SStefan Popa #define AD7606_RANGE_CH_MSK(ch) (GENMASK(3, 0) << (4 * ((ch) & 0x1)))
43d2a415c8SStefan Popa #define AD7606_RANGE_CH_MODE(ch, mode) \
44d2a415c8SStefan Popa ((GENMASK(3, 0) & mode) << (4 * ((ch) & 0x1)))
45d2a415c8SStefan Popa #define AD7606_RANGE_CH_ADDR(ch) (0x03 + ((ch) >> 1))
46d2a415c8SStefan Popa #define AD7606_OS_MODE 0x08
47d2a415c8SStefan Popa
48f2a22e1eSBeniamin Bia static const struct iio_chan_spec ad7616_sw_channels[] = {
49f2a22e1eSBeniamin Bia IIO_CHAN_SOFT_TIMESTAMP(16),
50f2a22e1eSBeniamin Bia AD7616_CHANNEL(0),
51f2a22e1eSBeniamin Bia AD7616_CHANNEL(1),
52f2a22e1eSBeniamin Bia AD7616_CHANNEL(2),
53f2a22e1eSBeniamin Bia AD7616_CHANNEL(3),
54f2a22e1eSBeniamin Bia AD7616_CHANNEL(4),
55f2a22e1eSBeniamin Bia AD7616_CHANNEL(5),
56f2a22e1eSBeniamin Bia AD7616_CHANNEL(6),
57f2a22e1eSBeniamin Bia AD7616_CHANNEL(7),
58f2a22e1eSBeniamin Bia AD7616_CHANNEL(8),
59f2a22e1eSBeniamin Bia AD7616_CHANNEL(9),
60f2a22e1eSBeniamin Bia AD7616_CHANNEL(10),
61f2a22e1eSBeniamin Bia AD7616_CHANNEL(11),
62f2a22e1eSBeniamin Bia AD7616_CHANNEL(12),
63f2a22e1eSBeniamin Bia AD7616_CHANNEL(13),
64f2a22e1eSBeniamin Bia AD7616_CHANNEL(14),
65f2a22e1eSBeniamin Bia AD7616_CHANNEL(15),
66f2a22e1eSBeniamin Bia };
67f2a22e1eSBeniamin Bia
68d2a415c8SStefan Popa static const struct iio_chan_spec ad7606b_sw_channels[] = {
69d2a415c8SStefan Popa IIO_CHAN_SOFT_TIMESTAMP(8),
70d2a415c8SStefan Popa AD7616_CHANNEL(0),
71d2a415c8SStefan Popa AD7616_CHANNEL(1),
72d2a415c8SStefan Popa AD7616_CHANNEL(2),
73d2a415c8SStefan Popa AD7616_CHANNEL(3),
74d2a415c8SStefan Popa AD7616_CHANNEL(4),
75d2a415c8SStefan Popa AD7616_CHANNEL(5),
76d2a415c8SStefan Popa AD7616_CHANNEL(6),
77d2a415c8SStefan Popa AD7616_CHANNEL(7),
78d2a415c8SStefan Popa };
79d2a415c8SStefan Popa
80d2a415c8SStefan Popa static const unsigned int ad7606B_oversampling_avail[9] = {
81d2a415c8SStefan Popa 1, 2, 4, 8, 16, 32, 64, 128, 256
82d2a415c8SStefan Popa };
83d2a415c8SStefan Popa
ad7616_spi_rd_wr_cmd(int addr,char isWriteOp)84f2a22e1eSBeniamin Bia static u16 ad7616_spi_rd_wr_cmd(int addr, char isWriteOp)
85f2a22e1eSBeniamin Bia {
86f2a22e1eSBeniamin Bia /*
87f2a22e1eSBeniamin Bia * The address of register consist of one w/r bit
88f2a22e1eSBeniamin Bia * 6 bits of address followed by one reserved bit.
89f2a22e1eSBeniamin Bia */
90f2a22e1eSBeniamin Bia return ((addr & 0x7F) << 1) | ((isWriteOp & 0x1) << 7);
91f2a22e1eSBeniamin Bia }
92f2a22e1eSBeniamin Bia
ad7606B_spi_rd_wr_cmd(int addr,char is_write_op)93d2a415c8SStefan Popa static u16 ad7606B_spi_rd_wr_cmd(int addr, char is_write_op)
94d2a415c8SStefan Popa {
95d2a415c8SStefan Popa /*
96d2a415c8SStefan Popa * The address of register consists of one bit which
97d2a415c8SStefan Popa * specifies a read command placed in bit 6, followed by
98d2a415c8SStefan Popa * 6 bits of address.
99d2a415c8SStefan Popa */
100d2a415c8SStefan Popa return (addr & 0x3F) | (((~is_write_op) & 0x1) << 6);
101d2a415c8SStefan Popa }
102d2a415c8SStefan Popa
ad7606_spi_read_block(struct device * dev,int count,void * buf)1032985a5d8SStefan Popa static int ad7606_spi_read_block(struct device *dev,
1042985a5d8SStefan Popa int count, void *buf)
1052985a5d8SStefan Popa {
1062985a5d8SStefan Popa struct spi_device *spi = to_spi_device(dev);
1072985a5d8SStefan Popa int i, ret;
1082985a5d8SStefan Popa unsigned short *data = buf;
1092985a5d8SStefan Popa __be16 *bdata = buf;
1102985a5d8SStefan Popa
1112985a5d8SStefan Popa ret = spi_read(spi, buf, count * 2);
1122985a5d8SStefan Popa if (ret < 0) {
1132985a5d8SStefan Popa dev_err(&spi->dev, "SPI read error\n");
1142985a5d8SStefan Popa return ret;
1152985a5d8SStefan Popa }
1162985a5d8SStefan Popa
1172985a5d8SStefan Popa for (i = 0; i < count; i++)
1182985a5d8SStefan Popa data[i] = be16_to_cpu(bdata[i]);
1192985a5d8SStefan Popa
1202985a5d8SStefan Popa return 0;
1212985a5d8SStefan Popa }
1222985a5d8SStefan Popa
ad7606_spi_reg_read(struct ad7606_state * st,unsigned int addr)123f2a22e1eSBeniamin Bia static int ad7606_spi_reg_read(struct ad7606_state *st, unsigned int addr)
124f2a22e1eSBeniamin Bia {
125f2a22e1eSBeniamin Bia struct spi_device *spi = to_spi_device(st->dev);
126f2a22e1eSBeniamin Bia struct spi_transfer t[] = {
127f2a22e1eSBeniamin Bia {
128f2a22e1eSBeniamin Bia .tx_buf = &st->d16[0],
129f2a22e1eSBeniamin Bia .len = 2,
130f2a22e1eSBeniamin Bia .cs_change = 0,
131f2a22e1eSBeniamin Bia }, {
132f2a22e1eSBeniamin Bia .rx_buf = &st->d16[1],
133f2a22e1eSBeniamin Bia .len = 2,
134f2a22e1eSBeniamin Bia },
135f2a22e1eSBeniamin Bia };
136f2a22e1eSBeniamin Bia int ret;
137f2a22e1eSBeniamin Bia
138f2a22e1eSBeniamin Bia st->d16[0] = cpu_to_be16(st->bops->rd_wr_cmd(addr, 0) << 8);
139f2a22e1eSBeniamin Bia
140f2a22e1eSBeniamin Bia ret = spi_sync_transfer(spi, t, ARRAY_SIZE(t));
141f2a22e1eSBeniamin Bia if (ret < 0)
142f2a22e1eSBeniamin Bia return ret;
143f2a22e1eSBeniamin Bia
144f2a22e1eSBeniamin Bia return be16_to_cpu(st->d16[1]);
145f2a22e1eSBeniamin Bia }
146f2a22e1eSBeniamin Bia
ad7606_spi_reg_write(struct ad7606_state * st,unsigned int addr,unsigned int val)147f2a22e1eSBeniamin Bia static int ad7606_spi_reg_write(struct ad7606_state *st,
148f2a22e1eSBeniamin Bia unsigned int addr,
149f2a22e1eSBeniamin Bia unsigned int val)
150f2a22e1eSBeniamin Bia {
151f2a22e1eSBeniamin Bia struct spi_device *spi = to_spi_device(st->dev);
152f2a22e1eSBeniamin Bia
153f2a22e1eSBeniamin Bia st->d16[0] = cpu_to_be16((st->bops->rd_wr_cmd(addr, 1) << 8) |
154f2a22e1eSBeniamin Bia (val & 0x1FF));
155f2a22e1eSBeniamin Bia
156f2a22e1eSBeniamin Bia return spi_write(spi, &st->d16[0], sizeof(st->d16[0]));
157f2a22e1eSBeniamin Bia }
158f2a22e1eSBeniamin Bia
ad7606_spi_write_mask(struct ad7606_state * st,unsigned int addr,unsigned long mask,unsigned int val)159f2a22e1eSBeniamin Bia static int ad7606_spi_write_mask(struct ad7606_state *st,
160f2a22e1eSBeniamin Bia unsigned int addr,
161f2a22e1eSBeniamin Bia unsigned long mask,
162f2a22e1eSBeniamin Bia unsigned int val)
163f2a22e1eSBeniamin Bia {
164f2a22e1eSBeniamin Bia int readval;
165f2a22e1eSBeniamin Bia
166f2a22e1eSBeniamin Bia readval = st->bops->reg_read(st, addr);
167f2a22e1eSBeniamin Bia if (readval < 0)
168f2a22e1eSBeniamin Bia return readval;
169f2a22e1eSBeniamin Bia
170f2a22e1eSBeniamin Bia readval &= ~mask;
171f2a22e1eSBeniamin Bia readval |= val;
172f2a22e1eSBeniamin Bia
173f2a22e1eSBeniamin Bia return st->bops->reg_write(st, addr, readval);
174f2a22e1eSBeniamin Bia }
175f2a22e1eSBeniamin Bia
ad7616_write_scale_sw(struct iio_dev * indio_dev,int ch,int val)176f2a22e1eSBeniamin Bia static int ad7616_write_scale_sw(struct iio_dev *indio_dev, int ch, int val)
177f2a22e1eSBeniamin Bia {
178f2a22e1eSBeniamin Bia struct ad7606_state *st = iio_priv(indio_dev);
179f2a22e1eSBeniamin Bia unsigned int ch_addr, mode, ch_index;
180f2a22e1eSBeniamin Bia
181f2a22e1eSBeniamin Bia
182f2a22e1eSBeniamin Bia /*
183f2a22e1eSBeniamin Bia * Ad7616 has 16 channels divided in group A and group B.
184f2a22e1eSBeniamin Bia * The range of channels from A are stored in registers with address 4
185f2a22e1eSBeniamin Bia * while channels from B are stored in register with address 6.
186f2a22e1eSBeniamin Bia * The last bit from channels determines if it is from group A or B
187f2a22e1eSBeniamin Bia * because the order of channels in iio is 0A, 0B, 1A, 1B...
188f2a22e1eSBeniamin Bia */
189f2a22e1eSBeniamin Bia ch_index = ch >> 1;
190f2a22e1eSBeniamin Bia
191f2a22e1eSBeniamin Bia ch_addr = AD7616_RANGE_CH_ADDR(ch_index);
192f2a22e1eSBeniamin Bia
193f2a22e1eSBeniamin Bia if ((ch & 0x1) == 0) /* channel A */
194f2a22e1eSBeniamin Bia ch_addr += AD7616_RANGE_CH_A_ADDR_OFF;
195f2a22e1eSBeniamin Bia else /* channel B */
196f2a22e1eSBeniamin Bia ch_addr += AD7616_RANGE_CH_B_ADDR_OFF;
197f2a22e1eSBeniamin Bia
198f2a22e1eSBeniamin Bia /* 0b01 for 2.5v, 0b10 for 5v and 0b11 for 10v */
199f2a22e1eSBeniamin Bia mode = AD7616_RANGE_CH_MODE(ch_index, ((val + 1) & 0b11));
200f2a22e1eSBeniamin Bia return st->bops->write_mask(st, ch_addr, AD7616_RANGE_CH_MSK(ch_index),
201f2a22e1eSBeniamin Bia mode);
202f2a22e1eSBeniamin Bia }
203f2a22e1eSBeniamin Bia
ad7616_write_os_sw(struct iio_dev * indio_dev,int val)204f2a22e1eSBeniamin Bia static int ad7616_write_os_sw(struct iio_dev *indio_dev, int val)
205f2a22e1eSBeniamin Bia {
206f2a22e1eSBeniamin Bia struct ad7606_state *st = iio_priv(indio_dev);
207f2a22e1eSBeniamin Bia
208f2a22e1eSBeniamin Bia return st->bops->write_mask(st, AD7616_CONFIGURATION_REGISTER,
209f2a22e1eSBeniamin Bia AD7616_OS_MASK, val << 2);
210f2a22e1eSBeniamin Bia }
211f2a22e1eSBeniamin Bia
ad7606_write_scale_sw(struct iio_dev * indio_dev,int ch,int val)212d2a415c8SStefan Popa static int ad7606_write_scale_sw(struct iio_dev *indio_dev, int ch, int val)
213d2a415c8SStefan Popa {
214d2a415c8SStefan Popa struct ad7606_state *st = iio_priv(indio_dev);
215d2a415c8SStefan Popa
216d2a415c8SStefan Popa return ad7606_spi_write_mask(st,
217d2a415c8SStefan Popa AD7606_RANGE_CH_ADDR(ch),
218d2a415c8SStefan Popa AD7606_RANGE_CH_MSK(ch),
219d2a415c8SStefan Popa AD7606_RANGE_CH_MODE(ch, val));
220d2a415c8SStefan Popa }
221d2a415c8SStefan Popa
ad7606_write_os_sw(struct iio_dev * indio_dev,int val)222d2a415c8SStefan Popa static int ad7606_write_os_sw(struct iio_dev *indio_dev, int val)
223d2a415c8SStefan Popa {
224d2a415c8SStefan Popa struct ad7606_state *st = iio_priv(indio_dev);
225d2a415c8SStefan Popa
226d2a415c8SStefan Popa return ad7606_spi_reg_write(st, AD7606_OS_MODE, val);
227d2a415c8SStefan Popa }
228d2a415c8SStefan Popa
ad7616_sw_mode_config(struct iio_dev * indio_dev)229f2a22e1eSBeniamin Bia static int ad7616_sw_mode_config(struct iio_dev *indio_dev)
230f2a22e1eSBeniamin Bia {
231f2a22e1eSBeniamin Bia struct ad7606_state *st = iio_priv(indio_dev);
232f2a22e1eSBeniamin Bia
233f2a22e1eSBeniamin Bia /*
234f2a22e1eSBeniamin Bia * Scale can be configured individually for each channel
235f2a22e1eSBeniamin Bia * in software mode.
236f2a22e1eSBeniamin Bia */
237f2a22e1eSBeniamin Bia indio_dev->channels = ad7616_sw_channels;
238f2a22e1eSBeniamin Bia
239f2a22e1eSBeniamin Bia st->write_scale = ad7616_write_scale_sw;
240f2a22e1eSBeniamin Bia st->write_os = &ad7616_write_os_sw;
241f2a22e1eSBeniamin Bia
242f2a22e1eSBeniamin Bia /* Activate Burst mode and SEQEN MODE */
243f2a22e1eSBeniamin Bia return st->bops->write_mask(st,
244f2a22e1eSBeniamin Bia AD7616_CONFIGURATION_REGISTER,
245f2a22e1eSBeniamin Bia AD7616_BURST_MODE | AD7616_SEQEN_MODE,
246f2a22e1eSBeniamin Bia AD7616_BURST_MODE | AD7616_SEQEN_MODE);
247f2a22e1eSBeniamin Bia }
248f2a22e1eSBeniamin Bia
ad7606B_sw_mode_config(struct iio_dev * indio_dev)249d2a415c8SStefan Popa static int ad7606B_sw_mode_config(struct iio_dev *indio_dev)
250d2a415c8SStefan Popa {
251d2a415c8SStefan Popa struct ad7606_state *st = iio_priv(indio_dev);
2528dc4594bSGuillaume Stols DECLARE_BITMAP(os, 3);
253d2a415c8SStefan Popa
2548dc4594bSGuillaume Stols bitmap_fill(os, 3);
255d2a415c8SStefan Popa /*
256d2a415c8SStefan Popa * Software mode is enabled when all three oversampling
257d2a415c8SStefan Popa * pins are set to high. If oversampling gpios are defined
258d2a415c8SStefan Popa * in the device tree, then they need to be set to high,
259d2a415c8SStefan Popa * otherwise, they must be hardwired to VDD
260d2a415c8SStefan Popa */
261d2a415c8SStefan Popa if (st->gpio_os) {
2628dc4594bSGuillaume Stols gpiod_set_array_value(st->gpio_os->ndescs,
263d2a415c8SStefan Popa st->gpio_os->desc, st->gpio_os->info, os);
264d2a415c8SStefan Popa }
265d2a415c8SStefan Popa /* OS of 128 and 256 are available only in software mode */
266d2a415c8SStefan Popa st->oversampling_avail = ad7606B_oversampling_avail;
267d2a415c8SStefan Popa st->num_os_ratios = ARRAY_SIZE(ad7606B_oversampling_avail);
268d2a415c8SStefan Popa
269d2a415c8SStefan Popa st->write_scale = ad7606_write_scale_sw;
270d2a415c8SStefan Popa st->write_os = &ad7606_write_os_sw;
271d2a415c8SStefan Popa
272d2a415c8SStefan Popa /* Configure device spi to output on a single channel */
273d2a415c8SStefan Popa st->bops->reg_write(st,
274d2a415c8SStefan Popa AD7606_CONFIGURATION_REGISTER,
275d2a415c8SStefan Popa AD7606_SINGLE_DOUT);
276d2a415c8SStefan Popa
277d2a415c8SStefan Popa /*
278d2a415c8SStefan Popa * Scale can be configured individually for each channel
279d2a415c8SStefan Popa * in software mode.
280d2a415c8SStefan Popa */
281d2a415c8SStefan Popa indio_dev->channels = ad7606b_sw_channels;
282d2a415c8SStefan Popa
283d2a415c8SStefan Popa return 0;
284d2a415c8SStefan Popa }
285d2a415c8SStefan Popa
2862985a5d8SStefan Popa static const struct ad7606_bus_ops ad7606_spi_bops = {
2872985a5d8SStefan Popa .read_block = ad7606_spi_read_block,
2882985a5d8SStefan Popa };
2892985a5d8SStefan Popa
290f2a22e1eSBeniamin Bia static const struct ad7606_bus_ops ad7616_spi_bops = {
291f2a22e1eSBeniamin Bia .read_block = ad7606_spi_read_block,
292f2a22e1eSBeniamin Bia .reg_read = ad7606_spi_reg_read,
293f2a22e1eSBeniamin Bia .reg_write = ad7606_spi_reg_write,
294f2a22e1eSBeniamin Bia .write_mask = ad7606_spi_write_mask,
295f2a22e1eSBeniamin Bia .rd_wr_cmd = ad7616_spi_rd_wr_cmd,
296f2a22e1eSBeniamin Bia .sw_mode_config = ad7616_sw_mode_config,
297f2a22e1eSBeniamin Bia };
298f2a22e1eSBeniamin Bia
299d2a415c8SStefan Popa static const struct ad7606_bus_ops ad7606B_spi_bops = {
300d2a415c8SStefan Popa .read_block = ad7606_spi_read_block,
301d2a415c8SStefan Popa .reg_read = ad7606_spi_reg_read,
302d2a415c8SStefan Popa .reg_write = ad7606_spi_reg_write,
303d2a415c8SStefan Popa .write_mask = ad7606_spi_write_mask,
304d2a415c8SStefan Popa .rd_wr_cmd = ad7606B_spi_rd_wr_cmd,
305d2a415c8SStefan Popa .sw_mode_config = ad7606B_sw_mode_config,
306d2a415c8SStefan Popa };
307d2a415c8SStefan Popa
ad7606_spi_probe(struct spi_device * spi)3082985a5d8SStefan Popa static int ad7606_spi_probe(struct spi_device *spi)
3092985a5d8SStefan Popa {
3102985a5d8SStefan Popa const struct spi_device_id *id = spi_get_device_id(spi);
311f2a22e1eSBeniamin Bia const struct ad7606_bus_ops *bops;
312f2a22e1eSBeniamin Bia
313f2a22e1eSBeniamin Bia switch (id->driver_data) {
314f2a22e1eSBeniamin Bia case ID_AD7616:
315f2a22e1eSBeniamin Bia bops = &ad7616_spi_bops;
316f2a22e1eSBeniamin Bia break;
317d2a415c8SStefan Popa case ID_AD7606B:
318d2a415c8SStefan Popa bops = &ad7606B_spi_bops;
319d2a415c8SStefan Popa break;
320f2a22e1eSBeniamin Bia default:
321f2a22e1eSBeniamin Bia bops = &ad7606_spi_bops;
322f2a22e1eSBeniamin Bia break;
323f2a22e1eSBeniamin Bia }
3242985a5d8SStefan Popa
3252985a5d8SStefan Popa return ad7606_probe(&spi->dev, spi->irq, NULL,
3262985a5d8SStefan Popa id->name, id->driver_data,
327f2a22e1eSBeniamin Bia bops);
3282985a5d8SStefan Popa }
3292985a5d8SStefan Popa
3302985a5d8SStefan Popa static const struct spi_device_id ad7606_id_table[] = {
3312985a5d8SStefan Popa { "ad7605-4", ID_AD7605_4 },
3322985a5d8SStefan Popa { "ad7606-4", ID_AD7606_4 },
3332985a5d8SStefan Popa { "ad7606-6", ID_AD7606_6 },
3342985a5d8SStefan Popa { "ad7606-8", ID_AD7606_8 },
335d2a415c8SStefan Popa { "ad7606b", ID_AD7606B },
3367989b4bbSBeniamin Bia { "ad7616", ID_AD7616 },
3372985a5d8SStefan Popa { }
3382985a5d8SStefan Popa };
3392985a5d8SStefan Popa MODULE_DEVICE_TABLE(spi, ad7606_id_table);
3402985a5d8SStefan Popa
3412985a5d8SStefan Popa static const struct of_device_id ad7606_of_match[] = {
3422985a5d8SStefan Popa { .compatible = "adi,ad7605-4" },
3432985a5d8SStefan Popa { .compatible = "adi,ad7606-4" },
3442985a5d8SStefan Popa { .compatible = "adi,ad7606-6" },
3452985a5d8SStefan Popa { .compatible = "adi,ad7606-8" },
346d2a415c8SStefan Popa { .compatible = "adi,ad7606b" },
3477989b4bbSBeniamin Bia { .compatible = "adi,ad7616" },
348*09e3bdfeSJonathan Cameron { }
3492985a5d8SStefan Popa };
3502985a5d8SStefan Popa MODULE_DEVICE_TABLE(of, ad7606_of_match);
3512985a5d8SStefan Popa
3522985a5d8SStefan Popa static struct spi_driver ad7606_driver = {
3532985a5d8SStefan Popa .driver = {
3542985a5d8SStefan Popa .name = "ad7606",
3552985a5d8SStefan Popa .of_match_table = ad7606_of_match,
3562985a5d8SStefan Popa .pm = AD7606_PM_OPS,
3572985a5d8SStefan Popa },
3582985a5d8SStefan Popa .probe = ad7606_spi_probe,
3592985a5d8SStefan Popa .id_table = ad7606_id_table,
3602985a5d8SStefan Popa };
3612985a5d8SStefan Popa module_spi_driver(ad7606_driver);
3622985a5d8SStefan Popa
3632985a5d8SStefan Popa MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
3642985a5d8SStefan Popa MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
3652985a5d8SStefan Popa MODULE_LICENSE("GPL v2");
36659cea5bcSJonathan Cameron MODULE_IMPORT_NS(IIO_AD7606);
367