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

Commit 561adcb4 authored by Gidon Studinski's avatar Gidon Studinski
Browse files

msm: ipa: add support for AP suspend in ipa driver



When AP suspend is triggered, IPA driver checks whether there are active
clients of IPA. In case there are active clients, postpone the AP suspend
operation for a later time.

Change-Id: Ib00d07c3fa93492aa532bff5b23d93ca557de2ca
Signed-off-by: default avatarGidon Studinski <gidons@codeaurora.org>
parent 9774d5bd
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -3592,11 +3592,59 @@ static int ipa_plat_drv_probe(struct platform_device *pdev_p)
	return result;
}

/**
* ipa_ap_suspend() - suspend callback for runtime_pm
* @dev: pointer to device
*
* This callback will be invoked by the runtime_pm framework when an AP suspend
* operation is invoked, usually by pressing a suspend button.
*
* Returns -EAGAIN to runtime_pm framework in case IPA is in use.
* This will postpone the suspend operation until all IPA clients release
* its resources and clocks can be turned off.
*/
static int ipa_ap_suspend(struct device *dev)
{
	int res = 0;

	IPADBG("Enter...\n");
	/* Do not allow A7 to suspend in case there are active clients of IPA */
	ipa_active_clients_lock();
	if (ipa_ctx->ipa_active_clients.cnt != 0) {
		IPADBG("IPA is in use, postponing AP suspend.\n");
		res = -EAGAIN;
	}
	ipa_active_clients_unlock();
	IPADBG("Exit\n");

	return res;
}

/**
* ipa_ap_resume() - resume callback for runtime_pm
* @dev: pointer to device
*
* This callback will be invoked by the runtime_pm framework when an AP resume
* operation is invoked.
*
* Always returns 0 since resume should always succeed.
*/
static int ipa_ap_resume(struct device *dev)
{
	return 0;
}

static const struct dev_pm_ops ipa_pm_ops = {
	.suspend_noirq = ipa_ap_suspend,
	.resume_noirq = ipa_ap_resume,
};

static struct platform_driver ipa_plat_drv = {
	.probe = ipa_plat_drv_probe,
	.driver = {
		.name = DRV_NAME,
		.owner = THIS_MODULE,
		.pm = &ipa_pm_ops,
		.of_match_table = ipa_plat_drv_match,
	},
};