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

Commit 0ed50fb1 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

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



On the PMW3100 wear platform which supports TWM mode, the FG
ESR timer (during TWM) can be increased as the system power
consumption is low. Add support for it by configuring the
ESR timer at shutdown.

Change-Id: I6cb2859437fcbcd1ffb1a73a190f0def86f9deaa
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 2b27e469
Loading
Loading
Loading
Loading
+8 −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>
+1 −0
Original line number Diff line number Diff line
@@ -258,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;
+22 −0
Original line number Diff line number Diff line
@@ -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;
@@ -4906,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},
	{},
@@ -4920,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)