Lines Matching +full:refin +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
71 .differential = (_channel2 == -1 ? 0 : 1), \
99 __AD7991_CHANNEL(_si, _channel, -1, _address, _bits, \
111 __AD7991_CHANNEL(_si, _channel, -1, _address, _bits, \
112 _storagebits, _shift, "supply", IIO_VOLTAGE, \
244 st->mode &= ~AD7791_MODE_SEL_MASK; in ad7791_set_mode()
245 st->mode |= AD7791_MODE_SEL(mode); in ad7791_set_mode()
247 return ad_sd_write_reg(sd, AD7791_REG_MODE, sizeof(st->mode), st->mode); in ad7791_set_mode()
263 bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR); in ad7791_read_raw()
272 * Bipolar -VREF to VREF in ad7791_read_raw()
277 *val = -(1 << (chan->scan_type.realbits - 1)); in ad7791_read_raw()
281 if (chan->address == AD7791_CH_AVDD_MONITOR) { in ad7791_read_raw()
290 voltage_uv = regulator_get_voltage(st->reg); in ad7791_read_raw()
297 *val2 = chan->scan_type.realbits; in ad7791_read_raw()
299 *val2 = chan->scan_type.realbits - 1; in ad7791_read_raw()
303 rate = st->filter & AD7791_FILTER_RATE_MASK; in ad7791_read_raw()
309 return -EINVAL; in ad7791_read_raw()
331 ret = -EINVAL; in ad7791_write_raw()
335 st->filter &= ~AD7791_FILTER_RATE_MASK; in ad7791_write_raw()
336 st->filter |= i; in ad7791_write_raw()
337 ad_sd_write_reg(&st->sd, AD7791_REG_FILTER, in ad7791_write_raw()
338 sizeof(st->filter), in ad7791_write_raw()
339 st->filter); in ad7791_write_raw()
342 ret = -EINVAL; in ad7791_write_raw()
376 /* Set to poweron-reset default values */ in ad7791_setup()
377 st->mode = AD7791_MODE_BUFFER; in ad7791_setup()
378 st->filter = AD7791_FILTER_RATE_16_6; in ad7791_setup()
383 if ((st->info->flags & AD7791_FLAG_HAS_BUFFER) && !pdata->buffered) in ad7791_setup()
384 st->mode &= ~AD7791_MODE_BUFFER; in ad7791_setup()
386 if ((st->info->flags & AD7791_FLAG_HAS_BURNOUT) && in ad7791_setup()
387 pdata->burnout_current) in ad7791_setup()
388 st->mode |= AD7791_MODE_BURNOUT; in ad7791_setup()
390 if ((st->info->flags & AD7791_FLAG_HAS_UNIPOLAR) && pdata->unipolar) in ad7791_setup()
391 st->mode |= AD7791_MODE_UNIPOLAR; in ad7791_setup()
393 return ad_sd_write_reg(&st->sd, AD7791_REG_MODE, sizeof(st->mode), in ad7791_setup()
394 st->mode); in ad7791_setup()
404 struct ad7791_platform_data *pdata = spi->dev.platform_data; in ad7791_probe()
409 if (!spi->irq) { in ad7791_probe()
410 dev_err(&spi->dev, "Missing IRQ.\n"); in ad7791_probe()
411 return -ENXIO; in ad7791_probe()
414 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7791_probe()
416 return -ENOMEM; in ad7791_probe()
420 st->reg = devm_regulator_get(&spi->dev, "refin"); in ad7791_probe()
421 if (IS_ERR(st->reg)) in ad7791_probe()
422 return PTR_ERR(st->reg); in ad7791_probe()
424 ret = regulator_enable(st->reg); in ad7791_probe()
428 ret = devm_add_action_or_reset(&spi->dev, ad7791_reg_disable, st->reg); in ad7791_probe()
432 st->info = &ad7791_chip_infos[spi_get_device_id(spi)->driver_data]; in ad7791_probe()
433 ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info); in ad7791_probe()
435 indio_dev->name = spi_get_device_id(spi)->name; in ad7791_probe()
436 indio_dev->modes = INDIO_DIRECT_MODE; in ad7791_probe()
437 indio_dev->channels = st->info->channels; in ad7791_probe()
438 indio_dev->num_channels = st->info->num_channels; in ad7791_probe()
439 if (st->info->flags & AD7791_FLAG_HAS_FILTER) in ad7791_probe()
440 indio_dev->info = &ad7791_info; in ad7791_probe()
442 indio_dev->info = &ad7791_no_filter_info; in ad7791_probe()
444 ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev); in ad7791_probe()
452 return devm_iio_device_register(&spi->dev, indio_dev); in ad7791_probe()
474 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");