]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/commitdiff
Merge branch 'mailbox-linux-3.14.y' of git://git.ti.com/rpmsg/mailbox into rproc...
authorSuman Anna <s-anna@ti.com>
Mon, 18 May 2015 01:59:23 +0000 (20:59 -0500)
committerSuman Anna <s-anna@ti.com>
Mon, 18 May 2015 02:02:40 +0000 (21:02 -0500)
Pull in the updated mailbox feature branch into the remoteproc tree,
this includes the suspend/resume support in the OMAP mailbox driver.

* 'mailbox-linux-3.14.y' of git://git.ti.com/rpmsg/mailbox:
  mailbox/omap: check for any unread messages during suspend
  mailbox/omap: add support for suspend/resume
  mailbox/omap: store mailbox interrupt type in omap_mbox_device

Signed-off-by: Suman Anna <s-anna@ti.com>
drivers/mailbox/omap-mailbox.c

index 2a657e715ab55c2588d0f7e6876f3e86a3d89a8a..5a42824766a51e2e3aa9be558b5c282675caa04f 100644 (file)
@@ -96,8 +96,10 @@ 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;
        struct omap_mbox **mboxes;
        struct mbox_controller controller;
        struct list_head elem;
@@ -652,6 +654,52 @@ static 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, fifo, reg;
+
+       if (pm_runtime_status_suspended(dev))
+               return 0;
+
+       for (fifo = 0; fifo < mdev->num_fifos; fifo++) {
+               if (mbox_read_reg(mdev, MAILBOX_MSGSTATUS(fifo))) {
+                       dev_err(mdev->dev, "fifo %d has unexpected unread messages\n",
+                               fifo);
+                       return -EBUSY;
+               }
+       }
+
+       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",
@@ -801,6 +849,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);
@@ -853,6 +906,7 @@ static int omap_mbox_probe(struct platform_device *pdev)
        mdev->dev = &pdev->dev;
        mdev->num_users = num_users;
        mdev->num_fifos = num_fifos;
+       mdev->intr_type  = intr_type;
        mdev->mboxes = list;
 
        /* OMAP does not have a Tx-Done IRQ, but rather a Tx-Ready IRQ */
@@ -911,6 +965,7 @@ static struct platform_driver omap_mbox_driver = {
        .driver = {
                .name = "omap-mailbox",
                .owner = THIS_MODULE,
+               .pm = &omap_mbox_pm_ops,
                .of_match_table = of_match_ptr(omap_mailbox_of_match),
        },
 };