• Linus Walleij's avatar
    power: supply: Support VBAT-to-Ri lookup tables · e9e7d165
    Linus Walleij authored
    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: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
    e9e7d165
power_supply_core.c 42.3 KB