Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Battery Charging

...

Monitoring

The ACT8945A device driver exposes some charging information in the user space at /sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018600.i2c/i2c-0/0-005b/act8945a-charger/power_supply/act8945a-charger.

...

  • type:

    Code Block
    Describes the main type of the supply.
    
    Access: Read
    Valid values: "Battery", "UPS", "Mains", "USB", "Wireless"

    Supported values:

    • "Battery",

    • "Mains",

    • "USB"

  • status:

    Code Block
    Represents the charging status of the battery. Normally this
    is read-only reporting although for some supplies this can be
    used to enable/disable charging to the battery.
    
    Access: Read, Write
    Valid values:
    	      "Unknown", "Charging", "Discharging",
    	      "Not charging", "Full"

    The file is actually read only, the driver not allowing to control the charging phase. Supported values:

    • "Charging"

    • "Full"

    • "Discharging"

    • "Not charging"

  • capacity_level:

    Code Block
    Coarse representation of battery capacity.
    
    Access: Read
    Valid values:
    	      "Unknown", "Critical", "Low", "Normal", "High",
    	      "Full"

    All values are supported by the driver.

  • charge_type:

    Code Block
    Represents the type of charging currently being applied to the
    battery. "Trickle", "Fast", and "Standard" all mean different
    charging speeds. "Adaptive" means that the charger uses some
    algorithm to adjust the charge rate dynamically, without
    any user configuration required. "Custom" means that the charger
    uses the charge_control_* properties as configuration for some
    different algorithm. "Long Life" means the charger reduces its
    charging rate in order to prolong the battery health. "Bypass"
    means the charger bypasses the charging path around the
    integrated converter allowing for a "smart" wall adaptor to
    perform the power conversion externally.
    
    Access: Read, Write
    Valid values:
    	      "Unknown", "N/A", "Trickle", "Fast", "Standard",
    	      "Adaptive", "Custom", "Long Life", "Bypass"

    The file is actually read-only, driver not allowing to change the charging type. Supported values:

    • "N/A",

    • "Fast"

    • "Trickle"

    • "Unknown"

  • health:

    Code Block
    Reports the health of the battery or battery side of charger
    functionality.
    
    Access: Read
    Valid values:
    	      "Unknown", "Good", "Overheat", "Dead",
    	      "Over voltage", "Unspecified failure", "Cold",
    	      "Watchdog timer expire", "Safety timer expire",
    	      "Over current", "Calibration required", "Warm",
    	      "Cool", "Hot", "No battery"

    Supported values:

    • "Good"

    • "Over voltage"

    • "Safety timer expire"

    • "Overheat"

    • "Unknown"

  • current_max:

    Code Block
    Battery:
      Reports the maximum IBAT current allowed into the battery.
    
    USB:
      Reports the maximum IBUS current the supply can support.
    
    Access: Read
    Valid values: Represented in microamps

    In cases of

    • unplugged USB,

    • unplugged battery,

    • both battery and USB plugged, battery fully charged,

    this value is always 0. Otherwise the charging current is given.

  • technology:

    Code Block
    Describes the battery technology supported by the supply.
    
    Access: Read
    Valid values:
    	      "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe",
    	      "NiCd", "LiMn"

    Always "Li-ion".

  • manufacturer:

    Code Block
    Reports the name of the device manufacturer.
    
    Access: Read
    Valid values: Represented as string

    Always "Active-semi".

  • model_name:

    Code Block
    Reports the name of the device model.
    
    Access: Read
    Valid values: Represented as string

    Always "ACT8945A"

Example

Real world values of some of the files in 3 different powering scenarios:

Scenario 1

Scenario 2

Scenario 3

USB

Plugged

Plugged

Unplugged

Battery

Plugged

Unplugged

Plugged

capacity_level

Full

Normal

Critical

charge_type

N/A

Unknown

N/A

health

Good

Overheat

Good

status

Full

Not charging

Discharging

type

Mains

Mains

Battery

Battery Charging Control

Overview

The ACT8945A PMIC provides a couple of charging-related parameters which can be programmed dynamically. However, the device's driver doesn't allow to do this from the userspace. Instead a direct communication through I2C for reading/writing PMIC's registers must be carried out. Conclusive provides a bash script /opt/act8945a-i2c-api.sh simplifying this task. See how to use it in detail with

Code Block
root@kstr-sama5d27:~# /opt/act8945a-i2c-api.sh -h

All charging-related registers can be listed with:

Code Block
root@kstr-sama5d27:~# /opt/act8945a-i2c-api.sh print pat APCH _
<output>	<name>
APCH	SUSCHG
APCH	TOTTIMO
APCH	PRETIMO
APCH	OVPSET
APCH	TIMRSTAT
APCH	TEMPSTAT
APCH	INSTAT
APCH	CHGSTAT
APCH	TIMRDAT
APCH	TEMPDAT
APCH	INDAT
APCH	CHGDAT
APCH	TIMRTOT
APCH	TEMPIN
APCH	INCON
APCH	CHGEOCIN
APCH	TIMRPRE
APCH	TEMPOUT
APCH	INDIS
APCH	CHGEOCOUT
APCH	CSTATE
APCH	ACINSTAT

"APCH" stands for "Active Path Charging" and designates a specific registers group (named "output" in ACT8945A's nomenclature).

Of these the TIMRDAT, TEMPDAT, INDAT, CHGDAT, CSTATE, ACINSTAT registers are read-only and describe the powering and charging state, which is sufficiently covered by the built-in driver, and their state is reflected in sysfs.

Registers TIMRSTAT, TEMPSTAT, INSTAT, CHGSTAT, TIMRTOT, TEMPIN, INCON, CHGEOCIN, TIMRPRE, TEMPOUT, INDIS, CHGEOCOUT are all single-bit flags enabling interrupts related to various phases of the charging process. By default all of them are disabled.

The TOTTIMO, PRETIMO, OVPSET registers control some charging parameters:

TOTTIMO

Total Charge Time-out

PRETIMO

Precondition Charge Time-out

OVPSET

Input Over-Voltage Protection Threshold

Finally, SUSCHG is a flag enabling/disabling charging of the battery.

For more details about these registers refer to the ACT8945A's datasheet.

Example: Disabling Charging

Assume the KSTR-SAMA5D27 board is connected to a host through USB and has a semi-discharged battery plugged in. Checking the charging status with

Code Block
root@kstr-sama5d27:~# cat /sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018600.i2c/i2c-0/0-005b/act8945a-charger/power_supply/act8945a-charger/status

Charging

shows that the battery is charging. Reading the SUSCHG ("Suspend Charging") register confirms this

Code Block
root@kstr-sama5d27:~# /opt/act8945a-i2c-api.sh get 0 pat APCH SUSCHG
<output>	<name>	Dec	Hex
APCH	SUSCHG	0	0x0

Value 0 means that the charging is not suspended. This can be changed with

Code Block
root@kstr-sama5d27:~# /opt/act8945a-i2c-api.sh set 0 1 pat APCH SUSCHG
<output>	<name>	<value>	Status
APCH	SUSCHG	1	OK

The PMIC's state is reflected in sysfs:

Code Block
cat /sys/devices/platform/ahb/ahb:apb/fc018000.flexcom/fc018600.i2c/i2c-0/0-005b/act8945a-charger/power_supply/act8945a-charger/status

Not charging