• Home
  • Raw
  • Download

Lines Matching +full:acquisition +full:- +full:time

1 // SPDX-License-Identifier: GPL-2.0-only
3 * ADC12130/ADC12132/ADC12138 12-bit plus sign ADC driver
48 /* The number of cclk periods for the S/H's acquisition time */
131 .tx_buf = adc->tx_buf, in adc12138_mode_programming()
132 .rx_buf = adc->rx_buf, in adc12138_mode_programming()
138 if (adc->id != adc12138) in adc12138_mode_programming()
141 adc->tx_buf[0] = mode; in adc12138_mode_programming()
143 ret = spi_sync_transfer(adc->spi, &xfer, 1); in adc12138_mode_programming()
147 memcpy(rx_buf, adc->rx_buf, len); in adc12138_mode_programming()
171 u8 mode = (ch_to_mux[channel->channel] << 4) | in __adc12138_start_conv()
172 (channel->differential ? 0 : 0x80); in __adc12138_start_conv()
201 if (!wait_for_completion_timeout(&adc->complete, timeout)) in adc12138_wait_eoc()
202 return -ETIMEDOUT; in adc12138_wait_eoc()
213 reinit_completion(&adc->complete); in adc12138_adc_conversion()
236 mutex_lock(&adc->lock); in adc12138_read_raw()
238 mutex_unlock(&adc->lock); in adc12138_read_raw()
246 ret = regulator_get_voltage(adc->vref_p); in adc12138_read_raw()
251 if (!IS_ERR(adc->vref_n)) { in adc12138_read_raw()
252 ret = regulator_get_voltage(adc->vref_n); in adc12138_read_raw()
255 *value -= ret; in adc12138_read_raw()
260 *shift = channel->scan_type.realbits - 1; in adc12138_read_raw()
264 if (!IS_ERR(adc->vref_n)) { in adc12138_read_raw()
265 *value = regulator_get_voltage(adc->vref_n); in adc12138_read_raw()
278 return -EINVAL; in adc12138_read_raw()
292 reinit_completion(&adc->complete); in adc12138_init()
298 /* data output at this time has no significance */ in adc12138_init()
307 dev_warn(&adc->spi->dev, in adc12138_init()
310 return -EIO; in adc12138_init()
313 switch (adc->acquisition_time) { in adc12138_init()
327 return -EINVAL; in adc12138_init()
336 struct iio_dev *indio_dev = pf->indio_dev; in adc12138_trigger_handler()
343 mutex_lock(&adc->lock); in adc12138_trigger_handler()
345 for_each_set_bit(scan_index, indio_dev->active_scan_mask, in adc12138_trigger_handler()
346 indio_dev->masklength) { in adc12138_trigger_handler()
348 &indio_dev->channels[scan_index]; in adc12138_trigger_handler()
350 reinit_completion(&adc->complete); in adc12138_trigger_handler()
353 i ? &adc->data[i - 1] : &trash); in adc12138_trigger_handler()
355 dev_warn(&adc->spi->dev, in adc12138_trigger_handler()
362 dev_warn(&adc->spi->dev, "wait eoc timeout\n"); in adc12138_trigger_handler()
370 ret = adc12138_read_conv_data(adc, &adc->data[i - 1]); in adc12138_trigger_handler()
372 dev_warn(&adc->spi->dev, in adc12138_trigger_handler()
378 iio_push_to_buffers_with_timestamp(indio_dev, adc->data, in adc12138_trigger_handler()
381 mutex_unlock(&adc->lock); in adc12138_trigger_handler()
383 iio_trigger_notify_done(indio_dev->trig); in adc12138_trigger_handler()
393 complete(&adc->complete); in adc12138_eoc_handler()
404 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in adc12138_probe()
406 return -ENOMEM; in adc12138_probe()
409 adc->spi = spi; in adc12138_probe()
410 adc->id = spi_get_device_id(spi)->driver_data; in adc12138_probe()
411 mutex_init(&adc->lock); in adc12138_probe()
412 init_completion(&adc->complete); in adc12138_probe()
414 indio_dev->name = spi_get_device_id(spi)->name; in adc12138_probe()
415 indio_dev->info = &adc12138_info; in adc12138_probe()
416 indio_dev->modes = INDIO_DIRECT_MODE; in adc12138_probe()
418 switch (adc->id) { in adc12138_probe()
421 indio_dev->channels = adc12132_channels; in adc12138_probe()
422 indio_dev->num_channels = ARRAY_SIZE(adc12132_channels); in adc12138_probe()
425 indio_dev->channels = adc12138_channels; in adc12138_probe()
426 indio_dev->num_channels = ARRAY_SIZE(adc12138_channels); in adc12138_probe()
429 return -EINVAL; in adc12138_probe()
432 ret = of_property_read_u32(spi->dev.of_node, "ti,acquisition-time", in adc12138_probe()
433 &adc->acquisition_time); in adc12138_probe()
435 adc->acquisition_time = 10; in adc12138_probe()
437 adc->cclk = devm_clk_get(&spi->dev, NULL); in adc12138_probe()
438 if (IS_ERR(adc->cclk)) in adc12138_probe()
439 return PTR_ERR(adc->cclk); in adc12138_probe()
441 adc->vref_p = devm_regulator_get(&spi->dev, "vref-p"); in adc12138_probe()
442 if (IS_ERR(adc->vref_p)) in adc12138_probe()
443 return PTR_ERR(adc->vref_p); in adc12138_probe()
445 adc->vref_n = devm_regulator_get_optional(&spi->dev, "vref-n"); in adc12138_probe()
446 if (IS_ERR(adc->vref_n)) { in adc12138_probe()
451 ret = PTR_ERR(adc->vref_n); in adc12138_probe()
452 if (ret != -ENODEV) in adc12138_probe()
456 ret = devm_request_irq(&spi->dev, spi->irq, adc12138_eoc_handler, in adc12138_probe()
457 IRQF_TRIGGER_RISING, indio_dev->name, indio_dev); in adc12138_probe()
461 ret = clk_prepare_enable(adc->cclk); in adc12138_probe()
465 ret = regulator_enable(adc->vref_p); in adc12138_probe()
469 if (!IS_ERR(adc->vref_n)) { in adc12138_probe()
470 ret = regulator_enable(adc->vref_n); in adc12138_probe()
494 if (!IS_ERR(adc->vref_n)) in adc12138_probe()
495 regulator_disable(adc->vref_n); in adc12138_probe()
497 regulator_disable(adc->vref_p); in adc12138_probe()
499 clk_disable_unprepare(adc->cclk); in adc12138_probe()
511 if (!IS_ERR(adc->vref_n)) in adc12138_remove()
512 regulator_disable(adc->vref_n); in adc12138_remove()
513 regulator_disable(adc->vref_p); in adc12138_remove()
514 clk_disable_unprepare(adc->cclk); in adc12138_remove()