From patchwork Wed Apr 6 23:37:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 65218 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp154063lbc; Wed, 6 Apr 2016 16:38:09 -0700 (PDT) X-Received: by 10.98.34.28 with SMTP id i28mr42349pfi.160.1459985889333; Wed, 06 Apr 2016 16:38:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uj10si7459869pac.79.2016.04.06.16.38.09; Wed, 06 Apr 2016 16:38:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754641AbcDFXhs (ORCPT + 3 others); Wed, 6 Apr 2016 19:37:48 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:52348 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754511AbcDFXhr (ORCPT ); Wed, 6 Apr 2016 19:37:47 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u36NbNjt032071; Wed, 6 Apr 2016 18:37:23 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u36NbNxo021097; Wed, 6 Apr 2016 18:37:23 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Wed, 6 Apr 2016 18:37:23 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u36NbMSc001653; Wed, 6 Apr 2016 18:37:22 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.83.68]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id u36NbM926344; Wed, 6 Apr 2016 18:37:22 -0500 (CDT) From: Suman Anna To: Jassi Brar CC: , , , Suman Anna Subject: [PATCH 2/4] mailbox/omap: add support for suspend/resume Date: Wed, 6 Apr 2016 18:37:18 -0500 Message-ID: <1459985840-1106-3-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1459985840-1106-1-git-send-email-s-anna@ti.com> References: <1459985840-1106-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Support has been added to the OMAP mailbox driver to allow it to work across a system suspend/resume. The OMAP mailbox driver requires only the interrupt configuration registers to be saved and restored, and this is done in the suspend/resume callbacks. The registers need to be saved only if there are active clients at the time of suspend. The enabling and disabling of the mailbox clocks is done automatically by the omap_device layer. Signed-off-by: Suman Anna --- drivers/mailbox/omap-mailbox.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index adf37f494690..1b90eb380d44 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -88,6 +88,7 @@ struct omap_mbox_device { struct device *dev; struct mutex cfg_lock; void __iomem *mbox_base; + u32 *irq_ctx; u32 num_users; u32 num_fifos; u32 intr_type; @@ -650,6 +651,44 @@ static const struct mbox_chan_ops omap_mbox_chan_ops = { .shutdown = omap_mbox_chan_shutdown, }; +#ifdef CONFIG_PM_SLEEP +static int omap_mbox_suspend(struct device *dev) +{ + struct omap_mbox_device *mdev = dev_get_drvdata(dev); + u32 usr, reg; + + if (pm_runtime_status_suspended(dev)) + return 0; + + for (usr = 0; usr < mdev->num_users; usr++) { + reg = MAILBOX_IRQENABLE(mdev->intr_type, usr); + mdev->irq_ctx[usr] = mbox_read_reg(mdev, reg); + } + + return 0; +} + +static int omap_mbox_resume(struct device *dev) +{ + struct omap_mbox_device *mdev = dev_get_drvdata(dev); + u32 usr, reg; + + if (pm_runtime_status_suspended(dev)) + return 0; + + for (usr = 0; usr < mdev->num_users; usr++) { + reg = MAILBOX_IRQENABLE(mdev->intr_type, usr); + mbox_write_reg(mdev, mdev->irq_ctx[usr], reg); + } + + return 0; +} +#endif + +static const struct dev_pm_ops omap_mbox_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume) +}; + static const struct of_device_id omap_mailbox_of_match[] = { { .compatible = "ti,omap2-mailbox", @@ -777,6 +816,11 @@ static int omap_mbox_probe(struct platform_device *pdev) if (IS_ERR(mdev->mbox_base)) return PTR_ERR(mdev->mbox_base); + mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32), + GFP_KERNEL); + if (!mdev->irq_ctx) + return -ENOMEM; + /* allocate one extra for marking end of list */ list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list), GFP_KERNEL); @@ -887,6 +931,7 @@ static struct platform_driver omap_mbox_driver = { .remove = omap_mbox_remove, .driver = { .name = "omap-mailbox", + .pm = &omap_mbox_pm_ops, .of_match_table = of_match_ptr(omap_mailbox_of_match), }, };