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

Commit 34b5579d authored by jasonhsing's avatar jasonhsing 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.

RiskArea:
Charging

Change-Id: I87695c1039a6f3c9fdf299f3e403238298f3a5d2
(cherry picked from commit 7c2d18a90e414aa596c500d0cd0d4e2351141c40)
parent ba3218fc
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;
}

//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
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;
}
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --

/*******************
 * VCONN REGULATOR *
 * *****************/
@@ -4586,6 +4618,16 @@ static int smblib_create_votables(struct smb_charger *chg)
		return rc;
	}

//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
	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;
	}
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --

	return rc;
}

+3 −0
Original line number Diff line number Diff line
@@ -356,6 +356,9 @@ struct smb_charger {
	struct votable		*chg_disable_votable;
	struct votable		*pl_enable_votable_indirect;
	struct votable		*usb_irq_enable_votable;
//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
	struct votable		*rechg_vol_votable;
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --

	/* 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;
//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
	struct votable		*rechg_vol_votable;
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --
	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
//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
#define JEITA_RECHG_HYST_UV		100000
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --

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;

//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
	if (!chip->rechg_vol_votable)
		chip->rechg_vol_votable = find_votable("RECHG_VOL");
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --

	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);
//<--[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp BEGIN --
	vote(chip->rechg_vol_votable,
			JEITA_VOTER, true, (fv_uv -JEITA_RECHG_HYST_UV));
//-->[FairPhone][Charging][JasonHsing] Setting jeita fv re-charge voltage for warm temp END --

update_time:
	chip->jeita_last_update_time = ktime_get();