Lines Matching +full:adc +full:- +full:diff +full:- +full:channels

1 // SPDX-License-Identifier: GPL-2.0
3 * Analog Devices AD7292 SPI ADC driver
94 st->d8[0] = AD7292_RD_FLAG_MSK(addr); in ad7292_spi_reg_read()
96 ret = spi_write_then_read(st->spi, st->d8, 1, &st->d16, 2); in ad7292_spi_reg_read()
100 return be16_to_cpu(st->d16); in ad7292_spi_reg_read()
106 unsigned int shift = 16 - (8 * len); in ad7292_spi_subreg_read()
109 st->d8[0] = AD7292_RD_FLAG_MSK(addr); in ad7292_spi_subreg_read()
110 st->d8[1] = sub_addr; in ad7292_spi_subreg_read()
112 ret = spi_write_then_read(st->spi, st->d8, 2, &st->d16, len); in ad7292_spi_subreg_read()
116 return (be16_to_cpu(st->d16) >> shift); in ad7292_spi_subreg_read()
126 .tx_buf = &st->d8, in ad7292_single_conversion()
133 .rx_buf = &st->d16, in ad7292_single_conversion()
138 st->d8[0] = chan_addr; in ad7292_single_conversion()
139 st->d8[1] = AD7292_RD_FLAG_MSK(AD7292_REG_CONV_COMM); in ad7292_single_conversion()
141 ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); in ad7292_single_conversion()
146 return be16_to_cpu(st->d16); in ad7292_single_conversion()
154 * Every AD7292 ADC channel may have its input range adjusted according in ad7292_vin_range_multiplier()
155 * to the settings at the ADC sampling mode and VIN range subregisters. in ad7292_vin_range_multiplier()
198 return -EPERM; in ad7292_vin_range_multiplier()
216 ch_addr = AD7292_REG_ADC_CH(chan->channel); in ad7292_read_raw()
230 * number of possible distinct input values. Given the ADC data in ad7292_read_raw()
237 ret = ad7292_vin_range_multiplier(st, chan->channel); in ad7292_read_raw()
241 *val = st->vref_mv * ret; in ad7292_read_raw()
247 return -EINVAL; in ad7292_read_raw()
261 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7292_probe()
263 return -ENOMEM; in ad7292_probe()
266 st->spi = spi; in ad7292_probe()
270 dev_err(&spi->dev, "Wrong vendor id 0x%x\n", ret); in ad7292_probe()
271 return -EINVAL; in ad7292_probe()
274 ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref"); in ad7292_probe()
275 if (ret < 0 && ret != -ENODEV) in ad7292_probe()
278 st->vref_mv = ret == -ENODEV ? AD7292_INTERNAL_REF_MV : ret / 1000; in ad7292_probe()
280 indio_dev->name = spi_get_device_id(spi)->name; in ad7292_probe()
281 indio_dev->modes = INDIO_DIRECT_MODE; in ad7292_probe()
282 indio_dev->info = &ad7292_info; in ad7292_probe()
284 device_for_each_child_node_scoped(&spi->dev, child) { in ad7292_probe()
286 "diff-channels"); in ad7292_probe()
292 indio_dev->num_channels = ARRAY_SIZE(ad7292_channels_diff); in ad7292_probe()
293 indio_dev->channels = ad7292_channels_diff; in ad7292_probe()
295 indio_dev->num_channels = ARRAY_SIZE(ad7292_channels); in ad7292_probe()
296 indio_dev->channels = ad7292_channels; in ad7292_probe()
299 return devm_iio_device_register(&spi->dev, indio_dev); in ad7292_probe()
325 MODULE_DESCRIPTION("Analog Devices AD7292 ADC driver");