diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2022-03-01 13:42:54 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2022-03-04 22:20:32 +0100 |
commit | 1ae4a91c923220b96c81e4a116595f4060f65c7f (patch) | |
tree | a1a45f421e7cb13020324e2956440ebb27069b41 /drivers/power | |
parent | 8dc355748a7cb4b374d1296bdd68f66c18aced9e (diff) |
power: supply: ab8500_fg: Account for line impedance
We add the line impedance to the inner resistance determined
from the battery voltage or other means to improve the
capacity estimations.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/supply/ab8500_fg.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 1abe10c7ff2a..3ae8086907de 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -213,6 +213,7 @@ struct ab8500_fg { int init_cnt; int low_bat_cnt; int nbr_cceoc_irq_cnt; + u32 line_impedance_uohm; bool recovery_needed; bool high_curr_mode; bool init_capacity; @@ -910,6 +911,9 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di, int vbat_uncomp_uv resistance = bi->factory_internal_resistance_uohm / 1000; } + /* Compensate for line impedance */ + resistance += (di->line_impedance_uohm / 1000); + dev_dbg(di->dev, "%s Temp: %d battery internal resistance: %d" " fg resistance %d, total: %d (mOhm)\n", __func__, di->bat_temp, resistance, di->bm->fg_res / 10, @@ -3098,6 +3102,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) return ret; } + if (!of_property_read_u32(dev->of_node, "line-impedance-micro-ohms", + &di->line_impedance_uohm)) + dev_info(dev, "line impedance: %u uOhm\n", + di->line_impedance_uohm); + psy_cfg.supplied_to = supply_interface; psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface); psy_cfg.drv_data = di; |