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:
pmu0@0 {
           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 IRC channel >>


Messages In This Thread
AXP803 Battery Charger Support - by xalius - 06-18-2016, 03:28 AM
RE: AXP803 Battery Charger Support - by tllim - 06-18-2016, 04:16 PM
RE: AXP803 Battery Charger Support - by pfeerick - 06-18-2016, 09:59 PM
RE: AXP803 Battery Charger Support - by xalius - 06-19-2016, 06:19 AM
RE: AXP803 Battery Charger Support - by pfeerick - 06-19-2016, 07:22 PM
RE: AXP803 Battery Charger Support - by tllim - 06-20-2016, 07:38 AM
RE: AXP803 Battery Charger Support - by xalius - 06-19-2016, 07:31 PM
RE: AXP803 Battery Charger Support - by xalius - 06-20-2016, 02:55 PM
RE: AXP803 Battery Charger Support - by longsleep - 06-20-2016, 04:25 PM
RE: AXP803 Battery Charger Support - by drid - 12-03-2017, 02:24 PM
RE: AXP803 Battery Charger Support - by xalius - 12-03-2017, 03:56 PM
RE: AXP803 Battery Charger Support - by xalius - 12-22-2017, 05:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Programming languages support under PINE64 baryluk 6 12,074 09-23-2020, 11:46 PM
Last Post: Phillip Bell
Wink Pine64 Will support Freenas or openmediavault ? joe 1 4,910 04-13-2017, 07:44 AM
Last Post: xalius
  Remote Desktop Support? Rochambeaux 20 28,745 10-01-2016, 05:08 PM
Last Post: HayseedGeek
  Binfmt_misc support cztian 1 3,641 08-17-2016, 11:49 PM
Last Post: longsleep
Question Joystick/Gamepad support Drakuwa 3 5,854 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 16,065 08-09-2016, 05:59 PM
Last Post: dkryder
  Camera support - Ubuntu Xenial 16.04 LTS @lex 3 5,109 08-07-2016, 03:47 AM
Last Post: romansavrulin
  Virtualization Support soccercheng 12 17,027 07-14-2016, 11:04 AM
Last Post: mont3z
  distro with kernel support for DVB-T dongles? mkaut 2 4,539 07-02-2016, 02:36 PM
Last Post: mkaut
  XFS Support? utdrmac 2 3,267 06-30-2016, 01:44 AM
Last Post: longsleep

Forum Jump:


Users browsing this thread: 1 Guest(s)