Lines Matching refs:adc
73 static int adc084s021_adc_conversion(struct adc084s021 *adc, __be16 *data) in adc084s021_adc_conversion() argument
75 int n_words = (adc->spi_trans.len >> 1) - 1; /* Discard first word */ in adc084s021_adc_conversion()
79 ret = spi_sync(adc->spi, &adc->message); in adc084s021_adc_conversion()
84 *(data + i) = adc->rx_buf[i + 1]; in adc084s021_adc_conversion()
93 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_read_raw() local
103 ret = regulator_enable(adc->reg); in adc084s021_read_raw()
109 adc->tx_buf[0] = channel->channel << 3; in adc084s021_read_raw()
110 ret = adc084s021_adc_conversion(adc, &be_val); in adc084s021_read_raw()
112 regulator_disable(adc->reg); in adc084s021_read_raw()
121 ret = regulator_enable(adc->reg); in adc084s021_read_raw()
125 ret = regulator_get_voltage(adc->reg); in adc084s021_read_raw()
126 regulator_disable(adc->reg); in adc084s021_read_raw()
148 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_buffer_trigger_handler() local
150 mutex_lock(&adc->lock); in adc084s021_buffer_trigger_handler()
152 if (adc084s021_adc_conversion(adc, adc->scan.channels) < 0) in adc084s021_buffer_trigger_handler()
153 dev_err(&adc->spi->dev, "Failed to read data\n"); in adc084s021_buffer_trigger_handler()
155 iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, in adc084s021_buffer_trigger_handler()
157 mutex_unlock(&adc->lock); in adc084s021_buffer_trigger_handler()
165 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_buffer_preenable() local
173 adc->tx_buf[i++] = channel->channel << 3; in adc084s021_buffer_preenable()
175 adc->spi_trans.len = 2 + (i * sizeof(__be16)); /* Trash + channels */ in adc084s021_buffer_preenable()
177 return regulator_enable(adc->reg); in adc084s021_buffer_preenable()
182 struct adc084s021 *adc = iio_priv(indio_dev); in adc084s021_buffer_postdisable() local
184 adc->spi_trans.len = 4; /* Trash + single channel */ in adc084s021_buffer_postdisable()
186 return regulator_disable(adc->reg); in adc084s021_buffer_postdisable()
201 struct adc084s021 *adc; in adc084s021_probe() local
204 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in adc084s021_probe()
210 adc = iio_priv(indio_dev); in adc084s021_probe()
211 adc->spi = spi; in adc084s021_probe()
221 adc->spi_trans.tx_buf = adc->tx_buf; in adc084s021_probe()
222 adc->spi_trans.rx_buf = adc->rx_buf; in adc084s021_probe()
223 adc->spi_trans.len = 4; /* Trash + single channel */ in adc084s021_probe()
224 spi_message_init_with_transfers(&adc->message, &adc->spi_trans, 1); in adc084s021_probe()
226 adc->reg = devm_regulator_get(&spi->dev, "vref"); in adc084s021_probe()
227 if (IS_ERR(adc->reg)) in adc084s021_probe()
228 return PTR_ERR(adc->reg); in adc084s021_probe()
230 mutex_init(&adc->lock); in adc084s021_probe()