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

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

Merge "power: qpnp-fg-gen3: Configure ESR timer at shutdown"

parents 2d752274 0ed50fb1
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -177,6 +177,14 @@ First Level Node - FG Gen3 device
		    Element 0 - Retry value for timer
		    Element 1 - Maximum value for timer

- qcom,fg-esr-timer-shutdown
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Number of cycles between ESR pulses at/after shutdwon. This is
		    defined when TWM (traditional watch mode) is supported.
		    Element 0 - Retry value for timer
		    Element 1 - Maximum value for timer

- qcom,fg-esr-pulse-thresh-ma
	Usage:      optional
	Value type: <u32>
@@ -398,6 +406,12 @@ First Level Node - FG Gen3 device
	Definition: A boolean property when defined uses software based
		    ESR during charging.

- qcom,fg-disable-esr-pull-dn
	Usage:      optional
	Value type: <empty>
	Definition: A boolean property which disables ESR pull-down.
		    This is to be used for debug purposes only.

==========================================================
Second Level Nodes - Peripherals managed by FG Gen3 driver
==========================================================
+2 −0
Original line number Diff line number Diff line
@@ -243,6 +243,7 @@ struct fg_dt_props {
	bool	hold_soc_while_full;
	bool	auto_recharge_soc;
	bool	use_esr_sw;
	bool	disable_esr_pull_dn;
	int	cutoff_volt_mv;
	int	empty_volt_mv;
	int	vbatt_low_thr_mv;
@@ -257,6 +258,7 @@ struct fg_dt_props {
	int	esr_timer_charging[NUM_ESR_TIMERS];
	int	esr_timer_awake[NUM_ESR_TIMERS];
	int	esr_timer_asleep[NUM_ESR_TIMERS];
	int	esr_timer_shutdown[NUM_ESR_TIMERS];
	int	rconn_mohms;
	int	esr_clamp_mohms;
	int	cl_start_soc;
+26 −1
Original line number Diff line number Diff line
@@ -3725,7 +3725,7 @@ static int fg_hw_init(struct fg_chip *chip)
		return rc;
	}

	if (is_debug_batt_id(chip)) {
	if (is_debug_batt_id(chip) || chip->dt.disable_esr_pull_dn) {
		val = ESR_NO_PULL_DOWN;
		rc = fg_masked_write(chip, BATT_INFO_ESR_PULL_DN_CFG(chip),
			ESR_PULL_DOWN_MODE_MASK, val);
@@ -4495,6 +4495,13 @@ static int fg_parse_dt(struct fg_chip *chip)
		chip->dt.esr_timer_asleep[TIMER_MAX] = -EINVAL;
	}

	rc = fg_parse_dt_property_u32_array(node, "qcom,fg-esr-timer-shutdown",
		chip->dt.esr_timer_shutdown, NUM_ESR_TIMERS);
	if (rc < 0) {
		chip->dt.esr_timer_shutdown[TIMER_RETRY] = -EINVAL;
		chip->dt.esr_timer_shutdown[TIMER_MAX] = -EINVAL;
	}

	chip->cyc_ctr.en = of_property_read_bool(node, "qcom,cycle-counter-en");
	if (chip->cyc_ctr.en)
		chip->cyc_ctr.id = 1;
@@ -4630,6 +4637,9 @@ static int fg_parse_dt(struct fg_chip *chip)

	chip->dt.use_esr_sw = of_property_read_bool(node, "qcom,fg-use-sw-esr");

	chip->dt.disable_esr_pull_dn = of_property_read_bool(node,
					"qcom,fg-disable-esr-pull-dn");

	return 0;
}

@@ -4903,6 +4913,20 @@ static int fg_gen3_remove(struct spmi_device *spmi)
	return 0;
}

static void fg_gen3_shutdown(struct spmi_device *spmi)
{
	struct fg_chip *chip = dev_get_drvdata(&spmi->dev);
	int rc;

	rc = fg_set_esr_timer(chip, chip->dt.esr_timer_shutdown[TIMER_RETRY],
				chip->dt.esr_timer_shutdown[TIMER_MAX], false,
				FG_IMA_NO_WLOCK);
	if (rc < 0)
		pr_err("Error in setting ESR timer at shutdown, rc=%d\n", rc);

	fg_cleanup(chip);
}

static const struct of_device_id fg_gen3_match_table[] = {
	{.compatible = FG_GEN3_DEV_NAME},
	{},
@@ -4917,6 +4941,7 @@ static struct spmi_driver fg_gen3_driver = {
	},
	.probe		= fg_gen3_probe,
	.remove		= fg_gen3_remove,
	.shutdown	= fg_gen3_shutdown,
};

static int __init fg_gen3_init(void)