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

Commit a291e86c authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Sahil Chandna
Browse files

power: qpnp-fg-gen3: adjust ki coefficient for full soc dynamically



In certain conditions, after the battery SOC reaches 100%, SOC is
not getting updated during discharging. Based on the hardware
recommendation, adjust the Ki coefficient for full SOC so that
SOC can be updated faster during discharging.

While at it, remove prev_charge_status variable which is not
used really.

CRs-Fixed: 2089555
Change-Id: I48b3494165396d36ce5b4212a0464d4ea87ee9a4
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: default avatarSahil Chandna <chandna@codeaurora.org>
parent da3967d9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -316,6 +316,13 @@ First Level Node - FG Gen3 device
		    is specified to make it fully functional. Value has no
		    unit. Allowed range is 0 to 62200 in micro units.

- qcom,ki-coeff-full-dischg
	Usage:      optional
	Value type: <u32>
	Definition: Ki coefficient full SOC value that will be applied during
		    discharging. If not specified, a value of 0 will be set.
		    Allowed range is from 245 to 62256.

- qcom,fg-rconn-mohms
	Usage:      optional
	Value type: <u32>
+1 −1
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ struct fg_dt_props {
	int	slope_limit_temp;
	int	esr_pulse_thresh_ma;
	int	esr_meas_curr_ma;
	int	ki_coeff_full_soc_dischg;
	int	sync_sleep_threshold_ma;
	int	jeita_thresholds[NUM_JEITA_LEVELS];
	int	ki_coeff_soc[KI_COEFF_SOC_LEVELS];
@@ -408,7 +409,6 @@ struct fg_chip {
	int			batt_id_ohms;
	int			ki_coeff_full_soc;
	int			charge_status;
	int			prev_charge_status;
	int			charge_done;
	int			charge_type;
	int			last_soc;
+7 −9
Original line number Diff line number Diff line
@@ -1503,9 +1503,6 @@ static void fg_cap_learning_update(struct fg_chip *chip)
		goto out;
	}

	if (chip->charge_status == chip->prev_charge_status)
		goto out;

	rc = fg_get_sram_prop(chip, FG_SRAM_BATT_SOC, &batt_soc);
	if (rc < 0) {
		pr_err("Error in getting ACT_BATT_CAP, rc=%d\n", rc);
@@ -1650,6 +1647,8 @@ static int fg_adjust_ki_coeff_full_soc(struct fg_chip *chip, int batt_temp)

	if (batt_temp < 0)
		ki_coeff_full_soc = 0;
	else if (chip->charge_status == POWER_SUPPLY_STATUS_DISCHARGING)
		ki_coeff_full_soc = chip->dt.ki_coeff_full_soc_dischg;
	else
		ki_coeff_full_soc = KI_COEFF_FULL_SOC_DEFAULT;

@@ -2227,9 +2226,6 @@ static int fg_esr_timer_config(struct fg_chip *chip, bool sleep)

static void fg_batt_avg_update(struct fg_chip *chip)
{
	if (chip->charge_status == chip->prev_charge_status)
		return;

	cancel_delayed_work_sync(&chip->batt_avg_work);
	fg_circ_buf_clr(&chip->ibatt_circ_buf);
	fg_circ_buf_clr(&chip->vbatt_circ_buf);
@@ -2460,7 +2456,6 @@ static void status_change_work(struct work_struct *work)
	}

	fg_batt_avg_update(chip);
	chip->prev_charge_status = chip->charge_status;
out:
	fg_dbg(chip, FG_STATUS, "charge_status:%d charge_type:%d charge_done:%d\n",
		chip->charge_status, chip->charge_type, chip->charge_done);
@@ -4247,7 +4242,11 @@ static int fg_parse_slope_limit_coefficients(struct fg_chip *chip)
static int fg_parse_ki_coefficients(struct fg_chip *chip)
{
	struct device_node *node = chip->dev->of_node;
	int rc, i;
	int rc, i, temp;

	rc = of_property_read_u32(node, "qcom,ki-coeff-full-dischg", &temp);
	if (!rc)
		chip->dt.ki_coeff_full_soc_dischg = temp;

	rc = fg_parse_dt_property_u32_array(node, "qcom,ki-coeff-soc-dischg",
		chip->dt.ki_coeff_soc, KI_COEFF_SOC_LEVELS);
@@ -4731,7 +4730,6 @@ static int fg_gen3_probe(struct spmi_device *spmi)
	chip->debug_mask = &fg_gen3_debug_mask;
	chip->irqs = fg_irqs;
	chip->charge_status = -EINVAL;
	chip->prev_charge_status = -EINVAL;
	chip->ki_coeff_full_soc = -EINVAL;
	chip->spmi = spmi;