Lines Matching +full:convert +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0-or-later
23 /* Channels */
88 complete(&gpadc->complete); in da9150_gpadc_irq()
98 mutex_lock(&gpadc->lock); in da9150_gpadc_read_adc()
101 da9150_reg_write(gpadc->da9150, DA9150_GPADC_MAN, in da9150_gpadc_read_adc()
105 /* Consume left-over completion from a previous timeout */ in da9150_gpadc_read_adc()
106 try_wait_for_completion(&gpadc->complete); in da9150_gpadc_read_adc()
109 wait_for_completion_timeout(&gpadc->complete, msecs_to_jiffies(5)); in da9150_gpadc_read_adc()
112 da9150_bulk_read(gpadc->da9150, DA9150_GPADC_RES_A, 2, result_regs); in da9150_gpadc_read_adc()
114 mutex_unlock(&gpadc->lock); in da9150_gpadc_read_adc()
118 dev_err(gpadc->dev, "Timeout on channel %d of GPADC\n", in da9150_gpadc_read_adc()
120 return -ETIMEDOUT; in da9150_gpadc_read_adc()
123 /* LSBs - 2 bits */ in da9150_gpadc_read_adc()
126 /* MSBs - 8 bits */ in da9150_gpadc_read_adc()
134 /* Convert to mV */ in da9150_gpadc_gpio_6v_voltage_now()
140 /* Convert to mA */ in da9150_gpadc_ibus_current_avg()
146 /* Convert to mV */ in da9150_gpadc_vbus_21v_voltage_now()
152 /* Convert to mV */ in da9150_gpadc_vsys_6v_voltage_now()
182 /* No processing for other channels so return raw value */ in da9150_gpadc_read_processed()
203 return -EINVAL; in da9150_gpadc_read_scale()
215 *val = -144; in da9150_gpadc_read_offset()
218 return -EINVAL; in da9150_gpadc_read_offset()
228 if ((chan->channel < DA9150_GPADC_CHAN_GPIOA) || in da9150_gpadc_read_raw()
229 (chan->channel > DA9150_GPADC_CHAN_TJUNC_OVP)) in da9150_gpadc_read_raw()
230 return -EINVAL; in da9150_gpadc_read_raw()
235 return da9150_gpadc_read_processed(gpadc, chan->channel, in da9150_gpadc_read_raw()
236 chan->address, val); in da9150_gpadc_read_raw()
238 return da9150_gpadc_read_scale(chan->channel, val, val2); in da9150_gpadc_read_raw()
240 return da9150_gpadc_read_offset(chan->channel, val); in da9150_gpadc_read_raw()
242 return -EINVAL; in da9150_gpadc_read_raw()
276 /* Supported channels */
293 /* Default maps used by da9150-charger */
296 .consumer_dev_name = "da9150-charger",
301 .consumer_dev_name = "da9150-charger",
306 .consumer_dev_name = "da9150-charger",
311 .consumer_dev_name = "da9150-charger",
320 struct device *dev = &pdev->dev; in da9150_gpadc_probe()
321 struct da9150 *da9150 = dev_get_drvdata(dev->parent); in da9150_gpadc_probe()
328 dev_err(&pdev->dev, "Failed to allocate IIO device\n"); in da9150_gpadc_probe()
329 return -ENOMEM; in da9150_gpadc_probe()
333 gpadc->da9150 = da9150; in da9150_gpadc_probe()
334 gpadc->dev = dev; in da9150_gpadc_probe()
335 mutex_init(&gpadc->lock); in da9150_gpadc_probe()
336 init_completion(&gpadc->complete); in da9150_gpadc_probe()
349 ret = devm_iio_map_array_register(&pdev->dev, indio_dev, da9150_gpadc_default_maps); in da9150_gpadc_probe()
355 indio_dev->name = dev_name(dev); in da9150_gpadc_probe()
356 indio_dev->info = &da9150_gpadc_info; in da9150_gpadc_probe()
357 indio_dev->modes = INDIO_DIRECT_MODE; in da9150_gpadc_probe()
358 indio_dev->channels = da9150_gpadc_channels; in da9150_gpadc_probe()
359 indio_dev->num_channels = ARRAY_SIZE(da9150_gpadc_channels); in da9150_gpadc_probe()
361 return devm_iio_device_register(&pdev->dev, indio_dev); in da9150_gpadc_probe()
366 .name = "da9150-gpadc",