Battery Charging Monitoring and Control

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.

Below is the list of all files provided, along with the API documentation quoted from Documentation/ABI/testing/sysfs-class-power and a comment about how it applies to the ACT8945A driver specifically.

  • type:

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

    Supported values:

    • "Battery",

    • "Mains",

    • "USB"

  • status:

    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:

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

    All values are supported by the driver.

  • charge_type:

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

    • "N/A",

    • "Fast"

    • "Trickle"

    • "Unknown"

  • health:

    Supported values:

    • "Good"

    • "Over voltage"

    • "Safety timer expire"

    • "Overheat"

    • "Unknown"

  • current_max:

    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:

    Always "Li-ion".

  • manufacturer:

    Always "Active-semi".

  • model_name:

    Always "ACT8945A"

Example

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

 

Scenario 1

Scenario 2

Scenario 3

 

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

All charging-related registers can be listed with:

"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

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

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

The PMIC's state is reflected in sysfs: