[Letux-kernel] Kobolino: rc5t619 adc

H. Nikolaus Schaller hns at goldelico.com
Sat Dec 21 16:25:50 CET 2019

> Am 21.12.2019 um 15:15 schrieb Andreas Kemnade <andreas at kemnade.info>:
> On Sat, 21 Dec 2019 13:31:08 +0100
> "H. Nikolaus Schaller" <hns at goldelico.com> wrote:
>>> Am 21.12.2019 um 09:32 schrieb Andreas Kemnade <andreas at kemnade.info>:
>>> On Sat, 21 Dec 2019 09:05:49 +0100
>>> "H. Nikolaus Schaller" <hns at goldelico.com> wrote:
>>>> Hi,
>>>>> Am 20.12.2019 um 21:15 schrieb Andreas Kemnade <andreas at kemnade.info>:
>>>>> Hi,
>>>>> in the branch
>>>>> letux/kobolino/rtc-v5    
>>>> Fine. I have prepared to merge it into letux-5.5-rc3.
>>> don't forget the additional CONFIG  
>> Ok, is working!
>> Only the scaling seems to be wrong. AFAIR, the in*_input are scaled
>> as mV and not µV as other interfaces. I think there was some document
>> in Documentation/ but I couldn't locate it quickly.
> well, there is no *1000 in the generic_adc_battery driver,
> so if gab is right, iio must deliver uV. Or the other way round,
> if iio has to deliver mV, then gab is wrong.
> Or am I missing something?

Well, I would more assume that gab is wrong...

If I read twl4030 or Palmas iio channels I obviously get mV:

root at letux:~# ./findiio palmas-gpadc
root at letux:~# cat /sys/bus/iio/devices/iio:device2/in_*_input
root at letux:~#

Or these are badly defined?

Well, /sys/class/power_supply gives µV and µA but they do not need to be the same definitions as iio.

And here is a hint:


	scale to be applied to in0_raw in order to obtain the measured voltage in millivolts.
	This specifies any shell prompt running on the target
	root:/sys/devices/platform/bfin-spi.0/spi0.3/iio:device0> cat in_voltage_scale

So this means the scale must scale the _raw to mV. And _input is just the value after applying scale and offset. This is then also mV.

Here is another doc:


It seems as if this is NOT well documented and taken for granted by everyone...
> But more interesting is the scaling of in_current.

Well, for me correct voltage readings are initially more important
since user-space (/root/charger script) may rely on a certain unit
of values.

But scaling in_current is also important.

Most likely it is a shunt resistor measuring the
current from the USB power supply to the battery charger.
And contrary to the twl4030 not the current going into
or coming from battery. I.e. the twl4030 can measure
positive and negative current. AFAIR, there are also
two separate ADC wires and channels reserved.

Without schematics and knowing the exact resistor value
it is very difficult to calibrate it.


More information about the Letux-kernel mailing list