[Letux-kernel] Kobolino: rc5t619 adc
Andreas Kemnade
andreas at kemnade.info
Sat Dec 21 17:08:39 CET 2019
On Sat, 21 Dec 2019 16:25:50 +0100
"H. Nikolaus Schaller" <hns at goldelico.com> wrote:
> > 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
> /sys/bus/iio/devices/iio:device2
> root at letux:~# cat /sys/bus/iio/devices/iio:device2/in_*_input
> 710
> 4602
> 0
> 2840
> 0
> 783
> 0
> 0
> 3960
> 4162
> 2476
> 5001
> 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:
>
> https://wiki.analog.com/resources/tools-software/linux-drivers/iio-adc/ad7887
>
> 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:
>
> https://wiki.st.com/stm32mpu/index.php/How_to_use_the_IIO_user_space_interface#How_to_do_a_simple_conversion_using_the_sysfs_interface
>
> It seems as if this is NOT well documented and taken for granted by everyone...
>
so probably better to use mV then. I will add a patch.
> > 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.
>
well interesting != important. µV vs. mV is just a decision.
> 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.
>
The rc5t619 uses two shunts, one attached to the adc and
charger control and one attached to the fuel gauge and charger
control.
> Without schematics and knowing the exact resistor value
> it is very difficult to calibrate it.
>
resistor is 20mOhm, as specified by the data sheet. I found two of those
near the pmic.
Regards,
Andreas
More information about the Letux-kernel
mailing list