Lines Matching refs:adc
35 static int adc128_adc_conversion(struct adc128 *adc, u8 channel) in adc128_adc_conversion() argument
39 mutex_lock(&adc->lock); in adc128_adc_conversion()
41 adc->buffer[0] = channel << 3; in adc128_adc_conversion()
42 adc->buffer[1] = 0; in adc128_adc_conversion()
44 ret = spi_write(adc->spi, &adc->buffer, 2); in adc128_adc_conversion()
46 mutex_unlock(&adc->lock); in adc128_adc_conversion()
50 ret = spi_read(adc->spi, &adc->buffer, 2); in adc128_adc_conversion()
52 mutex_unlock(&adc->lock); in adc128_adc_conversion()
57 return ((adc->buffer[0] << 8 | adc->buffer[1]) & 0xFFF); in adc128_adc_conversion()
64 struct adc128 *adc = iio_priv(indio_dev); in adc128_read_raw() local
70 ret = adc128_adc_conversion(adc, channel->channel); in adc128_read_raw()
79 ret = regulator_get_voltage(adc->reg); in adc128_read_raw()
144 struct adc128 *adc; in adc128_probe() local
152 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in adc128_probe()
156 adc = iio_priv(indio_dev); in adc128_probe()
157 adc->spi = spi; in adc128_probe()
166 adc->reg = devm_regulator_get(&spi->dev, "vref"); in adc128_probe()
167 if (IS_ERR(adc->reg)) in adc128_probe()
168 return PTR_ERR(adc->reg); in adc128_probe()
170 ret = regulator_enable(adc->reg); in adc128_probe()
174 adc->reg); in adc128_probe()
178 mutex_init(&adc->lock); in adc128_probe()