google_battery,max77779_fg,max1720x_battery: route aafv to FG
bug: 382713668
test: build
Signed-off-by: Jack Wu <[email protected]>
(cherry picked from commit c5c63ac9821ab9fa1cf243d0abe1d01042034bb6)
(cherry picked from https://partner-android-review.googlesource.com/q/commit:f453451ac7ce4fe4fd6d5751f8941c483fb1d496)
Merged-In: I6ee215c6bbc602c3aebb496f966fb1845b7da6bf
Change-Id: I6ee215c6bbc602c3aebb496f966fb1845b7da6bf
diff --git a/gbms_power_supply.h b/gbms_power_supply.h
index 05ca729..6ef82e2 100644
--- a/gbms_power_supply.h
+++ b/gbms_power_supply.h
@@ -96,6 +96,7 @@
GBMS_PROP_BATT_ID, /* GBMS battery id */
GBMS_PROP_RECAL_FG, /* GBMS FG reset */
GBMS_PROP_LOGBUFFER_BD, /* GBMS pass logbuffer_bd address */
+ GBMS_PROP_AAFV, /* GBMS pass aafv to FG */
};
union gbms_propval {
diff --git a/google_battery.c b/google_battery.c
index 4cc8a03..7529071 100644
--- a/google_battery.c
+++ b/google_battery.c
@@ -5228,8 +5228,14 @@
if (vbatt_idx != batt_drv->vbatt_idx || temp_idx != batt_drv->temp_idx) {
const int last_vbatt_idx = gbms_msc_get_last_voltage_idx(profile, temp_idx);
- if (vbatt_idx == last_vbatt_idx)
+ if (vbatt_idx == last_vbatt_idx) {
+ int ret;
+
aafv_update_voltage(batt_drv, &fv_uv, last_vbatt_idx);
+ ret = GPSY_SET_PROP(fg_psy, GBMS_PROP_AAFV, fv_uv);
+ if (ret < 0)
+ pr_err("pass aafv to FG failed %d", ret);
+ }
}
batt_prlog(batt_prlog_level(changed),
diff --git a/google_dual_batt_gauge.c b/google_dual_batt_gauge.c
index 5742d38..ce01e3f 100644
--- a/google_dual_batt_gauge.c
+++ b/google_dual_batt_gauge.c
@@ -828,6 +828,7 @@
case GBMS_PROP_CAPACITY_FADE_RATE:
case GBMS_PROP_CAPACITY_FADE_RATE_FCR:
case GBMS_PROP_BATT_ID:
+ case GBMS_PROP_AAFV:
val->prop.intval = fg_1.prop.intval;
break;
case GBMS_PROP_RECAL_FG:
@@ -894,6 +895,18 @@
case GBMS_PROP_RECAL_FG:
/* TODO: under porting */
break;
+ case GBMS_PROP_AAFV:
+ if (dual_fg_drv->first_fg_psy) {
+ ret = GPSY_SET_PROP(dual_fg_drv->first_fg_psy, psp, val->prop.intval);
+ if (ret < 0)
+ pr_err("Cannot set aafv to the first FG, ret=%d\n", ret);
+ }
+ if (dual_fg_drv->second_fg_psy) {
+ ret = GPSY_SET_PROP(dual_fg_drv->second_fg_psy, psp, val->prop.intval);
+ if (ret < 0)
+ pr_err("Cannot set aafv to the second FG, ret=%d\n", ret);
+ }
+ break;
default:
pr_debug("%s: route to gdbatt_set_property, psp:%d\n", __func__, psp);
return -ENODATA;
@@ -912,6 +925,7 @@
{
switch (psp) {
case GBMS_PROP_BATT_CE_CTRL:
+ case GBMS_PROP_AAFV:
return 1;
default:
break;
diff --git a/max1720x_battery.c b/max1720x_battery.c
index 4833bad..8aef260 100644
--- a/max1720x_battery.c
+++ b/max1720x_battery.c
@@ -243,6 +243,9 @@
/* buffer for recording learning history */
struct maxfg_capture_buf cb_lh;
+
+ /* AAFV: Aged Adjusted Float Voltage */
+ int aafv;
};
#define MAX1720_EMPTY_VOLTAGE(profile, temp, cycle) \
@@ -2699,6 +2702,9 @@
if (chip->gauge_type == MAX_M5_GAUGE_TYPE)
val->prop.intval = max_m5_recal_state(chip->model_data);
break;
+ case GBMS_PROP_AAFV:
+ val->prop.intval = chip->aafv;
+ break;
default:
pr_debug("%s: route to max1720x_get_property, psp:%d\n", __func__, psp);
err = -ENODATA;
@@ -2781,6 +2787,9 @@
case GBMS_PROP_RECAL_FG:
max1720x_set_recalibration(chip, val->prop.intval);
break;
+ case GBMS_PROP_AAFV:
+ chip->aafv = val->prop.intval;
+ break;
default:
pr_debug("%s: route to max1720x_set_property, psp:%d\n", __func__, psp);
return -ENODATA;
@@ -2798,6 +2807,7 @@
switch (psp) {
case GBMS_PROP_BATT_CE_CTRL:
case GBMS_PROP_HEALTH_ACT_IMPEDANCE:
+ case GBMS_PROP_AAFV:
return 1;
default:
break;
diff --git a/max77779_fg.c b/max77779_fg.c
index e3f26b0..a05aecf 100644
--- a/max77779_fg.c
+++ b/max77779_fg.c
@@ -1673,6 +1673,9 @@
case GBMS_PROP_RECAL_FG:
/* TODO: under porting */
break;
+ case GBMS_PROP_AAFV:
+ val->prop.intval = chip->aafv;
+ break;
default:
pr_debug("%s: route to max77779_fg_get_property, psp:%d\n", __func__, psp);
err = -ENODATA;
@@ -1745,6 +1748,9 @@
case GBMS_PROP_RECAL_FG:
/* TODO: under porting */
break;
+ case GBMS_PROP_AAFV:
+ chip->aafv = val->prop.intval;
+ break;
default:
pr_debug("%s: route to max77779_fg_set_property, psp:%d\n", __func__, psp);
return -ENODATA;
@@ -1762,6 +1768,7 @@
switch (psp) {
case GBMS_PROP_BATT_CE_CTRL:
case GBMS_PROP_HEALTH_ACT_IMPEDANCE:
+ case GBMS_PROP_AAFV:
return 1;
default:
break;
diff --git a/max77779_fg.h b/max77779_fg.h
index 5e3d4e2..bc79522 100644
--- a/max77779_fg.h
+++ b/max77779_fg.h
@@ -194,6 +194,9 @@
/* mutex lock to access FG USR reg */
struct mutex usr_lock;
+
+ /* AAFV: Aged Adjusted Float Voltage */
+ int aafv;
};
/** ------------------------------------------------------------------------ */