linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Tony Lindgren <tony@atomide.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, linux-omap@vger.kernel.org,
	Marcel Partap <mpartap@gmx.net>,
	Michael Scott <michael.scott@linaro.org>,
	Sebastian Reichel <sre@kernel.org>
Subject: Re: [PATCH 2/3] iio: adc: cpcap: Fix die temperature
Date: Wed, 24 May 2017 20:19:02 +0100	[thread overview]
Message-ID: <20170524201902.2cb31bcb@kernel.org> (raw)
In-Reply-To: <20170523005146.726-3-tony@atomide.com>

On Mon, 22 May 2017 17:51:45 -0700
Tony Lindgren <tony@atomide.com> wrote:

> It seems that "MC13783 Power Management and Audio Ciruit User's Guide"
> MC1378UG.pdf documents several similar components as in the CPCAP PMIC.
> 
> Chapter "9.5.5 Die Temperature and UID" says that the die temperature
> value is 282 at 25C with LSB of -1.14C. Converting CPCAP PMIC channel3
> values with following seems to produce values that make sense for a
> PMIC die:
> 
> temperature = 25000 + ((regval - 282) * 114)
> 
> As we don't have any other documentation, let's assume the die
> temperature is unconfigured in the Motorola mapphone Linux kernel
> and the current temperature conversion table should be only used
> for the battery thermistor and not for the die temperature.
> 
> Cc: Marcel Partap <mpartap@gmx.net>
> Cc: Michael Scott <michael.scott@linaro.org>
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
Applied to the togreg branch of iio.git which will shortly be
pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/cpcap-adc.c | 31 ++++++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c
> --- a/drivers/iio/adc/cpcap-adc.c
> +++ b/drivers/iio/adc/cpcap-adc.c
> @@ -875,6 +875,22 @@ static int cpcap_adc_init_request(struct cpcap_adc_request *req,
>  	return 0;
>  }
>  
> +static int cpcap_adc_read_st_die_temp(struct cpcap_adc *ddata,
> +				      int addr, int *val)
> +{
> +	int error;
> +
> +	error = regmap_read(ddata->reg, addr, val);
> +	if (error)
> +		return error;
> +
> +	*val -= 282;
> +	*val *= 114;
> +	*val += 25000;
> +
> +	return 0;
> +}
> +
>  static int cpcap_adc_read(struct iio_dev *indio_dev,
>  			  struct iio_chan_spec const *chan,
>  			  int *val, int *val2, long mask)
> @@ -906,9 +922,18 @@ static int cpcap_adc_read(struct iio_dev *indio_dev,
>  		error = cpcap_adc_start_bank(ddata, &req);
>  		if (error)
>  			goto err_unlock;
> -		error = cpcap_adc_read_bank_scaled(ddata, &req);
> -		if (error)
> -			goto err_unlock;
> +		if ((ddata->vendor == CPCAP_VENDOR_ST) &&
> +		    (chan->channel == CPCAP_ADC_AD3)) {
> +			error = cpcap_adc_read_st_die_temp(ddata,
> +							   chan->address,
> +							   &req.result);
> +			if (error)
> +				goto err_unlock;
> +		} else {
> +			error = cpcap_adc_read_bank_scaled(ddata, &req);
> +			if (error)
> +				goto err_unlock;
> +		}
>  		error = cpcap_adc_stop_bank(ddata);
>  		if (error)
>  			goto err_unlock;


  reply	other threads:[~2017-05-24 19:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23  0:51 [PATCHv2 0/3] Few non-critical cpcap ADC fixes Tony Lindgren
2017-05-23  0:51 ` [PATCH 1/3] iio: adc: cpcap: Fix default register values and battery temperature Tony Lindgren
2017-05-24 19:18   ` Jonathan Cameron
2017-06-07  6:22     ` Tony Lindgren
2017-06-11 14:12       ` Jonathan Cameron
2017-05-23  0:51 ` [PATCH 2/3] iio: adc: cpcap: Fix die temperature Tony Lindgren
2017-05-24 19:19   ` Jonathan Cameron [this message]
2017-05-23  0:51 ` [PATCH 3/3] iio: adc: cpcap: Remove hung interrupt quirk Tony Lindgren
2017-05-24 19:24   ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2017-05-19  3:40 [PATCH 0/3] Few non-critical cpcap ADC fixes Tony Lindgren
2017-05-19  3:40 ` [PATCH 2/3] iio: adc: cpcap: Fix die temperature Tony Lindgren
2017-05-20 15:55   ` Jonathan Cameron
2017-05-20 16:35     ` Tony Lindgren
2017-05-20 16:39       ` 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=20170524201902.2cb31bcb@kernel.org \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=michael.scott@linaro.org \
    --cc=mpartap@gmx.net \
    --cc=pmeerw@pmeerw.net \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /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).