linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Sanchayan Maity <maitysanchayan@gmail.com>
Cc: stefan@agner.ch, shawn.guo@freescale.com, B38611@freescale.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] drivers/iio/adc/vf610-adc: Add temperature sensor support
Date: Sun, 21 Sep 2014 13:27:00 +0100	[thread overview]
Message-ID: <541EC414.5050505@kernel.org> (raw)
In-Reply-To: <0d7ce38f3f0550a485293d854832304463e215cf.1411128738.git.maitysanchayan@gmail.com>

On 19/09/14 13:58, Sanchayan Maity wrote:
> Vybrid ADC peripheral includes a temperature sensor
> which is connected to channel number 26. This patch
> adds support for the sensor. The raw value is read
> and the temperature calculated in milli degree Celsius,
> which is returned using IIO_CHAN_INFO_PROCESSED option.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
Applied to the togreg branch of iio.git initially pushed out as testing
for the autobuilders to play.

Amended the patch title to fit with the style we have somehow
ended up with for IIO patches.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/vf610_adc.c |   28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
> index 44799eb5..52af611 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -91,7 +91,7 @@
>  #define VF610_ADC_CAL			0x80
>  
>  /* Other field define */
> -#define VF610_ADC_ADCHC(x)		((x) & 0xF)
> +#define VF610_ADC_ADCHC(x)		((x) & 0x1F)
>  #define VF610_ADC_AIEN			(0x1 << 7)
>  #define VF610_ADC_CONV_DISABLE		0x1F
>  #define VF610_ADC_HS_COCO0		0x1
> @@ -153,6 +153,12 @@ struct vf610_adc {
>  				BIT(IIO_CHAN_INFO_SAMP_FREQ),	\
>  }
>  
> +#define VF610_ADC_TEMPERATURE_CHAN(_idx, _chan_type) {	\
> +	.type = (_chan_type),	\
> +	.channel = (_idx),		\
> +	.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),	\
> +}
> +
>  static const struct iio_chan_spec vf610_adc_iio_channels[] = {
>  	VF610_ADC_CHAN(0, IIO_VOLTAGE),
>  	VF610_ADC_CHAN(1, IIO_VOLTAGE),
> @@ -170,6 +176,7 @@ static const struct iio_chan_spec vf610_adc_iio_channels[] = {
>  	VF610_ADC_CHAN(13, IIO_VOLTAGE),
>  	VF610_ADC_CHAN(14, IIO_VOLTAGE),
>  	VF610_ADC_CHAN(15, IIO_VOLTAGE),
> +	VF610_ADC_TEMPERATURE_CHAN(26, IIO_TEMP),
>  	/* sentinel */
>  };
>  
> @@ -451,6 +458,7 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:
> +	case IIO_CHAN_INFO_PROCESSED:
>  		mutex_lock(&indio_dev->mlock);
>  		reinit_completion(&info->completion);
>  
> @@ -468,7 +476,23 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
>  			return ret;
>  		}
>  
> -		*val = info->value;
> +		switch (chan->type) {
> +		case IIO_VOLTAGE:
> +			*val = info->value;
> +			break;
> +		case IIO_TEMP:
> +			/*
> +			* Calculate in degree Celsius times 1000
> +			* Using sensor slope of 1.84 mV/°C and
> +			* V at 25°C of 696 mV
> +			*/
> +			*val = 25000 - ((int)info->value - 864) * 1000000 / 1840;
> +			break;
> +		default:
> +			mutex_unlock(&indio_dev->mlock);
> +			return -EINVAL;
> +		}
> +
>  		mutex_unlock(&indio_dev->mlock);
>  		return IIO_VAL_INT;
>  
> 

      reply	other threads:[~2014-09-21 12:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19 12:58 [PATCH v3] drivers/iio/adc/vf610-adc: Add temperature sensor support Sanchayan Maity
2014-09-19 12:58 ` Sanchayan Maity
2014-09-21 12:27   ` Jonathan Cameron [this message]

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=541EC414.5050505@kernel.org \
    --to=jic23@kernel.org \
    --cc=B38611@freescale.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maitysanchayan@gmail.com \
    --cc=shawn.guo@freescale.com \
    --cc=stefan@agner.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).