Lines Matching +full:vref +full:- +full:p
1 // SPDX-License-Identifier: GPL-2.0-only
91 static irqreturn_t tlc4541_trigger_handler(int irq, void *p) in tlc4541_trigger_handler() argument
93 struct iio_poll_func *pf = p; in tlc4541_trigger_handler()
94 struct iio_dev *indio_dev = pf->indio_dev; in tlc4541_trigger_handler()
98 ret = spi_sync(st->spi, &st->scan_single_msg); in tlc4541_trigger_handler()
102 iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, in tlc4541_trigger_handler()
106 iio_trigger_notify_done(indio_dev->trig); in tlc4541_trigger_handler()
112 int vref; in tlc4541_get_range() local
114 vref = regulator_get_voltage(st->reg); in tlc4541_get_range()
115 if (vref < 0) in tlc4541_get_range()
116 return vref; in tlc4541_get_range()
118 vref /= 1000; in tlc4541_get_range()
120 return vref; in tlc4541_get_range()
137 ret = spi_sync(st->spi, &st->scan_single_msg); in tlc4541_read_raw()
141 *val = be16_to_cpu(st->rx_buf[0]); in tlc4541_read_raw()
142 *val = *val >> chan->scan_type.shift; in tlc4541_read_raw()
143 *val &= GENMASK(chan->scan_type.realbits - 1, 0); in tlc4541_read_raw()
150 *val2 = chan->scan_type.realbits; in tlc4541_read_raw()
153 return -EINVAL; in tlc4541_read_raw()
168 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in tlc4541_probe()
170 return -ENOMEM; in tlc4541_probe()
176 st->spi = spi; in tlc4541_probe()
178 info = &tlc4541_chip_info[spi_get_device_id(spi)->driver_data]; in tlc4541_probe()
180 indio_dev->name = spi_get_device_id(spi)->name; in tlc4541_probe()
181 indio_dev->modes = INDIO_DIRECT_MODE; in tlc4541_probe()
182 indio_dev->channels = info->channels; in tlc4541_probe()
183 indio_dev->num_channels = info->num_channels; in tlc4541_probe()
184 indio_dev->info = &tlc4541_info; in tlc4541_probe()
190 st->scan_single_xfer[0].rx_buf = &st->rx_buf[0]; in tlc4541_probe()
191 st->scan_single_xfer[0].len = 3; in tlc4541_probe()
192 st->scan_single_xfer[1].delay.value = 3; in tlc4541_probe()
193 st->scan_single_xfer[1].delay.unit = SPI_DELAY_UNIT_NSECS; in tlc4541_probe()
194 st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; in tlc4541_probe()
195 st->scan_single_xfer[2].len = 2; in tlc4541_probe()
197 spi_message_init_with_transfers(&st->scan_single_msg, in tlc4541_probe()
198 st->scan_single_xfer, 3); in tlc4541_probe()
200 st->reg = devm_regulator_get(&spi->dev, "vref"); in tlc4541_probe()
201 if (IS_ERR(st->reg)) in tlc4541_probe()
202 return PTR_ERR(st->reg); in tlc4541_probe()
204 ret = regulator_enable(st->reg); in tlc4541_probe()
222 regulator_disable(st->reg); in tlc4541_probe()
234 regulator_disable(st->reg); in tlc4541_remove()