]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: Support VBAT-to-Ri lookup tables
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 25 Feb 2022 23:27:58 +0000 (00:27 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 28 Feb 2022 10:34:32 +0000 (11:34 +0100)
commite583029c1b091ec7812c97d49809c0ee7751ae05
tree4bb2a186091776db007d7d1d833bb52e3e7edf94
parent447db3076d06558a1d85b0c6188f6f464e6478d7
power: supply: Support VBAT-to-Ri lookup tables

In Samsung devices, the method used to compensate for temperature,
age, load etc is by way of VBAT to Ri tables, which correlates the
battery voltage under load (VBAT) to an internal resistance (Ri).

Using this Ri and a measurement of the current out of the battery
(IBAT) the open circuit voltage (OCV) can be calculated as:

  OCV = VBAT - (Ri * IBAT)

The details are described in comments to struct
power_supply_battery_info in the commit.

Since not all batteries supply this VBAT-to-Ri data, the fallback
method to use the temperature-to-Ri lookup table can also be used
as a fallback.

Add two helper functions to check if we have the tables needed for
using power_supply_vbat2ri() or power_supply_temp2resist_simple()
respectively, so capacity estimation code can choose which one
to employ.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/power_supply_core.c
include/linux/power_supply.h