Lines Matching +full:vref +full:- +full:p
1 // SPDX-License-Identifier: GPL-2.0
4 * TI ADC081S/ADC101S/ADC121S 8/10/12-bit SPI ADC driver
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()
89 static irqreturn_t ad7476_trigger_handler(int irq, void *p) in ad7476_trigger_handler() argument
91 struct iio_poll_func *pf = p; in ad7476_trigger_handler()
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()
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), \
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()
330 /* Either vcc or vref (below) as appropriate */ 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()
336 /* If a device has an internal reference vref is optional */ 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");