linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kim, Milo" <Milo.Kim@ti.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v5] iio: adc: add new lp8788 adc driver
Date: Fri, 14 Sep 2012 00:33:27 +0000	[thread overview]
Message-ID: <A874F61F95741C4A9BA573A70FE3998F41EF4BFC@DQHE02.ent.ti.com> (raw)
In-Reply-To: <504DADE1.6010303@metafoo.de>

> Hi,
> 
> One issue and a couple of nitpicks inline.

I really appreciate it.
Please see my questions below.

> > +	switch (mask) {
> > +	case IIO_CHAN_INFO_RAW:
> > +		ret = lp8788_get_adc_result(adc, id, val) ? -EIO :
> IIO_VAL_INT;
> > +		break;
> > +	case IIO_CHAN_INFO_SCALE:
> > +		*val = (lp8788_scale[id] / 1000) * 1000;
> > +		*val2 = (lp8788_scale[id] % 1000) * 1000000;
> 
> This looks suspicious. E.g. if the entry in your table has the value
> "1234"
> you'd end up with a scale factor of 1000.234000000. Which looks wrong
> for
> two reasons, given that you return INT_PLUS_MICRO val2 should never
> exceed 6
> decimal digits and secondly val is multiplied by a factor of thousand.
> 
> Can you tell us in what unit the values in lp8788_scale are, that would
> make
> review easier.

The LP8788 has 13 ADC input selection.

ADC selection:
Battery voltage, general ADC1 and so on.

ADC result:
Result = MAX_VALUE * (raw + 0.5) / 4095  except ADC is the charger voltage
If the ADC input is the charger voltage,
Result = MAX_VALUE * (raw + 0.5) / (4095 * 0.48)

The raw value is from the registers.
It has the range between 0 to 4095. (12bits)

MAX_VALUE is constant for each selection.
For the battery voltage, there are three ADC inputs. 5.0/5.5/6.0V
Battery voltage for Max 5.0V = 5.0
Battery voltage for Max 5.5V = 5.5
Battery voltage for Max 6.0V = 6.0
Charger = 6.0
ADC1 = 2.5 

I'm afraid I still misunderstand how IIO ADC works.
Could you me some guide how to setup the scale in the driver?

Thank you.

Best Regards,
Milo

  reply	other threads:[~2012-09-14  0:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10  8:02 [PATCH v5] iio: adc: add new lp8788 adc driver Kim, Milo
2012-09-10  9:07 ` Lars-Peter Clausen
2012-09-14  0:33   ` Kim, Milo [this message]
2012-09-14  8:35     ` Lars-Peter Clausen
2012-09-15  0:15       ` Kim, Milo
2012-09-15  9:05         ` Jonathan Cameron
2012-09-13 12:23 ` Jonathan Cameron
2012-09-14  0:33   ` Kim, Milo

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=A874F61F95741C4A9BA573A70FE3998F41EF4BFC@DQHE02.ent.ti.com \
    --to=milo.kim@ti.com \
    --cc=jic23@cam.ac.uk \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).