Lines Matching +full:iio +full:- +full:consumer

1 // SPDX-License-Identifier: GPL-2.0
15 #include <linux/regulator/consumer.h>
18 #include <linux/gpio/consumer.h>
22 #include <linux/iio/iio.h>
23 #include <linux/iio/sysfs.h>
24 #include <linux/iio/adc/ad_sigma_delta.h>
100 gpiod_set_value(st->powerdown_gpio, val); in ad7780_set_mode()
118 voltage_uv = regulator_get_voltage(st->reg); in ad7780_read_raw()
122 *val = voltage_uv * st->gain; in ad7780_read_raw()
123 *val2 = chan->scan_type.realbits - 1; in ad7780_read_raw()
124 st->int_vref_mv = voltage_uv; in ad7780_read_raw()
127 *val = -(1 << (chan->scan_type.realbits - 1)); in ad7780_read_raw()
130 *val = st->odr; in ad7780_read_raw()
136 return -EINVAL; in ad7780_read_raw()
146 const struct ad7780_chip_info *chip_info = st->chip_info; in ad7780_write_raw()
150 if (!chip_info->is_ad778x) in ad7780_write_raw()
151 return -EINVAL; in ad7780_write_raw()
156 return -EINVAL; in ad7780_write_raw()
158 vref = st->int_vref_mv * 1000000LL; in ad7780_write_raw()
159 full_scale = 1 << (chip_info->channel.scan_type.realbits - 1); in ad7780_write_raw()
162 st->gain = gain; in ad7780_write_raw()
167 gpiod_set_value(st->gain_gpio, gain); in ad7780_write_raw()
174 st->odr = ad778x_odr_avail[val]; in ad7780_write_raw()
175 gpiod_set_value(st->filter_gpio, val); in ad7780_write_raw()
188 const struct ad7780_chip_info *chip_info = st->chip_info; in ad7780_postprocess_sample()
191 ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) in ad7780_postprocess_sample()
192 return -EIO; in ad7780_postprocess_sample()
194 if (chip_info->is_ad778x) { in ad7780_postprocess_sample()
195 st->gain = ad778x_gain[raw_sample & AD7780_GAIN]; in ad7780_postprocess_sample()
196 st->odr = ad778x_odr_avail[raw_sample & AD7780_FILTER]; in ad7780_postprocess_sample()
223 .shift = (_wordsize) - (_bits), \
269 st->powerdown_gpio = devm_gpiod_get_optional(dev, in ad7780_init_gpios()
272 if (IS_ERR(st->powerdown_gpio)) { in ad7780_init_gpios()
273 ret = PTR_ERR(st->powerdown_gpio); in ad7780_init_gpios()
278 if (!st->chip_info->is_ad778x) in ad7780_init_gpios()
282 st->gain_gpio = devm_gpiod_get_optional(dev, in ad7780_init_gpios()
285 if (IS_ERR(st->gain_gpio)) { in ad7780_init_gpios()
286 ret = PTR_ERR(st->gain_gpio); in ad7780_init_gpios()
291 st->filter_gpio = devm_gpiod_get_optional(dev, in ad7780_init_gpios()
294 if (IS_ERR(st->filter_gpio)) { in ad7780_init_gpios()
295 ret = PTR_ERR(st->filter_gpio); in ad7780_init_gpios()
314 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7780_probe()
316 return -ENOMEM; in ad7780_probe()
319 st->gain = 1; in ad7780_probe()
321 ad_sd_init(&st->sd, indio_dev, spi, &ad7780_sigma_delta_info); in ad7780_probe()
323 st->chip_info = in ad7780_probe()
324 &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; in ad7780_probe()
326 indio_dev->name = spi_get_device_id(spi)->name; in ad7780_probe()
327 indio_dev->modes = INDIO_DIRECT_MODE; in ad7780_probe()
328 indio_dev->channels = &st->chip_info->channel; in ad7780_probe()
329 indio_dev->num_channels = 1; in ad7780_probe()
330 indio_dev->info = &ad7780_info; in ad7780_probe()
332 ret = ad7780_init_gpios(&spi->dev, st); in ad7780_probe()
336 st->reg = devm_regulator_get(&spi->dev, "avdd"); in ad7780_probe()
337 if (IS_ERR(st->reg)) in ad7780_probe()
338 return PTR_ERR(st->reg); in ad7780_probe()
340 ret = regulator_enable(st->reg); in ad7780_probe()
342 dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); in ad7780_probe()
346 ret = devm_add_action_or_reset(&spi->dev, ad7780_reg_disable, st->reg); in ad7780_probe()
350 ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev); in ad7780_probe()
354 return devm_iio_device_register(&spi->dev, indio_dev); in ad7780_probe()