Letux Kernel

Issue 476: readings from twl4030_madc_battery driver are wrong

Reported by Nikolaus Schaller, Aug 12, 2013

I had only applied your patches but not yet tested the driver.
It appears that it does not work completely on the 3.11 kernel and
always reports an empty battery.

I get e.g. these readings:

root@gta04:~# cat /sys/class/power_supply/twl4030_battery/uevent 
POWER_SUPPLY_NAME=twl4030_battery
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_NOW=717000
POWER_SUPPLY_CURRENT_NOW=795000
POWER_SUPPLY_CAPACITY=0
POWER_SUPPLY_CHARGE_FULL=1200000
POWER_SUPPLY_CHARGE_NOW=0
POWER_SUPPLY_TEMP=670
POWER_SUPPLY_TIME_TO_EMPTY_NOW=10800
root@gta04:~# 

voltage/current/temp appear to be broken.

But reading the hwmon directly works perfectly:

root@gta04:~# cat /sys/devices/platform/twl4030_madc_hwmon/*_input
481	<- current
0
0
4199	<- vbatt
3
12
12
7
12
14
14
4940	<- vbus
3219	<- vbackup
26	<- temp
root@gta04:~# 

So I think there is something (now) missing with the madc 
initialization.

On the 3.7 kernel it did work.

Comment 1 by Nikolaus Schaller, Aug 12, 2013

Lukas commented in private communication:

I would assume something changed in madc_read(). Compare the drivers 
madc_read with madc_read from drivers/hwmon/twl4030-madc-hwmon.c, 
there are some slight differences (.func_cb VS .type).

Comment 2 by Lukas M, Aug 18, 2013

madc_read was indeed the culprit.

It is now fixed and working again on my 3.11-rc5:

root@gta04:~# cat /sys/class/power_supply/bq27000-battery/uevent 
POWER_SUPPLY_NAME=bq27000-battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_VOLTAGE_NOW=3905000
POWER_SUPPLY_CURRENT_NOW=-136731
POWER_SUPPLY_CAPACITY=45
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_TEMP=271
POWER_SUPPLY_TIME_TO_FULL_NOW=18360
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CHARGE_FULL=844305
POWER_SUPPLY_CHARGE_NOW=378063
POWER_SUPPLY_CHARGE_FULL_DESIGN=1233792
POWER_SUPPLY_CYCLE_COUNT=358
POWER_SUPPLY_ENERGY_NOW=1251220
POWER_SUPPLY_POWER_AVG=0
POWER_SUPPLY_HEALTH=Good

root@gta04:~# cat /sys/class/power_supply/twl4030_battery/uevent 
POWER_SUPPLY_NAME=twl4030_battery
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_NOW=3900000
POWER_SUPPLY_CURRENT_NOW=720000
POWER_SUPPLY_CAPACITY=25
POWER_SUPPLY_CHARGE_FULL=1200000
POWER_SUPPLY_CHARGE_NOW=324000
POWER_SUPPLY_TEMP=250
POWER_SUPPLY_TIME_TO_EMPTY_NOW=2700

The patch can be pulled from here (and is attached):
  https://github.com/slyon/linux/tree/gta04-3.11-twl4030_battery

Comment 3 by Lukas M, Aug 18, 2013

Here comes the patch.

PS: Attachments are being lost, if Indefero's preview function is 
being used.

Comment 4 by Lukas M, Aug 18, 2013

Now for real :)

Comment 5 by Nikolaus Schaller, Aug 28, 2013

Appears to work now :)
Status: Fixed

Comment 6 by Grace Bradley, Aug 10, 2019

Batery driver were wrong they are not showing us any of the 
important message. That message is not important because we just not 
have any of the https://www.topreviewstars.com/ value this time. I 
know this time we will be taking interest in all of these important 
messages all the time.

Created: 6 years 2 months ago by Nikolaus Schaller

Updated: 2 months 10 days ago

Status: Fixed

Followed by: 2 persons

Labels:
Type:Defect
Priority:Medium