AXP803 Battery Charger Support
#1
I am currently investigating how the battery charger in the PMIC (AXP803) is supported by the software. Being a hardware guy I was working my way up from the bottom side of things, starting with the physical connection and the PMIC:

The battery seems to be connected to the PMIC via a load sensing (current sensing) shunt and the PMIC has a switch that connects the battery to the inputs of the voltage
regulators once certain conditions are met. There is also an input on the battery connector to attach a 10k NTC for monitoring the battery temperature. The PMIC contains a battery charger that charges the battery depending on what DC power source is available (USB/DC IN).

From the AXP803 Datasheet:

- Vbat charge target voltage = 4.2V typical
- Charge current can be set between 200 and 2800mA, 1200mA typical
- Trickle charge current is 10% of normal charge current

- There are two safety timers which can be programmed to limit regular/trickle charging after x minutes (480 min / 50min typical)
- Charging stops in CV mode if the normal charge current drops below 10% of the set charge current
- The NTC monitor has different trip points like cold fault, hot fault for operation and charging which can be programmed in the PMIC
- Battery isolation current is 40uA


- Turning on the PMIC happens by either applying USB/DC_IN or pushing the power button
- Turning off the PMIC happens by undervoltage lockout, fault condition, power button or software writes to a register
- The charger starts working once the voltage input from USB/DC_IN is between 4.1V and 7V

- Input to the regulators is automatically selected from Battery, DC_IN or USB
- USB/DC_IN are preferred over Battery
- If USB and DC_IN are not connected together, DC_IN is preferred over USB
- If USB/DC_IN drops below certain thresholds, Battery takes over
- Input can be controlled by registers

- The function of the charge LED can be controlled via registers

- The PMIC is connected to the A64 via a I2C interface

I have looked at the device tree file and it seems to contain some default setting for the PMIC (and the charger):


Code:
[email protected] {
           compatible = "allwinner,pmu0";
           device_type = "pmu0";
           pmu_batdeten = <0x00000001>;
           pmu_init_chgend_rate = <0x00000014>;
           pmu_init_chg_enabled = <0x00000001>;
           pmu_init_adc_freq = <0x00000320>;
           pmu_init_adcts_freq = <0x00000320>;
           pmu_init_chg_pretime = <0x00000046>;
           pmu_init_chg_csttime = <0x000002d0>;
           pmu_batt_cap_correct = <0x00000001>;
           pmu_chg_end_on_en = <0x00000000>;
           pmu_pwroff_vol = <0x00000ce4>;
           pmu_pwron_vol = <0x00000a28>;
           pmu_powkey_off_delay_time = <0x00000000>;
           pmu_pwrok_time = <0x00000040>;
           pmu_reset_shutdown_en = <0x00000001>;
           pmu_restvol_adjust_time = <0x0000003c>;
           pmu_ocv_cou_adjust_time = <0x0000003c>;
           pmu_vbusen_func = <0x00000001>;
           pmu_reset = <0x00000000>;
           pmu_IRQ_wakeup = <0x00000001>;
           pmu_hot_shutdowm = <0x00000001>;
           pmu_inshort = <0x00000000>;
           pmu_bat_shutdown_ltf = <0x00000c80>;
           pmu_bat_shutdown_htf = <0x000000ed>;
           status = "okay";
           pmu_id = <0x00000006>;
           pmu_twi_addr = <0x00000034>;
           pmu_twi_id = <0x00000001>;
           pmu_irq_id = <0x00000040>;
           pmu_chg_ic_temp = <0x00000000>;
           pmu_battery_rdc = <0x00000058>;
           pmu_battery_cap = <0x000012c0>;
           pmu_runtime_chgcur = <0x000001c2>;
           pmu_suspend_chgcur = <0x000005dc>;
           pmu_shutdown_chgcur = <0x000005dc>;
           pmu_init_chgvol = <0x00001068>;
           pmu_ac_vol = <0x00000fa0>;
           pmu_ac_cur = <0x00000dac>;
           pmu_usbpc_vol = <0x00001130>;
           pmu_usbpc_cur = <0x000001f4>;
           pmu_battery_warning_level1 = <0x0000000f>;
           pmu_battery_warning_level2 = <0x00000000>;
           pmu_chgled_func = <0x00000000>;
           pmu_chgled_type = <0x00000000>;
           pmu_bat_para1 = <0x00000000>;
           pmu_bat_para2 = <0x00000000>;
           pmu_bat_para3 = <0x00000000>;
           pmu_bat_para4 = <0x00000000>;
           pmu_bat_para5 = <0x00000000>;
           pmu_bat_para6 = <0x00000000>;
           pmu_bat_para7 = <0x00000001>;
           pmu_bat_para8 = <0x00000001>;
           pmu_bat_para9 = <0x00000002>;
           pmu_bat_para10 = <0x00000003>;
           pmu_bat_para11 = <0x00000004>;
           pmu_bat_para12 = <0x0000000a>;
           pmu_bat_para13 = <0x00000011>;
           pmu_bat_para14 = <0x0000001a>;
           pmu_bat_para15 = <0x00000029>;
           pmu_bat_para16 = <0x0000002e>;
           pmu_bat_para17 = <0x00000033>;
           pmu_bat_para18 = <0x00000038>;
           pmu_bat_para19 = <0x0000003b>;
           pmu_bat_para20 = <0x00000041>;
           pmu_bat_para21 = <0x00000045>;
           pmu_bat_para22 = <0x0000004b>;
           pmu_bat_para23 = <0x0000004f>;
           pmu_bat_para24 = <0x00000053>;
           pmu_bat_para25 = <0x00000059>;
           pmu_bat_para26 = <0x0000005f>;
           pmu_bat_para27 = <0x00000062>;
           pmu_bat_para28 = <0x00000064>;
           pmu_bat_para29 = <0x00000064>;
           pmu_bat_para30 = <0x00000064>;
           pmu_bat_para31 = <0x00000064>;
           pmu_bat_para32 = <0x00000064>;
           pmu_bat_temp_enable = <0x00000001>;
           pmu_bat_charge_ltf = <0x000008d5>;
           pmu_bat_charge_htf = <0x00000184>;
           pmu_bat_temp_para1 = <0x00001d2a>;
           pmu_bat_temp_para2 = <0x00001180>;
           pmu_bat_temp_para3 = <0x00000dbe>;
           pmu_bat_temp_para4 = <0x00000ae2>;
           pmu_bat_temp_para5 = <0x000008af>;
           pmu_bat_temp_para6 = <0x000006fc>;
           pmu_bat_temp_para7 = <0x000005a8>;
           pmu_bat_temp_para8 = <0x000003c9>;
           pmu_bat_temp_para9 = <0x00000298>;
           pmu_bat_temp_para10 = <0x000001d2>;
           pmu_bat_temp_para11 = <0x00000189>;
           pmu_bat_temp_para12 = <0x0000014d>;
           pmu_bat_temp_para13 = <0x0000011b>;
           pmu_bat_temp_para14 = <0x000000f2>;
           pmu_bat_temp_para15 = <0x000000b3>;
           pmu_bat_temp_para16 = <0x00000086>;
           pmu_powkey_off_time = <0x00001770>;
           pmu_powkey_off_func = <0x00000000>;
           pmu_powkey_off_en = <0x00000001>;
           pmu_powkey_long_time = <0x000005dc>;
           pmu_powkey_on_time = <0x000003e8>;
           power_start = <0x00000000>;
};


There seems to be a driver for the PMIC in the Linux kernel (drivers/power/axp_power/) that interfaces with the PMIC and is used for register access, controlling the various output voltages (CPU frequency scaling etc...) and the battery charger operation. Some of  the information is also exported via sysfs and can be read from /sys/class/power_supply/ , /sys/class/regulator and other places.

My question is now, what would be the correct way to handle battery charging, what would be a good way to set the charger defaults and are there any userspace tools available already that can use the subsystems for monitoring etc... ?
Come have a chat in the Pine A64 IRC channel >>
  Reply
#2
(06-18-2016, 03:28 AM)xalius Wrote: I am currently investigating how the battery charger in the PMIC (AXP803) is supported by the software. Being a hardware guy I was working my way up from the bottom side of things, starting with the physical connection and the PMIC:

The battery seems to be connected to the PMIC via a load sensing (current sensing) shunt and the PMIC has a switch that connects the battery to the inputs of the voltage
regulators once certain conditions are met. There is also an input on the battery connector to attach a 10k NTC for monitoring the battery temperature. The PMIC contains a battery charger that charges the battery depending on what DC power source is available (USB/DC IN).

From the AXP803 Datasheet:

- Vbat charge target voltage = 4.2V typical
- Charge current can be set between 200 and 2800mA, 1200mA typical
- Trickle charge current is 10% of normal charge current

- There are two safety timers which can be programmed to limit regular/trickle charging after x minutes (480 min / 50min typical)
- Charging stops in CV mode if the normal charge current drops below 10% of the set charge current
- The NTC monitor has different trip points like cold fault, hot fault for operation and charging which can be programmed in the PMIC
- Battery isolation current is 40uA


- Turning on the PMIC happens by either applying USB/DC_IN or pushing the power button
- Turning off the PMIC happens by undervoltage lockout, fault condition, power button or software writes to a register
- The charger starts working once the voltage input from USB/DC_IN is between 4.1V and 7V

- Input to the regulators is automatically selected from Battery, DC_IN or USB
- USB/DC_IN are preferred over Battery
- If USB and DC_IN are not connected together, DC_IN is preferred over USB
- If USB/DC_IN drops below certain thresholds, Battery takes over
- Input can be controlled by registers

- The function of the charge LED can be controlled via registers

- The PMIC is connected to the A64 via a I2C interface

I have looked at the device tree file and it seems to contain some default setting for the PMIC (and the charger):


Code:
[email protected] {
           compatible = "allwinner,pmu0";
           device_type = "pmu0";
           pmu_batdeten = <0x00000001>;
           pmu_init_chgend_rate = <0x00000014>;
           pmu_init_chg_enabled = <0x00000001>;
           pmu_init_adc_freq = <0x00000320>;
           pmu_init_adcts_freq = <0x00000320>;
           pmu_init_chg_pretime = <0x00000046>;
           pmu_init_chg_csttime = <0x000002d0>;
           pmu_batt_cap_correct = <0x00000001>;
           pmu_chg_end_on_en = <0x00000000>;
           pmu_pwroff_vol = <0x00000ce4>;
           pmu_pwron_vol = <0x00000a28>;
           pmu_powkey_off_delay_time = <0x00000000>;
           pmu_pwrok_time = <0x00000040>;
           pmu_reset_shutdown_en = <0x00000001>;
           pmu_restvol_adjust_time = <0x0000003c>;
           pmu_ocv_cou_adjust_time = <0x0000003c>;
           pmu_vbusen_func = <0x00000001>;
           pmu_reset = <0x00000000>;
           pmu_IRQ_wakeup = <0x00000001>;
           pmu_hot_shutdowm = <0x00000001>;
           pmu_inshort = <0x00000000>;
           pmu_bat_shutdown_ltf = <0x00000c80>;
           pmu_bat_shutdown_htf = <0x000000ed>;
           status = "okay";
           pmu_id = <0x00000006>;
           pmu_twi_addr = <0x00000034>;
           pmu_twi_id = <0x00000001>;
           pmu_irq_id = <0x00000040>;
           pmu_chg_ic_temp = <0x00000000>;
           pmu_battery_rdc = <0x00000058>;
           pmu_battery_cap = <0x000012c0>;
           pmu_runtime_chgcur = <0x000001c2>;
           pmu_suspend_chgcur = <0x000005dc>;
           pmu_shutdown_chgcur = <0x000005dc>;
           pmu_init_chgvol = <0x00001068>;
           pmu_ac_vol = <0x00000fa0>;
           pmu_ac_cur = <0x00000dac>;
           pmu_usbpc_vol = <0x00001130>;
           pmu_usbpc_cur = <0x000001f4>;
           pmu_battery_warning_level1 = <0x0000000f>;
           pmu_battery_warning_level2 = <0x00000000>;
           pmu_chgled_func = <0x00000000>;
           pmu_chgled_type = <0x00000000>;
           pmu_bat_para1 = <0x00000000>;
           pmu_bat_para2 = <0x00000000>;
           pmu_bat_para3 = <0x00000000>;
           pmu_bat_para4 = <0x00000000>;
           pmu_bat_para5 = <0x00000000>;
           pmu_bat_para6 = <0x00000000>;
           pmu_bat_para7 = <0x00000001>;
           pmu_bat_para8 = <0x00000001>;
           pmu_bat_para9 = <0x00000002>;
           pmu_bat_para10 = <0x00000003>;
           pmu_bat_para11 = <0x00000004>;
           pmu_bat_para12 = <0x0000000a>;
           pmu_bat_para13 = <0x00000011>;
           pmu_bat_para14 = <0x0000001a>;
           pmu_bat_para15 = <0x00000029>;
           pmu_bat_para16 = <0x0000002e>;
           pmu_bat_para17 = <0x00000033>;
           pmu_bat_para18 = <0x00000038>;
           pmu_bat_para19 = <0x0000003b>;
           pmu_bat_para20 = <0x00000041>;
           pmu_bat_para21 = <0x00000045>;
           pmu_bat_para22 = <0x0000004b>;
           pmu_bat_para23 = <0x0000004f>;
           pmu_bat_para24 = <0x00000053>;
           pmu_bat_para25 = <0x00000059>;
           pmu_bat_para26 = <0x0000005f>;
           pmu_bat_para27 = <0x00000062>;
           pmu_bat_para28 = <0x00000064>;
           pmu_bat_para29 = <0x00000064>;
           pmu_bat_para30 = <0x00000064>;
           pmu_bat_para31 = <0x00000064>;
           pmu_bat_para32 = <0x00000064>;
           pmu_bat_temp_enable = <0x00000001>;
           pmu_bat_charge_ltf = <0x000008d5>;
           pmu_bat_charge_htf = <0x00000184>;
           pmu_bat_temp_para1 = <0x00001d2a>;
           pmu_bat_temp_para2 = <0x00001180>;
           pmu_bat_temp_para3 = <0x00000dbe>;
           pmu_bat_temp_para4 = <0x00000ae2>;
           pmu_bat_temp_para5 = <0x000008af>;
           pmu_bat_temp_para6 = <0x000006fc>;
           pmu_bat_temp_para7 = <0x000005a8>;
           pmu_bat_temp_para8 = <0x000003c9>;
           pmu_bat_temp_para9 = <0x00000298>;
           pmu_bat_temp_para10 = <0x000001d2>;
           pmu_bat_temp_para11 = <0x00000189>;
           pmu_bat_temp_para12 = <0x0000014d>;
           pmu_bat_temp_para13 = <0x0000011b>;
           pmu_bat_temp_para14 = <0x000000f2>;
           pmu_bat_temp_para15 = <0x000000b3>;
           pmu_bat_temp_para16 = <0x00000086>;
           pmu_powkey_off_time = <0x00001770>;
           pmu_powkey_off_func = <0x00000000>;
           pmu_powkey_off_en = <0x00000001>;
           pmu_powkey_long_time = <0x000005dc>;
           pmu_powkey_on_time = <0x000003e8>;
           power_start = <0x00000000>;
};


There seems to be a driver for the PMIC in the Linux kernel (drivers/power/axp_power/) that interfaces with the PMIC and is used for register access, controlling the various output voltages (CPU frequency scaling etc...) and the battery charger operation. Some of  the information is also exported via sysfs and can be read from /sys/class/power_supply/ , /sys/class/regulator and other places.

My question is now, what would be the correct way to handle battery charging, what would be a good way to set the charger defaults and are there any userspace tools available already that can use the subsystems for monitoring etc... ?

Unless having very good knowledge on Lithium battery charging (I am not), I don't encourage backer to modify the parameter. However, if there is backer has such deep knowledge and interest to do so, that will be awesome. The current charging characteristic gearing toward tablet application which is this SoC original usage.
  Reply
#3
(06-18-2016, 04:16 PM)tllim Wrote:
(06-18-2016, 03:28 AM)xalius Wrote: I am currently investigating how the battery charger in the PMIC (AXP803) is supported by the software. Being a hardware guy I was working my way up from the bottom side of things, starting with the physical connection and the PMIC:

Unless having very good knowledge on Lithium battery charging (I am not), I don't encourage backer to modify the parameter. However, if there is backer has such deep knowledge and interest to do so, that will be awesome. The current charging characteristic gearing toward tablet application which is this SoC original usage.

I'm interested in knowing also. Another SoC board I have which has a AXP209 seems to be have much better access to the SoC, as you can easily access its registers over the i2c, thus allowing you to configure the battery maximums and minimums, as well as configure things like the current limit on the USB sockets, etc. 

And since the AXP is connected to an i2c bus, why does't it register with either of the below commands? Is it hiding somewhere else?

Code:
sudo i2cdetect -y 0
sudo i2cdetect -y 1

I get how you are concerned with people misconfiguring things and blowing up a battery, but that doesn't prevent the info from being put out there very clearly one what NOT to do, and what IS safe to do. I like how the other boards wiki tells you which settings are safe to touch, and how to change them, and cautions on the others. 

And as far as default charge profiles, /sys/class/power_supply/battery/technology is certainly wrong, as /sys/class/power_supply/battery/voltage_min_design and  /sys/class/power_supply/battery/voltage_max_design are clearly set for lipo batteries (which is what pretty much everyone would be using, so that is good!), as life batteries are designed to be charged to 3.6v, not the 4.2 volts that lipo batteries are!!!
  Reply
#4
(06-18-2016, 09:59 PM)pfeerick Wrote:
(06-18-2016, 04:16 PM)tllim Wrote:
(06-18-2016, 03:28 AM)xalius Wrote: I am currently investigating how the battery charger in the PMIC (AXP803) is supported by the software. Being a hardware guy I was working my way up from the bottom side of things, starting with the physical connection and the PMIC:

Unless having very good knowledge on Lithium battery charging (I am not), I don't encourage backer to modify the parameter. However, if there is backer has such deep knowledge and interest to do so, that will be awesome. The current charging characteristic gearing toward tablet application which is this SoC original usage.

I'm interested in knowing also. Another SoC board I have which has a AXP209 seems to be have much better access to the SoC, as you can easily access its registers over the i2c, thus allowing you to configure the battery maximums and minimums, as well as configure things like the current limit on the USB sockets, etc. 

And since the AXP is connected to an i2c bus, why does't it register with either of the below commands? Is it hiding somewhere else?

Code:
sudo i2cdetect -y 0
sudo i2cdetect -y 1

I get how you are concerned with people misconfiguring things and blowing up a battery, but that doesn't prevent the info from being put out there very clearly one what NOT to do, and what IS safe to do. I like how the other boards wiki tells you which settings are safe to touch, and how to change them, and cautions on the others. 

And as far as default charge profiles, /sys/class/power_supply/battery/technology is certainly wrong, as /sys/class/power_supply/battery/voltage_min_design and  /sys/class/power_supply/battery/voltage_max_design are clearly set for lipo batteries (which is what pretty much everyone would be using, so that is good!), as life batteries are designed to be charged to 3.6v, not the 4.2 volts that lipo batteries are!!!

The AXP803 seems to support one other communications mode according to the datasheet which is proprietary to Allwinner. It uses the I2C pins but a different protocol. Maybe that is the reason it doesnt turn up on the I2C Bus scan or the particular I2C bus is not exposed to userspace, I haven't found out yet. The linux kernel driver fot he PMIC has all the function to set/get registers and control the battery charger as well as the programmable regulators and monitor the different voltages.

As far as the default definition from the dts for the battery goes, I am also pretty sure it does not fit the 8Ah battery sold via the Pine store? Maybe someone with the exact battery specs should have a look at this asap... especially people could also be connecting random other Lithium chemistry batteries to the port, a safe setting there should be the default... if a certain charge current limit is set, that means there has to be a certain minimum battery size connected to not exceed the battery's safe operating area...
Come have a chat in the Pine A64 IRC channel >>
  Reply
#5
(06-19-2016, 06:19 AM)xalius Wrote: The AXP803 seems to support one other communications mode according to the datasheet which is proprietary to Allwinner. It uses the I2C pins but a different protocol. Maybe that is the reason it doesnt turn up on the I2C Bus scan or the particular I2C bus is not exposed to userspace, I haven't found out yet. The linux kernel driver fot he PMIC has all the function to set/get registers and control the battery charger as well as the programmable regulators and monitor the different voltages.

As far as the default definition from the dts for the battery goes, I am also pretty sure it does not fit the 8Ah battery sold via the Pine store? Maybe someone with the exact battery specs should have a look at this asap... especially people could also be connecting random other Lithium chemistry batteries to the port, a safe setting there should be the default... if  a certain charge current limit is set, that means there has to be a certain minimum battery size connected to not exceed the battery's safe operating area...

Thanks for that xalius... looks like I'll need to go digging around in the datasheet now and see what is what.. :-O Are all the set/get bits under /sys/class/power_supply and  /sys/class/power_supply or do I need to know something else to go forraging around in the murky depths? Big Grin

Well, I'm pretty sure it isn't the "8000mAH 4.7V Lithium Polymer battery that plugs right into the PINE64 board. Compatible with A64 and A64+ " that is described on the Pine64 shop page - tllim might want to look into getting that fixed! Wink   He has said on another post that it is 3.7v type LiPo battery, with the middle connection on the three pin header there for a thermistor. Hence why I think the voltage settings are correct, but 'technology' is wrong :-O
  Reply
#6
I learned a lot more about the PMIC tonight talking to the linux-sunxi kernel developers. The A64 contains a companion Opencores RISC CPU that handles some part of the power-management. During boot this CPU core's code is loaded from a binary and the Linux driver interfaces with it. That means the Linux powermanagement driver does not talk to the PMIC directly, some low level functions, including the I2C interface are handled by that embedded CPU. I am currently figuring out where one can set the battery parameters and in which way they get passed down the layers to the PMIC.

Check for https://linux-sunxi.org/AR100 , https://linux-sunxi.org/Pine64#Boot_sequence
Come have a chat in the Pine A64 IRC channel >>
  Reply
#7
(06-19-2016, 07:22 PM)pfeerick Wrote:
(06-19-2016, 06:19 AM)xalius Wrote: The AXP803 seems to support one other communications mode according to the datasheet which is proprietary to Allwinner. It uses the I2C pins but a different protocol. Maybe that is the reason it doesnt turn up on the I2C Bus scan or the particular I2C bus is not exposed to userspace, I haven't found out yet. The linux kernel driver fot he PMIC has all the function to set/get registers and control the battery charger as well as the programmable regulators and monitor the different voltages.

As far as the default definition from the dts for the battery goes, I am also pretty sure it does not fit the 8Ah battery sold via the Pine store? Maybe someone with the exact battery specs should have a look at this asap... especially people could also be connecting random other Lithium chemistry batteries to the port, a safe setting there should be the default... if  a certain charge current limit is set, that means there has to be a certain minimum battery size connected to not exceed the battery's safe operating area...

Thanks for that xalius... looks like I'll need to go digging around in the datasheet now and see what is what.. :-O Are all the set/get bits under /sys/class/power_supply and  /sys/class/power_supply or do I need to know something else to go forraging around in the murky depths? Big Grin

Well, I'm pretty sure it isn't the "8000mAH 4.7V Lithium Polymer battery that plugs right into the PINE64 board. Compatible with A64 and A64+ " that is described on the Pine64 shop page - tllim might want to look into getting that fixed! Wink   He has said on another post that it is 3.7v type LiPo battery, with the middle connection on the three pin header there for a thermistor. Hence why I think the voltage settings are correct, but 'technology' is wrong :-O

Should be 3.7V, NOT 4.7v, I will inform sales folks. However, looks like they always make some careless mistakes Huh
  Reply
#8
So far I have found three places where battery parameters get defined:

In the devicetree (pine64.dts here from the current longsleep kernel):

Code:
[email protected] {
           compatible = "allwinner,pmu0";
           device_type = "pmu0";
           pmu_batdeten = <0x00000001>;
           pmu_init_chgend_rate = <0x00000014>;
           pmu_init_chg_enabled = <0x00000001>;
           pmu_init_adc_freq = <0x00000320>;
           pmu_init_adcts_freq = <0x00000320>;
           pmu_init_chg_pretime = <0x00000046>;
           pmu_init_chg_csttime = <0x000002d0>;
           pmu_batt_cap_correct = <0x00000001>;
           pmu_chg_end_on_en = <0x00000000>;
           pmu_pwroff_vol = <0x00000ce4>;
           pmu_pwron_vol = <0x00000a28>;
           pmu_powkey_off_delay_time = <0x00000000>;
           pmu_pwrok_time = <0x00000040>;
           pmu_reset_shutdown_en = <0x00000001>;
           pmu_restvol_adjust_time = <0x0000003c>;
           pmu_ocv_cou_adjust_time = <0x0000003c>;
           pmu_vbusen_func = <0x00000001>;
           pmu_reset = <0x00000000>;
           pmu_IRQ_wakeup = <0x00000001>;
           pmu_hot_shutdowm = <0x00000001>;
           pmu_inshort = <0x00000000>;
           pmu_bat_shutdown_ltf = <0x00000c80>;
           pmu_bat_shutdown_htf = <0x000000ed>;
           status = "okay";
           pmu_id = <0x00000006>;
           pmu_twi_addr = <0x00000034>;
           pmu_twi_id = <0x00000001>;
           pmu_irq_id = <0x00000040>;
           pmu_chg_ic_temp = <0x00000000>;
           pmu_battery_rdc = <0x00000058>;
           pmu_battery_cap = <0x000012c0>;
           pmu_runtime_chgcur = <0x000001c2>;
           pmu_suspend_chgcur = <0x000005dc>;
           pmu_shutdown_chgcur = <0x000005dc>;
           pmu_init_chgvol = <0x00001068>;
           pmu_ac_vol = <0x00000fa0>;
           pmu_ac_cur = <0x00000dac>;
           pmu_usbpc_vol = <0x00001130>;
           pmu_usbpc_cur = <0x000001f4>;
           pmu_battery_warning_level1 = <0x0000000f>;
           pmu_battery_warning_level2 = <0x00000000>;
           pmu_chgled_func = <0x00000000>;
           pmu_chgled_type = <0x00000000>;
           pmu_bat_para1 = <0x00000000>;
           pmu_bat_para2 = <0x00000000>;
           pmu_bat_para3 = <0x00000000>;
           pmu_bat_para4 = <0x00000000>;
           pmu_bat_para5 = <0x00000000>;
           pmu_bat_para6 = <0x00000000>;
           pmu_bat_para7 = <0x00000001>;
           pmu_bat_para8 = <0x00000001>;
           pmu_bat_para9 = <0x00000002>;
           pmu_bat_para10 = <0x00000003>;
           pmu_bat_para11 = <0x00000004>;
           pmu_bat_para12 = <0x0000000a>;
           pmu_bat_para13 = <0x00000011>;
           pmu_bat_para14 = <0x0000001a>;
           pmu_bat_para15 = <0x00000029>;
           pmu_bat_para16 = <0x0000002e>;
           pmu_bat_para17 = <0x00000033>;
           pmu_bat_para18 = <0x00000038>;
           pmu_bat_para19 = <0x0000003b>;
           pmu_bat_para20 = <0x00000041>;
           pmu_bat_para21 = <0x00000045>;
           pmu_bat_para22 = <0x0000004b>;
           pmu_bat_para23 = <0x0000004f>;
           pmu_bat_para24 = <0x00000053>;
           pmu_bat_para25 = <0x00000059>;
           pmu_bat_para26 = <0x0000005f>;
           pmu_bat_para27 = <0x00000062>;
           pmu_bat_para28 = <0x00000064>;
           pmu_bat_para29 = <0x00000064>;
           pmu_bat_para30 = <0x00000064>;
           pmu_bat_para31 = <0x00000064>;
           pmu_bat_para32 = <0x00000064>;
           pmu_bat_temp_enable = <0x00000001>;
           pmu_bat_charge_ltf = <0x000008d5>;
           pmu_bat_charge_htf = <0x00000184>;
           pmu_bat_temp_para1 = <0x00001d2a>;
           pmu_bat_temp_para2 = <0x00001180>;
           pmu_bat_temp_para3 = <0x00000dbe>;
           pmu_bat_temp_para4 = <0x00000ae2>;
           pmu_bat_temp_para5 = <0x000008af>;
           pmu_bat_temp_para6 = <0x000006fc>;
           pmu_bat_temp_para7 = <0x000005a8>;
           pmu_bat_temp_para8 = <0x000003c9>;
           pmu_bat_temp_para9 = <0x00000298>;
           pmu_bat_temp_para10 = <0x000001d2>;
           pmu_bat_temp_para11 = <0x00000189>;
           pmu_bat_temp_para12 = <0x0000014d>;
           pmu_bat_temp_para13 = <0x0000011b>;
           pmu_bat_temp_para14 = <0x000000f2>;
           pmu_bat_temp_para15 = <0x000000b3>;
           pmu_bat_temp_para16 = <0x00000086>;
           pmu_powkey_off_time = <0x00001770>;
           pmu_powkey_off_func = <0x00000000>;
           pmu_powkey_off_en = <0x00000001>;
           pmu_powkey_long_time = <0x000005dc>;
           pmu_powkey_on_time = <0x000003e8>;
           power_start = <0x00000000>;
       };
       [email protected] {
           compatible = "allwinner,pmu0_regu";
           regulator_count = <0x00000017>;
           status = "okay";
           device_type = "pmu0_regu";
           regulator1 = "axp81x_dcdc1 none vcc-nand vcc-emmc vcc-sdc vcc-usb-30 vcc-io vcc-pd";
           regulator2 = "axp81x_dcdc2 none vdd-cpua";
           regulator3 = "axp81x_dcdc3 none";
           regulator4 = "axp81x_dcdc4 none";
           regulator5 = "axp81x_dcdc5 none vcc-dram";
           regulator6 = "axp81x_dcdc6 none vdd-sys";
           regulator7 = "axp81x_dcdc7 none";
           regulator8 = "axp81x_rtc none";
           regulator9 = "axp81x_aldo1 none vdd-csi-led iovdd-csi vcc-pe";
           regulator10 = "axp81x_aldo2 none vcc-pl";
           regulator11 = "axp81x_aldo3 none vcc-avcc vcc-pll";
           regulator12 = "axp81x_dldo1 none vcc-hdmi-33";
           regulator13 = "axp81x_dldo2 none vcc-mipi";
           regulator14 = "axp81x_dldo3 none avdd-csi";
           regulator15 = "axp81x_dldo4 none vcc-deviceio";
           regulator16 = "axp81x_eldo1 none vcc-cpvdd vcc-wifi-io vcc-pc vcc-pg";
           regulator17 = "axp81x_eldo2 none vcc-lcd-0";
           regulator18 = "axp81x_eldo3 none dvdd-csi-18";
           regulator19 = "axp81x_fldo1 none vcc-hsic-12";
           regulator20 = "axp81x_fldo2 none vdd-cpus";
           regulator21 = "axp81x_gpio0ldo none vcc-ctp";
           regulator22 = "axp81x_gpio1ldo none";
           regulator23 = "axp81x_dc1sw none vcc-lvds vcc-dsi-33";
};

In the AXP driver in the linux kernel:  /drivers/power/axp_power/axp-cfg.h

Code:
...
#define INTCHGCUR        300000        //set initial charging current limite
#define SUSCHGCUR        1000000        //set suspend charging current limite
#define RESCHGCUR        INTCHGCUR    //set resume charging current limite
#define CLSCHGCUR        SUSCHGCUR    //set shutdown charging current limite
#define INTCHGVOL        4200000        //set initial charing target voltage
#define INTCHGENDRATE        10        //set initial charing end current rate
#define INTCHGENABLED        1        //set initial charing enabled
#define INTADCFREQ        25        //set initial adc frequency
#define INTADCFREQC        100        //set initial coulomb adc coufrequency
#define INTCHGPRETIME        50        //set initial pre-charging time
#define INTCHGCSTTIME        480        //set initial pre-charging time
#define BATMAXVOL        4200000        //set battery max design volatge
#define BATMINVOL            3500000            //set battery min design volatge
...



There is also in the AXP driver:  /drivers/power/axp_power/axp-board.c


Code:
...
static struct power_supply_info battery_data ={
    .name ="PTI PL336078",
    .technology = POWER_SUPPLY_TECHNOLOGY_LiFe,
    .voltage_max_design = 4200000,
    .voltage_min_design = 3500000,
    .use_for_apm = 1,
};


static struct axp_supply_init_data axp_sply_init_data = {
    .battery_info = &battery_data,
    .chgcur = 1500000,
    .chgvol = 4200000,
    .chgend = 10,
    .chgen = 1,
    .sample_time = 800,
    .chgpretime = 50,
    .chgcsttime = 720,
};
...

Those two structures are also what one gets from sysfs from userspace, so my money is on those entries to be the actual values used by the battery charger code in the driver, but I have to do more reading to verify that.

/sys/class/power_supply/battery/uevent:

Code:
[email protected]:/sys/class/power_supply/battery$ cat uevent
POWER_SUPPLY_NAME=battery
POWER_SUPPLY_MODEL_NAME=battery
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=0
POWER_SUPPLY_ONLINE=0
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_TECHNOLOGY=LiFe
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4200000
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=3300
POWER_SUPPLY_VOLTAGE_NOW=0
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=4800
POWER_SUPPLY_CAPACITY=100
POWER_SUPPLY_TEMP=300

I have a question for the real kernel hackers:

The devicetree has two entries, one for
Code:
...
[email protected] {
           compatible = "allwinner,pmu0";
...


and one for


Code:
...
 [email protected] {
           compatible = "allwinner,pmu0_regu";
...

I only find


Code:
drivers/power/axp_power/axp-mem-device.c:       { .compatible = "allwinner,pmu0_regu", },


referenced when I search through the sources, no reference for the entry with

Code:
 compatible = "allwinner,pmu0";

Does that mean that entry does not get read anywhere and so the battery definiton from the dts does not get used at all atm?


Attached Files
.pdf   A64-SOPine-0V02.pdf (Size: 56.07 KB / Downloads: 101)
Come have a chat in the Pine A64 IRC channel >>
  Reply
#9
Its used by U-Boot - see https://github.com/longsleep/u-boot-pine...ner%2Cpmu0
  Reply
#10
Hi,

did somebody found out how to control the axp803?

I like to discharge my battery with DC-IN connected to test it. My pine is driving ioBroker and stuff to control my house, shutting down if I forget to replug it -> Bad.

It is powered by an ups and lipo battery to ensure keeping power for critical control things.

Greetings from Germany, sorry for my bad english.
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Programming languages support under PINE64 baryluk 5 2,936 03-09-2018, 01:52 AM
Last Post: kaokaobang
Wink Pine64 Will support Freenas or openmediavault ? joe 1 1,760 04-13-2017, 07:44 AM
Last Post: xalius
  Remote Desktop Support? Rochambeaux 20 6,249 10-01-2016, 05:08 PM
Last Post: HayseedGeek
  Binfmt_misc support cztian 1 713 08-17-2016, 11:49 PM
Last Post: longsleep
Question Joystick/Gamepad support Drakuwa 3 877 08-10-2016, 10:12 AM
Last Post: xalius
Big Grin Funny ! Support Intel x86 linux applications on ARM-based ( PINE64 ) not freeware joe 10 3,559 08-09-2016, 05:59 PM
Last Post: dkryder
  Camera support - Ubuntu Xenial 16.04 LTS @lex 3 862 08-07-2016, 03:47 AM
Last Post: romansavrulin
  Virtualization Support soccercheng 12 4,214 07-14-2016, 11:04 AM
Last Post: mont3z
  distro with kernel support for DVB-T dongles? mkaut 2 747 07-02-2016, 02:36 PM
Last Post: mkaut
  XFS Support? utdrmac 2 454 06-30-2016, 01:44 AM
Last Post: longsleep

Forum Jump:


Users browsing this thread: 1 Guest(s)