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

Commit e12729bb authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen4: Fix Rslow compensation workaround



'commit b8fbbafb ("power: qpnp-fg-gen4: Disable Rslow
compensation for PM8150B v1")' added a workaround for PM8150B v1.
However, it will not work as expected when the profile is loaded
after doing the configuration during boot. Fix it by doing the
configuration after loading the profile.

Change-Id: Ie356453076f8c0d91eb5e54f86a41475b3d10e46
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent df9c344a
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -1134,7 +1134,7 @@ static int fg_gen4_bp_params_config(struct fg_dev *fg)
	struct fg_gen4_chip *chip = container_of(fg, struct fg_gen4_chip, fg);
	int rc, i;
	u8 buf, therm_coeffs[BATT_THERM_NUM_COEFFS * 2];
	u8 rslow_coeffs[RSLOW_NUM_COEFFS];
	u8 rslow_coeffs[RSLOW_NUM_COEFFS], val, mask;

	if (fg->bp.vbatt_full_mv > 0) {
		rc = fg_set_constant_chg_voltage(fg,
@@ -1190,6 +1190,23 @@ static int fg_gen4_bp_params_config(struct fg_dev *fg)
		fg_dbg(fg, FG_STATUS, "Rslow_low: %d\n", chip->rslow_low);
	}

	/*
	 * Since this SRAM word falls inside profile region, configure it after
	 * the profile is loaded. This parameter doesn't come from battery
	 * profile DT property.
	 */
	if (fg->wa_flags & PM8150B_V1_RSLOW_COMP_WA) {
		val = 0;
		mask = BIT(1);
		rc = fg_sram_masked_write(fg, RSLOW_CONFIG_WORD,
				RSLOW_CONFIG_OFFSET, mask, val, FG_IMA_DEFAULT);
		if (rc < 0) {
			pr_err("Error in writing RSLOW_CONFIG_WORD, rc=%d\n",
				rc);
			return rc;
		}
	}

	if (fg->bp.therm_pull_up_kohms > 0) {
		switch (fg->bp.therm_pull_up_kohms) {
		case 30:
@@ -2964,18 +2981,6 @@ static int fg_gen4_hw_init(struct fg_gen4_chip *chip)
		}
	}

	if (fg->wa_flags & PM8150B_V1_RSLOW_COMP_WA) {
		val = 0;
		mask = BIT(1);
		rc = fg_sram_masked_write(fg, RSLOW_CONFIG_WORD,
				RSLOW_CONFIG_OFFSET, mask, val, FG_IMA_DEFAULT);
		if (rc < 0) {
			pr_err("Error in writing RSLOW_CONFIG_WORD, rc=%d\n",
				rc);
			return rc;
		}
	}

	rc = restore_cycle_count(chip->counter);
	if (rc < 0) {
		pr_err("Error in restoring cycle_count, rc=%d\n", rc);