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

1 // SPDX-License-Identifier: GPL-2.0-or-later
12 #include <linux/gpio/consumer.h>
14 #include <linux/regulator/consumer.h>
18 #include <linux/iio/iio.h>
19 #include <linux/iio/buffer.h>
20 #include <linux/iio/trigger.h>
21 #include <linux/iio/trigger_consumer.h>
22 #include <linux/iio/triggered_buffer.h>
69 struct iio_dev *indio_dev = pf->indio_dev; in ad7766_trigger_handler()
73 ret = spi_sync(ad7766->spi, &ad7766->msg); in ad7766_trigger_handler()
77 iio_push_to_buffers_with_timestamp(indio_dev, ad7766->data, in ad7766_trigger_handler()
78 pf->timestamp); in ad7766_trigger_handler()
80 iio_trigger_notify_done(indio_dev->trig); in ad7766_trigger_handler()
90 ret = regulator_bulk_enable(ARRAY_SIZE(ad7766->reg), ad7766->reg); in ad7766_preenable()
92 dev_err(&ad7766->spi->dev, "Failed to enable supplies: %d\n", in ad7766_preenable()
97 ret = clk_prepare_enable(ad7766->mclk); in ad7766_preenable()
99 dev_err(&ad7766->spi->dev, "Failed to enable MCLK: %d\n", ret); in ad7766_preenable()
100 regulator_bulk_disable(ARRAY_SIZE(ad7766->reg), ad7766->reg); in ad7766_preenable()
104 gpiod_set_value(ad7766->pd_gpio, 0); in ad7766_preenable()
113 gpiod_set_value(ad7766->pd_gpio, 1); in ad7766_postdisable()
121 clk_disable_unprepare(ad7766->mclk); in ad7766_postdisable()
122 regulator_bulk_disable(ARRAY_SIZE(ad7766->reg), ad7766->reg); in ad7766_postdisable()
131 struct regulator *vref = ad7766->reg[AD7766_SUPPLY_VREF].consumer; in ad7766_read_raw()
140 *val2 = chan->scan_type.realbits; in ad7766_read_raw()
143 *val = clk_get_rate(ad7766->mclk) / in ad7766_read_raw()
144 ad7766->chip_info->decimation_factor; in ad7766_read_raw()
147 return -EINVAL; in ad7766_read_raw()
198 enable_irq(ad7766->spi->irq); in ad7766_set_trigger_state()
200 disable_irq(ad7766->spi->irq); in ad7766_set_trigger_state()
217 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*ad7766)); in ad7766_probe()
219 return -ENOMEM; in ad7766_probe()
222 ad7766->chip_info = &ad7766_chip_info[id->driver_data]; in ad7766_probe()
224 ad7766->mclk = devm_clk_get(&spi->dev, "mclk"); in ad7766_probe()
225 if (IS_ERR(ad7766->mclk)) in ad7766_probe()
226 return PTR_ERR(ad7766->mclk); in ad7766_probe()
228 ad7766->reg[AD7766_SUPPLY_AVDD].supply = "avdd"; in ad7766_probe()
229 ad7766->reg[AD7766_SUPPLY_DVDD].supply = "dvdd"; in ad7766_probe()
230 ad7766->reg[AD7766_SUPPLY_VREF].supply = "vref"; in ad7766_probe()
232 ret = devm_regulator_bulk_get(&spi->dev, ARRAY_SIZE(ad7766->reg), in ad7766_probe()
233 ad7766->reg); in ad7766_probe()
237 ad7766->pd_gpio = devm_gpiod_get_optional(&spi->dev, "powerdown", in ad7766_probe()
239 if (IS_ERR(ad7766->pd_gpio)) in ad7766_probe()
240 return PTR_ERR(ad7766->pd_gpio); in ad7766_probe()
242 indio_dev->name = spi_get_device_id(spi)->name; in ad7766_probe()
243 indio_dev->modes = INDIO_DIRECT_MODE; in ad7766_probe()
244 indio_dev->channels = ad7766_channels; in ad7766_probe()
245 indio_dev->num_channels = ARRAY_SIZE(ad7766_channels); in ad7766_probe()
246 indio_dev->info = &ad7766_info; in ad7766_probe()
248 if (spi->irq > 0) { in ad7766_probe()
249 ad7766->trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d", in ad7766_probe()
250 indio_dev->name, in ad7766_probe()
252 if (!ad7766->trig) in ad7766_probe()
253 return -ENOMEM; in ad7766_probe()
255 ad7766->trig->ops = &ad7766_trigger_ops; in ad7766_probe()
256 iio_trigger_set_drvdata(ad7766->trig, ad7766); in ad7766_probe()
263 ret = devm_request_irq(&spi->dev, spi->irq, ad7766_irq, in ad7766_probe()
265 dev_name(&spi->dev), in ad7766_probe()
266 ad7766->trig); in ad7766_probe()
270 ret = devm_iio_trigger_register(&spi->dev, ad7766->trig); in ad7766_probe()
275 ad7766->spi = spi; in ad7766_probe()
278 ad7766->xfer.rx_buf = &ad7766->data[1]; in ad7766_probe()
279 ad7766->xfer.len = 3; in ad7766_probe()
281 spi_message_init(&ad7766->msg); in ad7766_probe()
282 spi_message_add_tail(&ad7766->xfer, &ad7766->msg); in ad7766_probe()
284 ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, in ad7766_probe()
290 return devm_iio_device_register(&spi->dev, indio_dev); in ad7766_probe()
295 { "ad7766-1", ID_AD7766_1 },
296 { "ad7766-2", ID_AD7766_2 },
298 { "ad7767-1", ID_AD7766_1 },
299 { "ad7767-2", ID_AD7766_2 },
313 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");