Re: [lm-sensors] [PATCH V1] fix adc to voltage calculation inda9052 power driver

From: Jean Delvare
Date: Sat Dec 21 2013 - 12:32:13 EST


Hi Guenter, hi Anthony,

On Thu, 19 Dec 2013 10:10:49 -0800, Guenter Roeck wrote:
> On Thu, Dec 19, 2013 at 03:54:54PM +0100, Jean Delvare wrote:
> > BTW, you (and we) probably shouldn't waste too much energy on this.
> > ADCs are only accurate to some degree anyway. If you take the
> > components connected to the input into consideration, the accuracy gets
> > even worse. For example, if the input voltage must be scaled down to
> > fit in the ADC's range, you need at least one resistor, which in best
> > cases will have a 1% accurate value (known as tolerance.) That's ten
> > times the LSB of your 10-bit ADC, at which point / 1023 or / 1024
> > really makes no practical difference. Sub-percent tolerant resistors are
> > expensive and rare in consumer electronics in my experience.
>
> True, but on the other side (and after looking into the datasheet)
> the driver already calculated the voltage on adc4..6 correctly,
> so unless you disagree I would like to apply the hwmon patch to -next
> for consistency.

The datasheet isn't the best quality I've seen. The gain values
mentioned to not even match the formulas in the same cell... But I can't
object to implementing conversions the way the datasheet says, no
matter how suspicious.

I don't really know what tree the patch is based on. Anthony said
linux-next but I can't see ichg_reg_to_mA there.

If volt_reg_to_mv is updated then you certainly want to update
vbbat_reg_to_mv the same way, as it diverges from the datasheet just
the same.

Also, please update Documentation/hwmon/da9052 so that the
documentation matches the actual driver code.

I really would like to hear what David Dajun Chen has to say about
that. He must have had a reason to use different conversions formulas
than the datasheet specifies.

--
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/