public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel•org>
To: Jonathan Bakker <xc-racer2@live•ca>
Cc: kstewart@linuxfoundation•org, linux-samsung-soc@vger•kernel.org,
	lars@metafoo•de, linux-iio@vger•kernel.org, mpe@ellerman•id.au,
	linux-kernel@vger•kernel.org, krzk@kernel•org,
	swboyd@chromium•org, cw00.choi@samsung•com, kgene@kernel•org,
	pmeerw@pmeerw•net, knaack.h@gmx•de, tglx@linutronix•de,
	linux-arm-kernel@lists•infradead.org, m.szyprowski@samsung•com
Subject: Re: [PATCH] iio: adc: Add scaling support to exynos adc driver
Date: Sun, 10 May 2020 11:24:17 +0100	[thread overview]
Message-ID: <20200510112417.1e54d66e@archlinux> (raw)
In-Reply-To: <BN6PR04MB066058A68D6471E7F6AFCFF7A3A20@BN6PR04MB0660.namprd04.prod.outlook.com>

On Fri,  8 May 2020 14:14:00 -0700
Jonathan Bakker <xc-racer2@live•ca> wrote:

> 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 <xc-racer2@live•ca>

Seems reasonable to me. I'd like an exynos Ack though before applying.

thanks,

Jonathan


> ---
>  drivers/iio/adc/exynos_adc.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index 22131a677445..9d29b56805cd 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -531,8 +531,19 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>  	unsigned long timeout;
>  	int ret;
>  
> -	if (mask != IIO_CHAN_INFO_RAW)
> +	if (mask == IIO_CHAN_INFO_SCALE) {
> +		ret = regulator_get_voltage(info->vdd);
> +		if (ret < 0)
> +			return ret;
> +
> +		/* Regulator voltage is in uV, but need mV */
> +		*val = ret / 1000;
> +		*val2 = info->data->mask;
> +
> +		return IIO_VAL_FRACTIONAL;
> +	} else if (mask != IIO_CHAN_INFO_RAW) {
>  		return -EINVAL;
> +	}
>  
>  	mutex_lock(&indio_dev->mlock);
>  	reinit_completion(&info->completion);
> @@ -683,6 +694,7 @@ static const struct iio_info exynos_adc_iio_info = {
>  	.channel = _index,				\
>  	.address = _index,				\
>  	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),	\
> +	.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SCALE),	\
>  	.datasheet_name = _id,				\
>  }
>  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-05-10 10:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 21:14 [PATCH] iio: adc: Add scaling support to exynos adc driver Jonathan Bakker
2020-05-10 10:24 ` Jonathan Cameron [this message]
2020-05-11  7:42   ` Krzysztof Kozlowski
2020-05-16 18:19     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200510112417.1e54d66e@archlinux \
    --to=jic23@kernel$(echo .)org \
    --cc=cw00.choi@samsung$(echo .)com \
    --cc=kgene@kernel$(echo .)org \
    --cc=knaack.h@gmx$(echo .)de \
    --cc=krzk@kernel$(echo .)org \
    --cc=kstewart@linuxfoundation$(echo .)org \
    --cc=lars@metafoo$(echo .)de \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-iio@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-samsung-soc@vger$(echo .)kernel.org \
    --cc=m.szyprowski@samsung$(echo .)com \
    --cc=mpe@ellerman$(echo .)id.au \
    --cc=pmeerw@pmeerw$(echo .)net \
    --cc=swboyd@chromium$(echo .)org \
    --cc=tglx@linutronix$(echo .)de \
    --cc=xc-racer2@live$(echo .)ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox