Lines Matching +full:8 +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0
3 * Analog Devices AD7466/7/8 AD7476/5/7/8 (A) SPI ADC driver
4 * TI ADC081S/ADC101S/ADC121S 8/10/12-bit SPI ADC driver
31 struct iio_chan_spec channel[2]; member
74 if (!st->convst_gpio) in ad7091_convst()
77 gpiod_set_value(st->convst_gpio, 0); in ad7091_convst()
79 gpiod_set_value(st->convst_gpio, 1); in ad7091_convst()
86 struct iio_dev *indio_dev = pf->indio_dev; in ad7476_trigger_handler()
92 b_sent = spi_sync(st->spi, &st->msg); in ad7476_trigger_handler()
96 iio_push_to_buffers_with_timestamp(indio_dev, st->data, in ad7476_trigger_handler()
99 iio_trigger_notify_done(indio_dev->trig); in ad7476_trigger_handler()
106 /* Any transfers with 8 scl cycles will reset the device */ in ad7091_reset()
107 spi_read(st->spi, st->data, 1); in ad7091_reset()
116 ret = spi_sync(st->spi, &st->msg); in ad7476_scan_direct()
120 return be16_to_cpup((__be16 *)st->data); in ad7476_scan_direct()
143 *val = (ret >> st->chip_info->channel[0].scan_type.shift) & in ad7476_read_raw()
144 GENMASK(st->chip_info->channel[0].scan_type.realbits - 1, 0); in ad7476_read_raw()
147 if (!st->chip_info->int_vref_uv) { in ad7476_read_raw()
148 scale_uv = regulator_get_voltage(st->reg); in ad7476_read_raw()
152 scale_uv = st->chip_info->int_vref_uv; in ad7476_read_raw()
155 *val2 = chan->scan_type.realbits; in ad7476_read_raw()
158 return -EINVAL; in ad7476_read_raw()
176 #define ADC081S_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \
178 #define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits), \
180 #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \
182 #define AD7091R_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), 0)
183 #define AD7091R_CONVST_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), \
185 #define ADS786X_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \
190 .channel[0] = AD7091R_CHAN(12),
191 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
197 .channel[0] = AD7940_CHAN(12),
198 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
201 .channel[0] = AD7940_CHAN(10),
202 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
205 .channel[0] = AD7940_CHAN(8),
206 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
209 .channel[0] = AD7476_CHAN(12),
210 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
213 .channel[0] = AD7476_CHAN(10),
214 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
217 .channel[0] = AD7476_CHAN(8),
218 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
221 .channel[0] = AD7476_CHAN(12),
222 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
226 .channel[0] = AD7940_CHAN(14),
227 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
230 .channel[0] = ADC081S_CHAN(8),
231 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
234 .channel[0] = ADC081S_CHAN(10),
235 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
238 .channel[0] = ADC081S_CHAN(12),
239 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
242 .channel[0] = ADS786X_CHAN(12),
243 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
246 .channel[0] = ADS786X_CHAN(10),
247 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
250 .channel[0] = ADS786X_CHAN(8),
251 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
263 regulator_disable(st->reg); in ad7476_reg_disable()
272 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7476_probe()
274 return -ENOMEM; in ad7476_probe()
277 st->chip_info = in ad7476_probe()
278 &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data]; in ad7476_probe()
280 st->reg = devm_regulator_get(&spi->dev, "vcc"); in ad7476_probe()
281 if (IS_ERR(st->reg)) in ad7476_probe()
282 return PTR_ERR(st->reg); in ad7476_probe()
284 ret = regulator_enable(st->reg); in ad7476_probe()
288 ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable, in ad7476_probe()
293 st->convst_gpio = devm_gpiod_get_optional(&spi->dev, in ad7476_probe()
294 "adi,conversion-start", in ad7476_probe()
296 if (IS_ERR(st->convst_gpio)) in ad7476_probe()
297 return PTR_ERR(st->convst_gpio); in ad7476_probe()
301 st->spi = spi; in ad7476_probe()
303 indio_dev->name = spi_get_device_id(spi)->name; in ad7476_probe()
304 indio_dev->modes = INDIO_DIRECT_MODE; in ad7476_probe()
305 indio_dev->channels = st->chip_info->channel; in ad7476_probe()
306 indio_dev->num_channels = 2; in ad7476_probe()
307 indio_dev->info = &ad7476_info; in ad7476_probe()
309 if (st->convst_gpio) in ad7476_probe()
310 indio_dev->channels = st->chip_info->convst_channel; in ad7476_probe()
313 st->xfer.rx_buf = &st->data; in ad7476_probe()
314 st->xfer.len = st->chip_info->channel[0].scan_type.storagebits / 8; in ad7476_probe()
316 spi_message_init(&st->msg); in ad7476_probe()
317 spi_message_add_tail(&st->xfer, &st->msg); in ad7476_probe()
324 if (st->chip_info->reset) in ad7476_probe()
325 st->chip_info->reset(st); in ad7476_probe()
335 regulator_disable(st->reg); in ad7476_probe()
382 MODULE_DESCRIPTION("Analog Devices AD7476 and similar 1-channel ADCs");