[Letux-kernel] generic-adc-battery

H. Nikolaus Schaller hns at goldelico.com
Sat Feb 6 18:16:39 CET 2016


Hi Marek,

Am 05.02.2016 um 23:02 schrieb Belisko Marek <marek at goldelico.com>:

> Hi,
> 
> I did look about converting generic-adc-battery to DT and reuse it
> also for our twl4030_madc driver.

Great!

> What I understand is that this
> driver accept in platform_data -> which must be converted to DT,
> battery name, type and other parameters.

Yes. That also was my cursory impression.

> Some properties which we have
> in twl4030_madc are missing in generic like temperature, chargenow but
> instead there are other which aren't used in twl4030_madc (min_design,
> max_design ..).

Hm. Do we have temperature? Maybe because our twl-madc can provide.

> I did check usage and found that it's used only 2
> times for LIPO batteries. Basically conversion is doable but I'm not
> sure how community will respond to our enhancements (conversion to DT
> should be OK). So question is if we should invest time to this rework?
> Formula was valid only for LioN batteries, not sure if something else
> exists for LIPO batteries type. Suggestions? Thanks.

I think we should "sell" our enhacements as:
a) if iio provides temperature, we report (if not there is no property)
b) if iio provides current measurement, we report (if not there is no property)
c) since there is no platform-data for the voltage -> % function, we provide a simple
default function based on the formula. If this is not good enough for a platform,
a different one can be supplied by platform-data.

And I think for Pavel's calibration we can simply define a "series-resistance"
property which is used if the iio reports the current. It is effectively ignored if not.

The formula was:

>>  def percent(m, v):
>>   	u = 0.0387-(1.4523*(3.7835-v))
>>       if u < 0:
>>           return 0

next line sounds a little strange because it will retur 19.66% minimum !?!

>>         return (0.1966+math.sqrt(u))*100


I think we should find the slide show Pavel did mention during discussion.
That was a presentation by some LiIon/LiPo specialist.

Ah, and I think that Texas Instruments has some fuel gauges which are *not*
coulomb counters like the bq27000 but just apply a formula like the one above.
But they also measure the series resistance by injecting some 1kHz signal.


Anyways, I would simply add two properties:

* series-resistance-mOhm: <300>
* charge-current-offset-mA: <400>

int percent(int mV, int mA) {
	s32 u;
	mV = mV - 1000*series-resistance-mOhm * mA);
  	u = 387 - (14523 * (37835 - 10 * mV));
	if (u < 0)
		u = 0;
	return = (1966+sqrt(u))/100; // adjust factors for correct fixed point scaling...
}

And apply the charge-current-offset-mA when reporting (and using) charging current.
If there is no charge current iio channel, offset is not applied and 0 passed for the mA
parameter.

And I think by injecting different frequencies they can even measure temperature.
This is patented an impossible to do by twl4030-madc but shows the principle.

In total I think we have better chances to get anything upstream if we extend
the generic-adc-battery for DT and madc instead of continuing to work on and
resubmit our twl4030-madc-battery.

BR,
Nikolaus



More information about the Letux-kernel mailing list