Lines Matching +full:adc +full:- +full:chan
1 // SPDX-License-Identifier: GPL-2.0+
3 * ti-adc161s626.c - Texas Instruments ADC161S626 1-channel differential ADC
5 * ADC Devices Supported:
6 * adc141s626 - 14-bit ADC
7 * adc161s626 - 16-bit ADC
9 * Copyright (C) 2016-2018
25 #define TI_ADC_DRV_NAME "ti-adc161s626"
78 struct iio_chan_spec const *chan, int *val) in ti_adc_read_measurement() argument
82 switch (data->read_size) { in ti_adc_read_measurement()
86 ret = spi_read(data->spi, (void *) &buf, 2); in ti_adc_read_measurement()
96 ret = spi_read(data->spi, (void *) &buf, 3); in ti_adc_read_measurement()
104 return -EINVAL; in ti_adc_read_measurement()
107 *val = sign_extend32(*val >> data->shift, chan->scan_type.realbits - 1); in ti_adc_read_measurement()
115 struct iio_dev *indio_dev = pf->indio_dev; in ti_adc_trigger_handler()
119 ret = ti_adc_read_measurement(data, &indio_dev->channels[0], in ti_adc_trigger_handler()
120 (int *) &data->buffer); in ti_adc_trigger_handler()
123 data->buffer, in ti_adc_trigger_handler()
126 iio_trigger_notify_done(indio_dev->trig); in ti_adc_trigger_handler()
132 struct iio_chan_spec const *chan, in ti_adc_read_raw() argument
144 ret = ti_adc_read_measurement(data, chan, val); in ti_adc_read_raw()
152 ret = regulator_get_voltage(data->ref); in ti_adc_read_raw()
157 *val2 = chan->scan_type.realbits; in ti_adc_read_raw()
161 *val = 1 << (chan->scan_type.realbits - 1); in ti_adc_read_raw()
178 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); in ti_adc_probe()
180 return -ENOMEM; in ti_adc_probe()
182 indio_dev->info = &ti_adc_info; in ti_adc_probe()
183 indio_dev->name = TI_ADC_DRV_NAME; in ti_adc_probe()
184 indio_dev->modes = INDIO_DIRECT_MODE; in ti_adc_probe()
188 data->spi = spi; in ti_adc_probe()
190 switch (spi_get_device_id(spi)->driver_data) { in ti_adc_probe()
192 indio_dev->channels = ti_adc141s626_channels; in ti_adc_probe()
193 indio_dev->num_channels = ARRAY_SIZE(ti_adc141s626_channels); in ti_adc_probe()
194 data->shift = 0; in ti_adc_probe()
195 data->read_size = 2; in ti_adc_probe()
198 indio_dev->channels = ti_adc161s626_channels; in ti_adc_probe()
199 indio_dev->num_channels = ARRAY_SIZE(ti_adc161s626_channels); in ti_adc_probe()
200 data->shift = 6; in ti_adc_probe()
201 data->read_size = 3; in ti_adc_probe()
205 data->ref = devm_regulator_get(&spi->dev, "vdda"); in ti_adc_probe()
206 if (!IS_ERR(data->ref)) { in ti_adc_probe()
207 ret = regulator_enable(data->ref); in ti_adc_probe()
227 regulator_disable(data->ref); in ti_adc_probe()
239 regulator_disable(data->ref); in ti_adc_remove()
270 MODULE_DESCRIPTION("Texas Instruments ADC1x1S 1-channel differential ADC");