diff options
author | Prasanna Prapancham <prapancham@google.com> | 2023-08-01 23:30:15 +0000 |
---|---|---|
committer | Prasanna Prapancham <prapancham@google.com> | 2023-08-08 17:41:10 +0000 |
commit | c61a148b3a07ecd2b2f1cd73fc96d582509e6835 (patch) | |
tree | 0eb0bfbdec62baf34b63954ba2294fe488242bbf | |
parent | ba6a6d4293513ee5559eb7838f5fb24e74ddbd62 (diff) | |
download | bms-c61a148b3a07ecd2b2f1cd73fc96d582509e6835.tar.gz |
google_battery: fix round fv_uv, don't lose irdrop learnt fv_uv
Bug: 292448490
Change-Id: I3fb542f90e049c28c0b1b4bb8a84549112094ae6
Signed-off-by: Prasanna Prapancham <prapancham@google.com>
-rw-r--r-- | google_battery.c | 9 | ||||
-rw-r--r-- | google_bms.c | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/google_battery.c b/google_battery.c index 981bb9f..ae84a40 100644 --- a/google_battery.c +++ b/google_battery.c @@ -4489,7 +4489,14 @@ static int msc_logic(struct batt_drv *batt_drv) /* need a new fv_uv only on a new voltage tier. */ if (vbatt_idx != batt_drv->vbatt_idx) { - fv_uv = profile->volt_limits[vbatt_idx]; + bool no_back_down = (batt_drv->chg_state.f.flags & GBMS_CS_FLAG_DIRECT_CHG) + && batt_drv->dc_irdrop; + /* Don't reduce fv_uv on next tier */ + bool allow_next_vt_fv_uv = no_back_down && vbatt_idx > batt_drv->vbatt_idx + && profile->volt_limits[vbatt_idx] > fv_uv; + + if (!no_back_down || allow_next_vt_fv_uv || vbatt_idx < batt_drv->vbatt_idx) + fv_uv = profile->volt_limits[vbatt_idx]; batt_drv->checked_tier_switch_cnt = 0; batt_drv->checked_ov_cnt = 0; } diff --git a/google_bms.c b/google_bms.c index 11b1332..3e78080 100644 --- a/google_bms.c +++ b/google_bms.c @@ -431,7 +431,7 @@ EXPORT_SYMBOL_GPL(gbms_dump_raw_profile); int gbms_msc_round_fv_uv(const struct gbms_chg_profile *profile, int vtier, int fv_uv, int cc_ua) { - int result; + int result, fv_uv_orig = fv_uv; const unsigned int fv_uv_max = (vtier / 1000) * profile->fv_uv_margin_dpct; const unsigned int dc_fv_uv_max = vtier + (cc_ua / 1000) * profile->fv_dc_ratio; const unsigned int last_fv = profile->volt_limits[profile->volt_nb_limits - 1]; @@ -447,11 +447,12 @@ int gbms_msc_round_fv_uv(const struct gbms_chg_profile *profile, if (fv_max != 0 && fv_uv > fv_max) fv_uv = fv_max; + fv_uv += profile->fv_uv_resolution / 2; result = fv_uv - (fv_uv % profile->fv_uv_resolution); if (fv_max != 0) gbms_info(profile, "MSC_ROUND: fv_uv=%d vtier=%d fv_uv_max=%d -> %d\n", - fv_uv, vtier, fv_max, result); + fv_uv_orig, vtier, fv_max, result); return result; } |