Lines Matching +full:vref +full:- +full:p

1 // SPDX-License-Identifier: GPL-2.0-only
3 * MAX1117/MAX1118/MAX1119 8-bit, dual-channel ADCs driver
7 * Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1117-MAX1119.pdf
13 * ------ --------- -----------
14 * nCS --> CNVST
15 * SCK --> SCLK
16 * MISO <-- DOUT
17 * ------ --------- -----------
98 .rx_buf = &adc->data, in max1118_read()
105 ret = spi_sync_transfer(adc->spi, xfers + 1, 2); in max1118_read()
107 ret = spi_sync_transfer(adc->spi, xfers, 3); in max1118_read()
112 return adc->data; in max1118_read()
118 const struct spi_device_id *id = spi_get_device_id(adc->spi); in max1118_get_vref_mV()
121 switch (id->driver_data) { in max1118_get_vref_mV()
127 vref_uV = regulator_get_voltage(adc->reg); in max1118_get_vref_mV()
133 return -ENODEV; in max1118_get_vref_mV()
144 mutex_lock(&adc->lock); in max1118_read_raw()
145 *val = max1118_read(indio_dev, chan->channel); in max1118_read_raw()
146 mutex_unlock(&adc->lock); in max1118_read_raw()
160 return -EINVAL; in max1118_read_raw()
167 static irqreturn_t max1118_trigger_handler(int irq, void *p) in max1118_trigger_handler() argument
169 struct iio_poll_func *pf = p; in max1118_trigger_handler()
170 struct iio_dev *indio_dev = pf->indio_dev; in max1118_trigger_handler()
175 mutex_lock(&adc->lock); in max1118_trigger_handler()
177 for_each_set_bit(scan_index, indio_dev->active_scan_mask, in max1118_trigger_handler()
178 indio_dev->masklength) { in max1118_trigger_handler()
180 &indio_dev->channels[scan_index]; in max1118_trigger_handler()
181 int ret = max1118_read(indio_dev, scan_chan->channel); in max1118_trigger_handler()
184 dev_warn(&adc->spi->dev, in max1118_trigger_handler()
189 adc->scan.channels[i] = ret; in max1118_trigger_handler()
192 iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, in max1118_trigger_handler()
195 mutex_unlock(&adc->lock); in max1118_trigger_handler()
197 iio_trigger_notify_done(indio_dev->trig); in max1118_trigger_handler()
214 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in max1118_probe()
216 return -ENOMEM; in max1118_probe()
219 adc->spi = spi; in max1118_probe()
220 mutex_init(&adc->lock); in max1118_probe()
222 if (id->driver_data == max1118) { in max1118_probe()
223 adc->reg = devm_regulator_get(&spi->dev, "vref"); in max1118_probe()
224 if (IS_ERR(adc->reg)) in max1118_probe()
225 return dev_err_probe(&spi->dev, PTR_ERR(adc->reg), in max1118_probe()
226 "failed to get vref regulator\n"); in max1118_probe()
227 ret = regulator_enable(adc->reg); in max1118_probe()
231 ret = devm_add_action_or_reset(&spi->dev, max1118_reg_disable, in max1118_probe()
232 adc->reg); in max1118_probe()
238 indio_dev->name = spi_get_device_id(spi)->name; in max1118_probe()
239 indio_dev->info = &max1118_info; in max1118_probe()
240 indio_dev->modes = INDIO_DIRECT_MODE; in max1118_probe()
241 indio_dev->channels = max1118_channels; in max1118_probe()
242 indio_dev->num_channels = ARRAY_SIZE(max1118_channels); in max1118_probe()
252 ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, in max1118_probe()
257 return devm_iio_device_register(&spi->dev, indio_dev); in max1118_probe()