Skip to content

Commit 1ae4a91

Browse files
Linus Walleijsre
authored andcommitted
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>
1 parent 8dc3557 commit 1ae4a91

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/power/supply/ab8500_fg.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ struct ab8500_fg {
213213
int init_cnt;
214214
int low_bat_cnt;
215215
int nbr_cceoc_irq_cnt;
216+
u32 line_impedance_uohm;
216217
bool recovery_needed;
217218
bool high_curr_mode;
218219
bool init_capacity;
@@ -910,6 +911,9 @@ static int ab8500_fg_battery_resistance(struct ab8500_fg *di, int vbat_uncomp_uv
910911
resistance = bi->factory_internal_resistance_uohm / 1000;
911912
}
912913

914+
/* Compensate for line impedance */
915+
resistance += (di->line_impedance_uohm / 1000);
916+
913917
dev_dbg(di->dev, "%s Temp: %d battery internal resistance: %d"
914918
" fg resistance %d, total: %d (mOhm)\n",
915919
__func__, di->bat_temp, resistance, di->bm->fg_res / 10,
@@ -3098,6 +3102,11 @@ static int ab8500_fg_probe(struct platform_device *pdev)
30983102
return ret;
30993103
}
31003104

3105+
if (!of_property_read_u32(dev->of_node, "line-impedance-micro-ohms",
3106+
&di->line_impedance_uohm))
3107+
dev_info(dev, "line impedance: %u uOhm\n",
3108+
di->line_impedance_uohm);
3109+
31013110
psy_cfg.supplied_to = supply_interface;
31023111
psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
31033112
psy_cfg.drv_data = di;

0 commit comments

Comments
 (0)