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

Commit 8724e454 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: power_supply: add property for sw based JEITA"

parents 6f18dec7 8ae23a5c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -313,6 +313,7 @@ static struct device_attribute power_supply_attrs[] = {
	POWER_SUPPLY_ATTR(pr_swap),
	POWER_SUPPLY_ATTR(cc_step),
	POWER_SUPPLY_ATTR(cc_step_sel),
	POWER_SUPPLY_ATTR(sw_jeita_enabled),
	/* Local extensions of type int64_t */
	POWER_SUPPLY_ATTR(charge_counter_ext),
	/* Properties of type `const char *' */
+1 −0
Original line number Diff line number Diff line
@@ -433,6 +433,7 @@ struct fg_chip {
	int			maint_soc;
	int			delta_soc;
	int			last_msoc;
	int			last_recharge_volt_mv;
	int			esr_timer_charging_default[NUM_ESR_TIMERS];
	enum slope_limit_status	slope_limit_sts;
	bool			profile_available;
+49 −0
Original line number Diff line number Diff line
@@ -1315,11 +1315,20 @@ static bool is_temp_valid_cap_learning(struct fg_chip *chip)
	return true;
}

#define QNOVO_CL_SKEW_DECIPCT	-30
static void fg_cap_learning_post_process(struct fg_chip *chip)
{
	int64_t max_inc_val, min_dec_val, old_cap;
	int rc;

	if (is_qnovo_en(chip)) {
		fg_dbg(chip, FG_CAP_LEARN, "applying skew %d on current learnt capacity %lld\n",
			QNOVO_CL_SKEW_DECIPCT, chip->cl.final_cc_uah);
		chip->cl.final_cc_uah = chip->cl.final_cc_uah *
						(1000 + QNOVO_CL_SKEW_DECIPCT);
		do_div(chip->cl.final_cc_uah, 1000);
	}

	max_inc_val = chip->cl.learned_cc_uah
			* (1000 + chip->dt.cl_max_cap_inc);
	do_div(max_inc_val, 1000);
@@ -1628,6 +1637,9 @@ static int fg_set_recharge_voltage(struct fg_chip *chip, int voltage_mv)
	if (chip->wa_flags & PMI8998_V1_REV_WA)
		return 0;

	if (voltage_mv == chip->last_recharge_volt_mv)
		return 0;

	fg_dbg(chip, FG_STATUS, "Setting recharge voltage to %dmV\n",
		voltage_mv);
	fg_encode(chip->sp, FG_SRAM_RECHARGE_VBATT_THR, voltage_mv, &buf);
@@ -1642,6 +1654,7 @@ static int fg_set_recharge_voltage(struct fg_chip *chip, int voltage_mv)
		return rc;
	}

	chip->last_recharge_volt_mv = voltage_mv;
	return 0;
}

@@ -1952,6 +1965,33 @@ static int fg_adjust_recharge_soc(struct fg_chip *chip)
	return 0;
}

static int fg_adjust_recharge_voltage(struct fg_chip *chip)
{
	int rc, recharge_volt_mv;

	if (chip->dt.auto_recharge_soc)
		return 0;

	fg_dbg(chip, FG_STATUS, "health: %d chg_status: %d chg_done: %d\n",
		chip->health, chip->charge_status, chip->charge_done);

	recharge_volt_mv = chip->dt.recharge_volt_thr_mv;

	/* Lower the recharge voltage in soft JEITA */
	if (chip->health == POWER_SUPPLY_HEALTH_WARM ||
			chip->health == POWER_SUPPLY_HEALTH_COOL)
		recharge_volt_mv -= 200;

	rc = fg_set_recharge_voltage(chip, recharge_volt_mv);
	if (rc < 0) {
		pr_err("Error in setting recharge_voltage, rc=%d\n",
			rc);
		return rc;
	}

	return 0;
}

static int fg_slope_limit_config(struct fg_chip *chip, int batt_temp)
{
	enum slope_limit_status status;
@@ -2415,6 +2455,10 @@ static void status_change_work(struct work_struct *work)
	if (rc < 0)
		pr_err("Error in adjusting recharge_soc, rc=%d\n", rc);

	rc = fg_adjust_recharge_voltage(chip);
	if (rc < 0)
		pr_err("Error in adjusting recharge_voltage, rc=%d\n", rc);

	rc = fg_adjust_ki_coeff_dischg(chip);
	if (rc < 0)
		pr_err("Error in adjusting ki_coeff_dischg, rc=%d\n", rc);
@@ -3993,6 +4037,11 @@ static irqreturn_t fg_delta_batt_temp_irq_handler(int irq, void *data)
		if (rc < 0)
			pr_err("Error in adjusting timebase, rc=%d\n", rc);

		rc = fg_adjust_recharge_voltage(chip);
		if (rc < 0)
			pr_err("Error in adjusting recharge_voltage, rc=%d\n",
				rc);

		chip->last_batt_temp = batt_temp;
		power_supply_changed(chip->batt_psy);
	}
+11 −0
Original line number Diff line number Diff line
@@ -1395,6 +1395,17 @@ static irqreturn_t handle_ptrain_done(int irq, void *data)
	struct qnovo *chip = data;
	union power_supply_propval pval = {0};

	/*
	 * In some cases (esp shutting down) the userspace would  disable by
	 * setting qnovo_enable=0. Also charger could be removed or there is
	 * an error (i.e. its not okay to run qnovo)-
	 * skip taking ESR measurement in such situations
	 */

	if (get_client_vote(chip->disable_votable, USER_VOTER)
		|| get_effective_result(chip->not_ok_to_qnovo_votable) > 0)
		return IRQ_HANDLED;

	/*
	 * hw resets pt_en bit once ptrain_done triggers.
	 * vote on behalf of QNI to disable it such that
+1 −0
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ enum power_supply_property {
	POWER_SUPPLY_PROP_PR_SWAP,
	POWER_SUPPLY_PROP_CC_STEP,
	POWER_SUPPLY_PROP_CC_STEP_SEL,
	POWER_SUPPLY_PROP_SW_JEITA_ENABLED,
	/* Local extensions of type int64_t */
	POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
	/* Properties of type `const char *' */