Lines Matching +full:ain0 +full:- +full:ain1
1 // SPDX-License-Identifier: GPL-2.0+
28 /* average 4-time conversion mode */
52 AIN1, enumerator
53 AIN0 enumerator
63 [AIN1] = {1, 1},
64 [AIN0] = {1, 1},
72 ret = regmap_bulk_read(rn5t618->regmap, reg, data, sizeof(data)); in rn5t618_read_adc_reg()
88 regmap_write(adc->rn5t618->regmap, RN5T618_IR_ADC1, 0); in rn5t618_adc_irq()
89 regmap_write(adc->rn5t618->regmap, RN5T618_IR_ADC2, 0); in rn5t618_adc_irq()
91 ret = regmap_read(adc->rn5t618->regmap, RN5T618_IR_ADC3, &r); in rn5t618_adc_irq()
93 dev_err(adc->dev, "failed to read IRQ status: %d\n", ret); in rn5t618_adc_irq()
95 regmap_write(adc->rn5t618->regmap, RN5T618_IR_ADC3, 0); in rn5t618_adc_irq()
98 complete(&adc->conv_completion); in rn5t618_adc_irq()
113 rn5t618_ratios[chan->channel].numerator; in rn5t618_adc_read()
114 *val2 = rn5t618_ratios[chan->channel].denominator * 4095; in rn5t618_adc_read()
120 ret = regmap_update_bits(adc->rn5t618->regmap, RN5T618_ADCCNT3, in rn5t618_adc_read()
122 chan->channel); in rn5t618_adc_read()
126 ret = regmap_write(adc->rn5t618->regmap, RN5T618_EN_ADCIR3, in rn5t618_adc_read()
131 ret = regmap_update_bits(adc->rn5t618->regmap, RN5T618_ADCCNT3, in rn5t618_adc_read()
138 init_completion(&adc->conv_completion); in rn5t618_adc_read()
140 ret = regmap_set_bits(adc->rn5t618->regmap, RN5T618_ADCCNT3, in rn5t618_adc_read()
145 ret = wait_for_completion_timeout(&adc->conv_completion, in rn5t618_adc_read()
148 dev_warn(adc->dev, "timeout waiting for adc result\n"); in rn5t618_adc_read()
149 return -ETIMEDOUT; in rn5t618_adc_read()
152 ret = rn5t618_read_adc_reg(adc->rn5t618, in rn5t618_adc_read()
153 RN5T618_ILIMDATAH + 2 * chan->channel, in rn5t618_adc_read()
184 RN5T618_ADC_CHANNEL(AIN1, IIO_VOLTAGE, "AIN1"),
185 RN5T618_ADC_CHANNEL(AIN0, IIO_VOLTAGE, "AIN0")
189 IIO_MAP("VADP", "rn5t618-power", "vadp"),
190 IIO_MAP("VUSB", "rn5t618-power", "vusb"),
199 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); in rn5t618_adc_probe()
201 iio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); in rn5t618_adc_probe()
203 dev_err(&pdev->dev, "failed allocating iio device\n"); in rn5t618_adc_probe()
204 return -ENOMEM; in rn5t618_adc_probe()
208 adc->dev = &pdev->dev; in rn5t618_adc_probe()
209 adc->rn5t618 = rn5t618; in rn5t618_adc_probe()
211 if (rn5t618->irq_data) in rn5t618_adc_probe()
212 adc->irq = regmap_irq_get_virq(rn5t618->irq_data, in rn5t618_adc_probe()
215 if (adc->irq <= 0) { in rn5t618_adc_probe()
216 dev_err(&pdev->dev, "get virq failed\n"); in rn5t618_adc_probe()
217 return -EINVAL; in rn5t618_adc_probe()
220 init_completion(&adc->conv_completion); in rn5t618_adc_probe()
222 iio_dev->name = dev_name(&pdev->dev); in rn5t618_adc_probe()
223 iio_dev->info = &rn5t618_adc_iio_info; in rn5t618_adc_probe()
224 iio_dev->modes = INDIO_DIRECT_MODE; in rn5t618_adc_probe()
225 iio_dev->channels = rn5t618_adc_iio_channels; in rn5t618_adc_probe()
226 iio_dev->num_channels = ARRAY_SIZE(rn5t618_adc_iio_channels); in rn5t618_adc_probe()
228 /* stop any auto-conversion */ in rn5t618_adc_probe()
229 ret = regmap_write(rn5t618->regmap, RN5T618_ADCCNT3, 0); in rn5t618_adc_probe()
235 ret = devm_request_threaded_irq(adc->dev, adc->irq, NULL, in rn5t618_adc_probe()
237 IRQF_ONESHOT, dev_name(adc->dev), in rn5t618_adc_probe()
240 dev_err(adc->dev, "request irq %d failed: %d\n", adc->irq, ret); in rn5t618_adc_probe()
244 ret = devm_iio_map_array_register(adc->dev, iio_dev, rn5t618_maps); in rn5t618_adc_probe()
248 return devm_iio_device_register(adc->dev, iio_dev); in rn5t618_adc_probe()
253 .name = "rn5t618-adc",
259 MODULE_ALIAS("platform:rn5t618-adc");