Lines Matching refs:adc

75 static int adc084s021_adc_conversion(struct adc084s021 *adc, void *data)  in adc084s021_adc_conversion()  argument
77 int n_words = (adc->spi_trans.len >> 1) - 1; /* Discard first word */ in adc084s021_adc_conversion()
82 ret = spi_sync(adc->spi, &adc->message); in adc084s021_adc_conversion()
87 *(p + i) = adc->rx_buf[i + 1]; in adc084s021_adc_conversion()
96 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_read_raw() local
105 ret = regulator_enable(adc->reg); in adc084s021_read_raw()
111 adc->tx_buf[0] = channel->channel << 3; in adc084s021_read_raw()
112 ret = adc084s021_adc_conversion(adc, val); in adc084s021_read_raw()
114 regulator_disable(adc->reg); in adc084s021_read_raw()
123 ret = regulator_enable(adc->reg); in adc084s021_read_raw()
127 ret = regulator_get_voltage(adc->reg); in adc084s021_read_raw()
128 regulator_disable(adc->reg); in adc084s021_read_raw()
150 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_buffer_trigger_handler() local
152 mutex_lock(&adc->lock); in adc084s021_buffer_trigger_handler()
154 if (adc084s021_adc_conversion(adc, adc->scan.channels) < 0) in adc084s021_buffer_trigger_handler()
155 dev_err(&adc->spi->dev, "Failed to read data\n"); in adc084s021_buffer_trigger_handler()
157 iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, in adc084s021_buffer_trigger_handler()
159 mutex_unlock(&adc->lock); in adc084s021_buffer_trigger_handler()
167 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_buffer_preenable() local
175 adc->tx_buf[i++] = channel->channel << 3; in adc084s021_buffer_preenable()
177 adc->spi_trans.len = 2 + (i * sizeof(__be16)); /* Trash + channels */ in adc084s021_buffer_preenable()
179 return regulator_enable(adc->reg); in adc084s021_buffer_preenable()
184 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_buffer_postdisable() local
186 adc->spi_trans.len = 4; /* Trash + single channel */ in adc084s021_buffer_postdisable()
188 return regulator_disable(adc->reg); in adc084s021_buffer_postdisable()
205 struct adc084s021 *adc; in adc084s021_probe() local
208 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in adc084s021_probe()
214 adc = iio_priv(indio_dev); in adc084s021_probe()
215 adc->spi = spi; in adc084s021_probe()
230 adc->spi_trans.tx_buf = adc->tx_buf; in adc084s021_probe()
231 adc->spi_trans.rx_buf = adc->rx_buf; in adc084s021_probe()
232 adc->spi_trans.len = 4; /* Trash + single channel */ in adc084s021_probe()
233 spi_message_init_with_transfers(&adc->message, &adc->spi_trans, 1); in adc084s021_probe()
235 adc->reg = devm_regulator_get(&spi->dev, "vref"); in adc084s021_probe()
236 if (IS_ERR(adc->reg)) in adc084s021_probe()
237 return PTR_ERR(adc->reg); in adc084s021_probe()
239 mutex_init(&adc->lock); in adc084s021_probe()