2

Using the ACPI interface, one can obtain information on battery life. Where does this info come from?

Is there a chip that computes capability by integrating current over the power supply plug? Is this the chip of the battery that translates voltages to capability?

1 Answer 1

3

The actual knowledge of nominal battery capacity doesn't generally come from the same place. For example, I worked with small embedded devices that would only ever be shipped with the same battery type – so the nominal capacity was simply hard-coded in the kernel driver (or the device tree file, I forget which, doesn't matter, it means "hardcoded in the software running on the CPU").

Other devices will have firmware runnning on the computer's main board's power controller that keeps track of capacity. Whether it knows that by knowing the factory capacity as a constant, or whether it gets the capacity from a microcontroller or memory built into the battery pack is again dependent on hardware design. Same for abilities to re-calibrate without operating system support.

Then, the question of where the knowledge on current battery state comes from: this again depends on the hardware design. Simplistic solutions might just read current battery voltage (and have an internal typical discharge curve that maps voltage to charge; which is what you'd expect in the dumbphone era: a battery symbol that signals "quite full", "somewhat full", "nearly empty", that's it), others will at least compensate for temperature, better ones will also actually count the Joules that came from the battery and give a more accurate reading, typically.

Then, either the ACPI controller, or quite often on non-ACPI systems, the kernel directly talks to these devices (e.g. via SMBUS, USB, some CPU UART…) and converts these readings to the values you see from the kernel interfaces (sysfs).

4
  • Thanks for the answer, I will have a tour on /sys to see if I can find where this comes from in my setup. Commented May 31, 2023 at 13:16
  • 2
    that won't tell you. /sys is where the information can be queried – not where it comes from. Commented May 31, 2023 at 14:40
  • I found that there is an SMBUS for ex, any advice for further investigations ? Commented Jun 1, 2023 at 15:42
  • 1
    look into which kernel driver get loaded. But you ask about information that comes from ACPI, so the devices that supply the information to the ACPI controller might simply not be visible to Linux at all, and Linux just talks ACPI to the ACPI controller and you have no way at all to figure out how that knows. Commented Jun 1, 2023 at 18:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.