Setting jeita fv re-charge voltage for warm temp
Root cause:
Jeita fv stop charging when battery temp is warm, but without
use HW re-charge.
How to fix:
Add a dynamic re-charge function for warm temp's HW re-charge
Change-Id: I9343ab687113f03d93cecb8baa5e8ac794cf7f7b
diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c
index 7d9c7ba..a5c3254 100644
--- a/drivers/power/supply/qcom/smb5-lib.c
+++ b/drivers/power/supply/qcom/smb5-lib.c
@@ -1236,6 +1236,38 @@
return 0;
}
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+static int smblib_jeita_rechg_voltage_vote_callback(struct votable *votable, void *data,
+ int voltage, const char *client)
+{
+ struct smb_charger *chg = data;
+ int rc = 0;
+ u32 temp = VBAT_TO_VRAW_ADC((voltage/1000));
+
+ temp = ((temp & 0xFF00) >> 8) | ((temp & 0xFF) << 8);
+ rc = smblib_batch_write(chg,
+ CHGR_ADC_RECHARGE_THRESHOLD_MSB_REG, (u8 *)&temp, 2);
+ if (rc < 0) {
+ dev_err(chg->dev, "Couldn't configure ADC_RECHARGE_THRESHOLD REG rc=%d\n",
+ rc);
+ return rc;
+ }
+ /* Program the sample count for VBAT based recharge to 3 */
+ rc = smblib_masked_write(chg, CHGR_NO_SAMPLE_TERM_RCHG_CFG_REG,
+ NO_OF_SAMPLE_FOR_RCHG,
+ 2 << NO_OF_SAMPLE_FOR_RCHG_SHIFT);
+ if (rc < 0) {
+ dev_err(chg->dev, "Couldn't configure CHGR_NO_SAMPLE_FOR_TERM_RCHG_CFG rc=%d\n",
+ rc);
+ return rc;
+ }
+
+ dev_err(chg->dev, "jeita_rechg_voltage =%d\n", voltage);
+
+ return rc;
+}
+//>2020/04/28-JessicaTseng
+
/*******************
* VCONN REGULATOR *
* *****************/
@@ -4428,6 +4460,16 @@
return rc;
}
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+ chg->rechg_vol_votable = create_votable("RECHG_VOL", VOTE_MIN,
+ smblib_jeita_rechg_voltage_vote_callback,
+ chg);
+ if (IS_ERR(chg->rechg_vol_votable)) {
+ rc = PTR_ERR(chg->rechg_vol_votable);
+ return rc;
+ }
+//>2020/04/28-JessicaTseng
+
return rc;
}
diff --git a/drivers/power/supply/qcom/smb5-lib.h b/drivers/power/supply/qcom/smb5-lib.h
index 63061da..c00db85 100644
--- a/drivers/power/supply/qcom/smb5-lib.h
+++ b/drivers/power/supply/qcom/smb5-lib.h
@@ -341,6 +341,9 @@
struct votable *chg_disable_votable;
struct votable *pl_enable_votable_indirect;
struct votable *usb_irq_enable_votable;
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+ struct votable *rechg_vol_votable;
+//>2020/04/28-JessicaTseng
/* work */
struct work_struct bms_update_work;
diff --git a/drivers/power/supply/qcom/step-chg-jeita.c b/drivers/power/supply/qcom/step-chg-jeita.c
index 3e8b46b..63b3950 100644
--- a/drivers/power/supply/qcom/step-chg-jeita.c
+++ b/drivers/power/supply/qcom/step-chg-jeita.c
@@ -80,6 +80,9 @@
struct votable *fcc_votable;
struct votable *fv_votable;
struct votable *usb_icl_votable;
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+ struct votable *rechg_vol_votable;
+//>2020/04/28-JessicaTseng
struct wakeup_source *step_chg_ws;
struct power_supply *batt_psy;
struct power_supply *bms_psy;
@@ -500,6 +503,10 @@
}
#define JEITA_SUSPEND_HYST_UV 50000
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+#define JEITA_RECHG_HYST_UV 200000//100000
+//>2020/04/28-JessicaTseng
+
static int handle_jeita(struct step_chg_info *chip)
{
union power_supply_propval pval = {0, };
@@ -561,6 +568,11 @@
if (rc < 0)
fv_uv = 0;
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+ if (!chip->rechg_vol_votable)
+ chip->rechg_vol_votable = find_votable("RECHG_VOL");
+//>2020/04/28-JessicaTseng
+
chip->fv_votable = find_votable("FV");
if (!chip->fv_votable)
goto update_time;
@@ -597,6 +609,10 @@
set_jeita_fv:
vote(chip->fv_votable, JEITA_VOTER, fv_uv ? true : false, fv_uv);
+//<2020/04/28-JessicaTseng, Setting jeita fv re-charge voltage for warm temp
+ vote(chip->rechg_vol_votable,
+ JEITA_VOTER, true, (fv_uv -JEITA_RECHG_HYST_UV));
+//>2020/04/28-JessicaTseng
update_time:
chip->jeita_last_update_time = ktime_get();