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

Commit ff443ce0 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

power: qpnp-qg: Move GOOD_OCV irq handling to suspend/resume



Disabling the IRQ in the no_irq PM callbacks does not take effect
as the IRQ's are masked post late_suspend. Move the GOOD_OCV
irq handling to suspend/resume callback.

Change-Id: I2bbc2cc18f2b4e28427826d0f0a62e095ce3fe86
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent d77ce925
Loading
Loading
Loading
Loading
+32 −7
Original line number Diff line number Diff line
@@ -3412,9 +3412,6 @@ static int process_suspend(struct qpnp_qg *chip)
		return 0;

	cancel_delayed_work_sync(&chip->ttf->ttf_work);
	/* disable GOOD_OCV IRQ in sleep */
	vote(chip->good_ocv_irq_disable_votable,
			QG_INIT_STATE_IRQ_DISABLE, true, 0);

	chip->suspend_data = false;

@@ -3487,10 +3484,6 @@ static int process_resume(struct qpnp_qg *chip)
	if (!chip->profile_loaded)
		return 0;

	/* enable GOOD_OCV IRQ when awake */
	vote(chip->good_ocv_irq_disable_votable,
			QG_INIT_STATE_IRQ_DISABLE, false, 0);

	rc = qg_read(chip, chip->qg_base + QG_STATUS2_REG, &status2, 1);
	if (rc < 0) {
		pr_err("Failed to read status2 register, rc=%d\n", rc);
@@ -3581,9 +3574,41 @@ static int qpnp_qg_resume_noirq(struct device *dev)
	return 0;
}

static int qpnp_qg_suspend(struct device *dev)
{
	struct qpnp_qg *chip = dev_get_drvdata(dev);

	/* skip if profile is not loaded */
	if (!chip->profile_loaded)
		return 0;

	/* disable GOOD_OCV IRQ in sleep */
	vote(chip->good_ocv_irq_disable_votable,
			QG_INIT_STATE_IRQ_DISABLE, true, 0);

	return 0;
}

static int qpnp_qg_resume(struct device *dev)
{
	struct qpnp_qg *chip = dev_get_drvdata(dev);

	/* skip if profile is not loaded */
	if (!chip->profile_loaded)
		return 0;

	/* enable GOOD_OCV IRQ when active */
	vote(chip->good_ocv_irq_disable_votable,
			QG_INIT_STATE_IRQ_DISABLE, false, 0);

	return 0;
}

static const struct dev_pm_ops qpnp_qg_pm_ops = {
	.suspend_noirq	= qpnp_qg_suspend_noirq,
	.resume_noirq	= qpnp_qg_resume_noirq,
	.suspend	= qpnp_qg_suspend,
	.resume		= qpnp_qg_resume,
};

static int qpnp_qg_probe(struct platform_device *pdev)