Lines Matching refs:adc
76 static int ads8344_adc_conversion(struct ads8344 *adc, int channel, in ads8344_adc_conversion() argument
79 struct spi_device *spi = adc->spi; in ads8344_adc_conversion()
82 adc->tx_buf = ADS8344_START; in ads8344_adc_conversion()
84 adc->tx_buf |= ADS8344_SINGLE_END; in ads8344_adc_conversion()
85 adc->tx_buf |= ADS8344_CHANNEL(channel); in ads8344_adc_conversion()
86 adc->tx_buf |= ADS8344_CLOCK_INTERNAL; in ads8344_adc_conversion()
88 ret = spi_write(spi, &adc->tx_buf, 1); in ads8344_adc_conversion()
94 ret = spi_read(spi, adc->rx_buf, sizeof(adc->rx_buf)); in ads8344_adc_conversion()
98 return adc->rx_buf[0] << 9 | adc->rx_buf[1] << 1 | adc->rx_buf[2] >> 7; in ads8344_adc_conversion()
105 struct ads8344 *adc = iio_priv(iio); in ads8344_read_raw() local
109 mutex_lock(&adc->lock); in ads8344_read_raw()
110 *value = ads8344_adc_conversion(adc, channel->address, in ads8344_read_raw()
112 mutex_unlock(&adc->lock); in ads8344_read_raw()
118 *value = regulator_get_voltage(adc->reg); in ads8344_read_raw()
144 struct ads8344 *adc; in ads8344_probe() local
147 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in ads8344_probe()
151 adc = iio_priv(indio_dev); in ads8344_probe()
152 adc->spi = spi; in ads8344_probe()
153 mutex_init(&adc->lock); in ads8344_probe()
161 adc->reg = devm_regulator_get(&spi->dev, "vref"); in ads8344_probe()
162 if (IS_ERR(adc->reg)) in ads8344_probe()
163 return PTR_ERR(adc->reg); in ads8344_probe()
165 ret = regulator_enable(adc->reg); in ads8344_probe()
169 ret = devm_add_action_or_reset(&spi->dev, ads8344_reg_disable, adc->reg); in ads8344_probe()