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
80 if (!st->convst_gpio) in ad7091_convst()
83 gpiod_set_value(st->convst_gpio, 0); in ad7091_convst()
85 gpiod_set_value(st->convst_gpio, 1); in ad7091_convst()
92 struct iio_dev *indio_dev = pf->indio_dev; in ad7476_trigger_handler()
98 b_sent = spi_sync(st->spi, &st->msg); in ad7476_trigger_handler()
102 iio_push_to_buffers_with_timestamp(indio_dev, st->data, in ad7476_trigger_handler()
105 iio_trigger_notify_done(indio_dev->trig); in ad7476_trigger_handler()
112 /* Any transfers with 8 scl cycles will reset the device */ in ad7091_reset()
113 spi_read(st->spi, st->data, 1); in ad7091_reset()
122 ret = spi_sync(st->spi, &st->msg); in ad7476_scan_direct()
126 return be16_to_cpup((__be16 *)st->data); in ad7476_scan_direct()
149 *val = (ret >> st->chip_info->channel[0].scan_type.shift) & in ad7476_read_raw()
150 GENMASK(st->chip_info->channel[0].scan_type.realbits - 1, 0); in ad7476_read_raw()
153 if (st->ref_reg) { in ad7476_read_raw()
154 scale_uv = regulator_get_voltage(st->ref_reg); in ad7476_read_raw()
158 scale_uv = st->chip_info->int_vref_uv; in ad7476_read_raw()
161 *val2 = chan->scan_type.realbits; in ad7476_read_raw()
164 return -EINVAL; in ad7476_read_raw()
182 #define ADC081S_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \
184 #define AD7476_CHAN(bits) _AD7476_CHAN((bits), 13 - (bits), \
186 #define AD7940_CHAN(bits) _AD7476_CHAN((bits), 15 - (bits), \
188 #define AD7091R_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), 0)
189 #define AD7091R_CONVST_CHAN(bits) _AD7476_CHAN((bits), 16 - (bits), \
191 #define ADS786X_CHAN(bits) _AD7476_CHAN((bits), 12 - (bits), \
196 .channel[0] = AD7091R_CHAN(12),
197 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
203 .channel[0] = AD7091R_CHAN(12),
204 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
212 .channel[0] = AD7940_CHAN(10),
213 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
217 .channel[0] = AD7940_CHAN(12),
218 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
222 .channel[0] = AD7940_CHAN(12),
223 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
226 .channel[0] = AD7940_CHAN(10),
227 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
230 .channel[0] = AD7940_CHAN(8),
231 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
234 .channel[0] = AD7476_CHAN(12),
235 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
238 .channel[0] = AD7476_CHAN(10),
239 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
242 .channel[0] = AD7476_CHAN(8),
243 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
246 .channel[0] = AD7476_CHAN(12),
247 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
252 .channel[0] = AD7476_CHAN(12),
253 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
258 .channel[0] = AD7940_CHAN(14),
259 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
262 .channel[0] = ADC081S_CHAN(8),
263 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
266 .channel[0] = ADC081S_CHAN(10),
267 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
270 .channel[0] = ADC081S_CHAN(12),
271 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
274 .channel[0] = ADS786X_CHAN(12),
275 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
278 .channel[0] = ADS786X_CHAN(10),
279 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
282 .channel[0] = ADS786X_CHAN(8),
283 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
286 .channel[0] = AD7940_CHAN(14),
287 .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
310 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7476_probe()
312 return -ENOMEM; in ad7476_probe()
315 st->chip_info = in ad7476_probe()
316 &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data]; in ad7476_probe()
318 reg = devm_regulator_get(&spi->dev, "vcc"); in ad7476_probe()
326 ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable, reg); in ad7476_probe()
331 if (!st->chip_info->int_vref_uv) in ad7476_probe()
332 st->ref_reg = reg; in ad7476_probe()
334 if (st->chip_info->has_vref) { in ad7476_probe()
337 if (st->chip_info->int_vref_uv) { in ad7476_probe()
338 reg = devm_regulator_get_optional(&spi->dev, "vref"); in ad7476_probe()
339 if (IS_ERR(reg) && (PTR_ERR(reg) != -ENODEV)) in ad7476_probe()
342 reg = devm_regulator_get(&spi->dev, "vref"); in ad7476_probe()
352 ret = devm_add_action_or_reset(&spi->dev, in ad7476_probe()
357 st->ref_reg = reg; in ad7476_probe()
366 st->ref_reg = NULL; in ad7476_probe()
370 if (st->chip_info->has_vdrive) { in ad7476_probe()
371 ret = devm_regulator_get_enable(&spi->dev, "vdrive"); in ad7476_probe()
376 st->convst_gpio = devm_gpiod_get_optional(&spi->dev, in ad7476_probe()
377 "adi,conversion-start", in ad7476_probe()
379 if (IS_ERR(st->convst_gpio)) in ad7476_probe()
380 return PTR_ERR(st->convst_gpio); in ad7476_probe()
382 st->spi = spi; in ad7476_probe()
384 indio_dev->name = spi_get_device_id(spi)->name; in ad7476_probe()
385 indio_dev->modes = INDIO_DIRECT_MODE; in ad7476_probe()
386 indio_dev->channels = st->chip_info->channel; in ad7476_probe()
387 indio_dev->num_channels = 2; in ad7476_probe()
388 indio_dev->info = &ad7476_info; in ad7476_probe()
390 if (st->convst_gpio) in ad7476_probe()
391 indio_dev->channels = st->chip_info->convst_channel; in ad7476_probe()
394 st->xfer.rx_buf = &st->data; in ad7476_probe()
395 st->xfer.len = st->chip_info->channel[0].scan_type.storagebits / 8; in ad7476_probe()
397 spi_message_init(&st->msg); in ad7476_probe()
398 spi_message_add_tail(&st->xfer, &st->msg); in ad7476_probe()
400 ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, in ad7476_probe()
405 if (st->chip_info->reset) in ad7476_probe()
406 st->chip_info->reset(st); in ad7476_probe()
408 return devm_iio_device_register(&spi->dev, indio_dev); in ad7476_probe()
439 { "ltc2314-14", ID_LTC2314_14 },
454 MODULE_DESCRIPTION("Analog Devices AD7476 and similar 1-channel ADCs");