[HD2 Android SD Development] hastarin:
Extended battery update

I just thought I'd post an update on where I'm at with trying to get extended battery support in the new driver.

The good news

I've managed to get things to boot long enough to get some data.

The bad news

The package_id reading the driver is relying on is very similar between the original (150 & 168 seen) and extended batteries (144, 147 & 159 seen) and in fact the ranges I've observed so far overlap!

What's next...

I need to do more testing to see what range of ids I'm seeing from the original battery. The values will vary with temperature.

I need to figure out a better way to gather data from the extended battery. What I'm doing at the moment is resulting in a crash of Android that corrupts my setup and it takes too long to restore a backup of everything.

Worst case I can probably hack the driver so it uses something else to detect the difference but I would need to figure out something that will still work on NAND when we don't have WM setting some of the values on boot.

The temperature reading might work...

EDIT 1

I've confirmed package id and thermistor values are being read the right way around, and that package id has minimal variation with temperature. Amazing what a few minutes in a freezer and a hair dryer can do. :P

EDIT 2

Confirmed we can't use the value that's being read for the package id. It seems to be the wrong value and Markinus just lucked out with the new driver that it happened to match the correct battery.

I've linked Markinus to this thread and some of my older test data. He is looking in to things further and I'll see what "hacks" I can think of tomorrow.

If anyone reads this that knows enough to start experimenting themselves here is some of the data I've gathered:

01 - Status/Config = When this is read as 0x3 means the AIN0/AIN1 values are valid
08/09 - AIN0 = Temperature
0a/0b - AIN1 = Package Id (id_adc)
0c/0d - Voltage
0e/0f - Current
10/11 - ACR

Standard:
<4>[ 102.214416] [D:BATT] [x0]3 [x8]f 40 a 80 69 30 f4 86 10 e1
<4>[ 102.214416] [D:BATT] battery.id_adc pre clip: 168

Extended:
<4>[ 2.185028] [D:BATT] [x0]3 [x8]2 0 9 f0 65 40 ee aa 37 b1
<4>[ 2.185028] [D:BATT] battery.id_adc pre clip: 159

Standard battery:
<6>[ 102.212371] [ds2746_batt] ds2746_battery_work*
<4>[ 102.212585] [D:BATT][ds2746_i2c_read_u8] ds2746[0x1]=0x3.
<4>[ 102.212768] [D:BATT][ds2746_i2c_read_u8] ds2746[0x8]=0xf.
<4>[ 102.212951] [D:BATT][ds2746_i2c_read_u8] ds2746[0x9]=0x40.
<4>[ 102.213134] [D:BATT][ds2746_i2c_read_u8] ds2746[0xa]=0xa.
<4>[ 102.213317] [D:BATT][ds2746_i2c_read_u8] ds2746[0xb]=0x80.
<4>[ 102.213500] [D:BATT][ds2746_i2c_read_u8] ds2746[0xc]=0x69.
<4>[ 102.213653] [D:BATT][ds2746_i2c_read_u8] ds2746[0xd]=0x30.
<4>[ 102.213836] [D:BATT][ds2746_i2c_read_u8] ds2746[0xe]=0xf4.
<4>[ 102.214019] [D:BATT][ds2746_i2c_read_u8] ds2746[0xf]=0x86.
<4>[ 102.214202] [D:BATT][ds2746_i2c_read_u8] ds2746[0x10]=0x10.
<4>[ 102.214385] [D:BATT][ds2746_i2c_read_u8] ds2746[0x11]=0xe1.
<4>[ 102.214416] [D:BATT] [x0]3 [x8]f 40 a 80 69 30 f4 86 10 e1
<4>[ 102.214416] [D:BATT] battery.id_adc pre clip: 168
<4>[ 102.214447] [D:BATT] battery.id_ohm pre calibrate: 168
<4>[ 102.214447] [D:BATT] battery.id_ohm post calibrate: 668
<4>[ 102.214477] [D:BATT] batt_id: 4
<4>[ 102.214508] [D:BATT] kadc t: capacity=10000 voltage=4135
<4>[ 102.214508] [D:BATT] kadc t: capacity=7500 voltage=3960
<4>[ 102.214538] [D:BATT] kadc t: capacity=4700 voltage=3800
<4>[ 102.214538] [D:BATT] kadc t: capacity=1700 voltage=3727
<4>[ 102.214569] [D:BATT] kadc t: capacity=900 voltage=3674
<4>[ 102.214599] [D:BATT] kadc t: capacity=300 voltage=3640
<4>[ 102.214599] [D:BATT] kadc t: capacity=0 voltage=3420
<4>[ 102.214630] [D:BATT] pd_m=87, pd_temp=0
<4>[ 102.214630] [D:BATT] V=4106(693) I=-290(fffffd22) C=1209.0/1230(10e1) id=4(a8) T=310(f4) KADC=1000
<6>[ 102.214660] ds2746_batt:__update_capacity start
<6>[ 102.214691] ds2746_blocking_notify
<6>[ 102.214721] batt: charging OFF
<4>[ 102.214721] [D:BATT][2] P=983 cable=00 flags=110 debug=0000 fst_discharge=990/1217 [1120585059]

Extended battery:
<4>[ 2.183959] [D:BATT][ds2746_i2c_read_u8] ds2746[0xb]=0xf0.
<4>[ 2.184143] [D:BATT][ds2746_i2c_read_u8] ds2746[0xc]=0x65.
<4>[ 2.184326] [D:BATT][ds2746_i2c_read_u8] ds2746[0xd]=0x40.
<4>[ 2.184478] [D:BATT][ds2746_i2c_read_u8] ds2746[0xe]=0xee.
<4>[ 2.184661] [D:BATT][ds2746_i2c_read_u8] ds2746[0xf]=0xaa.
<4>[ 2.184814] [D:BATT][ds2746_i2c_read_u8] ds2746[0x10]=0x37.
<4>[ 2.184997] [D:BATT][ds2746_i2c_read_u8] ds2746[0x11]=0xb1.
<4>[ 2.185028] [D:BATT] [x0]3 [x8]2 0 9 f0 65 40 ee aa 37 b1
<4>[ 2.185028] [D:BATT] battery.id_adc pre clip: 159
<4>[ 2.185058] [D:BATT] battery.id_ohm pre calibrate: 159
<4>[ 2.185058] [D:BATT] battery.id_ohm post calibrate: 659
<4>[ 2.185089] [D:BATT] batt_id: 4
<4>[ 2.185119] [D:BATT] kadc t: capacity=10000 voltage=4135
<4>[ 2.185119] [D:BATT] kadc t: capacity=7500 voltage=3960
<4>[ 2.185150] [D:BATT] kadc t: capacity=4700 voltage=3800
<4>[ 2.185150] [D:BATT] kadc t: capacity=1700 voltage=3727
<4>[ 2.185180] [D:BATT] kadc t: capacity=900 voltage=3674
<4>[ 2.185211] [D:BATT] kadc t: capacity=300 voltage=3640
<4>[ 2.185211] [D:BATT] kadc t: capacity=0 voltage=3420
<4>[ 2.185241] [D:BATT] pd_m=131, pd_temp=0
<4>[ 2.185241] [D:BATT] V=3952(654) I=-438(fffffbab) C=5139.0/1230(37b1) id=4(9f) T=700(20) KADC=926
<4>[ 2.185272] [D:BATT] acr update: P=1000, C=4373.
<4>[ 2.185394] [D:BATT][ds2746_i2c_write_u8] ds2746[0x10]<-0x11.
<4>[ 2.185516] [D:BATT][ds2746_i2c_write_u8] ds2746[0x11]<-0x15.
<4>[ 2.185546] [D:BATT]new RARC=1000 C=1230mAh adc=4373.
<4>[ 2.185577] [D:BATT] state change(0->2), full count=0, over load count=0 [2184]
<6>[ 2.185577] ds2746_batt:__update_capacity start
<6>[ 2.185607] ds2746_blocking_notify
<6>[ 2.185638] batt: ds2784_notify: 1 99 at 2184604539 (1970-01-01 00:00:02.184604539 UTC)
<6>[ 2.185668] batt: batt:power_supply_changed: battery at 2184665574 (1970-01-01 00:00:02.184635057 UTC
<6>[ 2.185699] ds2746_blocking_notify
<6>[ 2.185729] batt: charging OFF
<4>[ 2.185729] [D:BATT][2] P=990 cable=00 flags=100 debug=0000 fst_discharge=990/1230 [2184]
<4>[ 2.186065] regulator_init_complete: incomplete constraints, leaving ldo2 on
<4>[ 2.186248] regulator_init_complete: incomplete constraints, leaving ldo1 on
<4>[ 2.186462] regulator_init_complete: incomplete constraints, leaving dcdc3 on
<4>[ 2.186645] regulator_init_complete: incomplete constraints, leaving dcdc2 on
<4>[ 2.186859] regulator_init_complete: incomplete constraints, leaving dcdc1 on