Lines Matching +full:vref +full:- +full:out +full:- +full:en
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()
170 struct iio_dev *indio_dev = pf->indio_dev; in max1118_trigger_handler()
175 mutex_lock(&adc->lock); in max1118_trigger_handler()
179 &indio_dev->channels[scan_index]; in max1118_trigger_handler()
180 int ret = max1118_read(indio_dev, scan_chan->channel); in max1118_trigger_handler()
183 dev_warn(&adc->spi->dev, in max1118_trigger_handler()
185 goto out; in max1118_trigger_handler()
188 adc->scan.channels[i] = ret; in max1118_trigger_handler()
191 iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, in max1118_trigger_handler()
193 out: in max1118_trigger_handler()
194 mutex_unlock(&adc->lock); in max1118_trigger_handler()
196 iio_trigger_notify_done(indio_dev->trig); in max1118_trigger_handler()
213 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); in max1118_probe()
215 return -ENOMEM; in max1118_probe()
218 adc->spi = spi; in max1118_probe()
219 mutex_init(&adc->lock); in max1118_probe()
221 if (id->driver_data == max1118) { in max1118_probe()
222 adc->reg = devm_regulator_get(&spi->dev, "vref"); in max1118_probe()
223 if (IS_ERR(adc->reg)) in max1118_probe()
224 return dev_err_probe(&spi->dev, PTR_ERR(adc->reg), in max1118_probe()
225 "failed to get vref regulator\n"); in max1118_probe()
226 ret = regulator_enable(adc->reg); in max1118_probe()
230 ret = devm_add_action_or_reset(&spi->dev, max1118_reg_disable, in max1118_probe()
231 adc->reg); in max1118_probe()
237 indio_dev->name = spi_get_device_id(spi)->name; in max1118_probe()
238 indio_dev->info = &max1118_info; in max1118_probe()
239 indio_dev->modes = INDIO_DIRECT_MODE; in max1118_probe()
240 indio_dev->channels = max1118_channels; in max1118_probe()
241 indio_dev->num_channels = ARRAY_SIZE(max1118_channels); in max1118_probe()
245 * conversion to be complete and all of the data to be read out. Once in max1118_probe()
251 ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, in max1118_probe()
256 return devm_iio_device_register(&spi->dev, indio_dev); in max1118_probe()