Skip to content

Commit 754718a

Browse files
xc-racer99jic23
authored andcommitted
iio: adc: Add scaling support to exynos adc driver
Currently the driver only exposes the raw counts. As we have the regulator voltage and the maximum value (stored in the data mask), we can trivially produce a scaling fraction of voltage / max value. This assumes that the regulator voltage is in fact the max voltage, which appears to be the case for all mainline dts and cross referenced with the public Exynos4412 and S5PV210 datasheets. Signed-off-by: Jonathan Bakker <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 5cb1a54 commit 754718a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/iio/adc/exynos_adc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,19 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
531531
unsigned long timeout;
532532
int ret;
533533

534-
if (mask != IIO_CHAN_INFO_RAW)
534+
if (mask == IIO_CHAN_INFO_SCALE) {
535+
ret = regulator_get_voltage(info->vdd);
536+
if (ret < 0)
537+
return ret;
538+
539+
/* Regulator voltage is in uV, but need mV */
540+
*val = ret / 1000;
541+
*val2 = info->data->mask;
542+
543+
return IIO_VAL_FRACTIONAL;
544+
} else if (mask != IIO_CHAN_INFO_RAW) {
535545
return -EINVAL;
546+
}
536547

537548
mutex_lock(&indio_dev->mlock);
538549
reinit_completion(&info->completion);
@@ -683,6 +694,7 @@ static const struct iio_info exynos_adc_iio_info = {
683694
.channel = _index, \
684695
.address = _index, \
685696
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
697+
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SCALE), \
686698
.datasheet_name = _id, \
687699
}
688700

0 commit comments

Comments
 (0)