Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 913a32ed authored by jessicatseng's avatar jessicatseng Committed by jessicatseng(45616)
Browse files

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
parent 40d21c37
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -1236,6 +1236,38 @@ static int smblib_usb_irq_enable_vote_callback(struct votable *votable,
	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 @@ static int smblib_create_votables(struct smb_charger *chg)
		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;
}

+3 −0
Original line number Diff line number Diff line
@@ -341,6 +341,9 @@ struct smb_charger {
	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;
+16 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ struct step_chg_info {
	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 @@ static int handle_step_chg_config(struct step_chg_info *chip)
}

#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 @@ static int handle_jeita(struct step_chg_info *chip)
	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 @@ static int handle_jeita(struct step_chg_info *chip)

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();