lime2: mainline kernel support for battery charging

Started by sermore, June 18, 2017, 04:34:18 PM

Previous topic - Next topic

sermore

Hi,

I'm trying to make the battery charging works for the lime2's mainline kernel.
It seems that it is not enabled by default.

Power supply from battery is working, tested detaching the AC line and the system is still alive.
No information about the attached battery seems to be collected, and the battery seems not charging.
Please note that the "connected" item is always 1, no matter if battery is attached or not.

/sys/power/axp_pmu/battery/
amperage 0
capacity 0
charge 0
charging 0
connected 1
power 0
ts_voltage 3276000
voltage 9900


Here the kernel version

uname -a
Linux lime2 4.11.5-sunxi #3 SMP Thu Jun 15 02:11:01 CEST 2017 armv7l GNU/Linux


Here the kernel's log


dmesg | grep axp
[    5.110645] axp20x-i2c 0-0034: AXP20x variant AXP209 found
[    5.134514] axp20x-gpio axp20x-gpio: AXP209 GPIO driver loaded
[    5.158853] input: axp20x-pek as /devices/platform/soc@01c00000/1c2ac00.i2c/i2c-0/0-0034/axp20x-pek/input/input0
[    5.201986] axp20x-i2c 0-0034: Backup (RTC) battery charging is disabled
[    5.219403] axp20x-i2c 0-0034: AXP20X driver loaded


Thanks

igorpec

Armbian has support for AXP PMU in mainline kernel for more than one year, but it's still considered WIP so I am not sure that everything is working as it should. Worth trying.

https://www.armbian.com/olimex-lime-2/

This is patch: https://github.com/armbian/build/blob/master/patch/kernel/sunxi-next/axp20x-sysfs-interface.patch

A side note: current 4.11.5 build has some stability troubles which we are still working on it. Most likely the problem is in u-boot. https://forum.armbian.com/index.php?/topic/4523-olimex-lime-2/

linux for ARM development boards
www.armbian.com

sermore

Hi,

Thanks for the quick reply.

Forgive my noobness, could you please advise on the below:

  • is the mainline kernel coming from Armbian APT different from the one indicated by you?
  • is the kernel indicated by you already containing the mentioned patch?

Thanks also for the tip regarding the identified instability.

igorpec

Quote from: sermore on June 19, 2017, 12:59:34 PM
Hi,

Thanks for the quick reply.

Forgive my noobness, could you please advise on the below:

  • is the mainline kernel coming from Armbian APT different from the one indicated by you?
  • is the kernel indicated by you already containing the mentioned patch?

Thanks also for the tip regarding the identified instability.


No, it's the same - kernel placed in repository contain all those patches, yes.

We have separate package for device tree blobs and there are boot scripts with overlay handling support. Another cool feature you might want to make use of. That's why I point you to the image download. It's not just kernel .. and u-boot.

Check this page for more info: https://www.armbian.com/kernel/

You need those packages at minimum: linux-image-next-sunxi linux-dtb-next-sunxi
linux for ARM development boards
www.armbian.com

igorpec

_     _                  ____ 
| |   (_)_ __ ___   ___  |___ \
| |   | | '_ ` _ \ / _ \   __) |
| |___| | | | | | |  __/  / __/
|_____|_|_| |_| |_|\___| |_____|
                               

Welcome to ARMBIAN 5.31 stable Ubuntu 16.04.2 LTS 4.11.5-sunxi   
System load:   0.26 0.30 0.13   Up time:       2 min
Memory usage:  3 % of 1001MB    IP:            xxxxxxxxxxx
CPU temp:      38°C           
Usage of /:    2% of 117G       Battery:       19% charging 

[ General system configuration: armbian-config ]
Last login: Tue Jun 20 08:57:33 2017



ls -l /sys/power/axp_pmu/battery/
total 0
-r--r--r-- 1 root root 4096 Jun 20 09:01 amperage
-r--r--r-- 1 root root 4096 Jun 20 08:57 capacity
-r--r--r-- 1 root root 4096 Jun 20 09:01 charge
-r--r--r-- 1 root root 4096 Jun 20 09:01 charging
-r--r--r-- 1 root root 4096 Jun 20 08:57 connected
-r--r--r-- 1 root root 4096 Jun 20 09:01 power
-r--r--r-- 1 root root 4096 Jun 20 09:01 ts_voltage
-r--r--r-- 1 root root 4096 Jun 20 09:01 voltage


cat /sys/power/axp_pmu/battery/voltage
3923700


Most of stuff works.
linux for ARM development boards
www.armbian.com

sermore

Hi Igor,

In my case the battery status is changed from the initial
ts_voltage 3276000
voltage 9900
to the below


/sys/power/axp_pmu/battery/ts_voltage 2433600
/sys/power/axp_pmu/battery/voltage 6600
/sys/power/axp_pmu/battery/charging 0
/sys/power/axp_pmu/battery/charge 0


Considering the voltage values, it seems that charging is not active.
The system is powered through the jack.
Maybe there is some configuration stuff to enable the charge feature?

igorpec

Hmm, not everything is working, but I have such readings at fully charged battery:

cat /sys/power/axp_pmu/battery/capacity
100
cat /sys/power/axp_pmu/battery/voltage
4154700


It also does not report that it's charging but charging is working for me.
cat /sys/power/axp_pmu/battery/charging
0
linux for ARM development boards
www.armbian.com

sermore

I've checked the battery state, and it is charged, therefore charging is working for me too.

I've Debian 8 instead of Ubuntu, maybe it could be the cause?

Welcome to ARMBIAN 5.31 stable Debian GNU/Linux 8 (jessie) 4.11.5-sunxi

Thanks,
Sergio