Re: [PATCH v2] hwmon: (ntc_thermistor): try reading processed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 26, 2020 at 2:45 AM Chris Lesiak <chris.lesiak@xxxxxxxxx> wrote:

> I haven't been able to find detailed documentation on the ab8500-gpadc,
> so I have a couple of questions / comments:

The documentation is available here:
https://web.archive.org/web/20130614115108/http://www.stericsson.com/developers/CD00291561_UM1031_AB8500_user_manual-rev5_CTDS_public.pdf

As it is in the wayback machine I put a copy here:
https://dflund.se/~triad/krad/CD00291561_UM1031_AB8500_user_manual-rev5_CTDS_public.pdf

As with many mixsig products the ADC isn't very well documented.
The code is the documentation...

> 1. The driver appears to support temperature output directly.  Why do
> you need ntc_thermistor?

Actually these channels (if you mean AB8500_GPADC_CHAN_BAT_TEMP,
AB8505_GPADC_CHAN_DIE_TEMP, AB8500_GPADC_CHAN_XTAL_TEMP)
are just voltages and they need to be processed because they are
some kind of thermistors and not temperatures at all, these are
voltages. It's just that the channels are named like this.

However in this case (the current patch), the two channels used for the
thermistors are
AB8500_GPADC_CHAN_ADC_AUX_1
AB8500_GPADC_CHAN_ADC_AUX_2
which are just common arbitrary voltage ADCs, not related to
the above, so it doesn't really apply anyways.

> 2. I don't understand how the ab8500_gpadc_read_raw output of processed
> data could possibly be correct.
>
>         if (mask == IIO_CHAN_INFO_PROCESSED) {
>                 processed = ab8500_gpadc_ad_to_voltage(gpadc, ch->id, raw_val);
>                 if (processed < 0)
>                         return processed;
>
>                 /* Return millivolt or milliamps or millicentigrades */
>                 *val = processed * 1000;
>                 return IIO_VAL_INT;
>         }
>
> Note that both processed and *val are both of type int.
>
> If *val really does end up with milliVolt units, then processed must
> have had Volt units.  And you only have single Volt resolution.

Sorry there is a bug there and I sent a patch the other day:
https://lore.kernel.org/linux-iio/20201224011700.1059659-1-linus.walleij@xxxxxxxxxx/T/#u

"processed" contains millivolts, the * 1000 is a bug. This is why
reading the processed channel without multiplying with 1000
was working for me before, then I discovered that the contract
of the API is to pass millivolts and then I fixed this bug.

Sorry about the confusion :/

> Either you are working with a lot higher voltages than I usually see,
> or something must be wrong.

Yeah something was wrong. Fixed with the patch.

But do you agree with the general stance that we should
give precedence to using iio_read_channel_processed()
and multiply the result with 1000? It should work with
any driver I think.

Yours,
Linus Walleij



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux