All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boojin Kim <boojin.kim@samsung.com>
To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org
Cc: Vinod Koul <vinod.koul@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Russell King <linux@arm.linux.org.uk>,
	Boojin Kim <boojin.kim@samsung.com>
Subject: [PATCH 01/15] DMA: PL330: Add support runtime PM for PL330 DMAC
Date: Wed, 27 Jul 2011 14:31:23 +0900	[thread overview]
Message-ID: <1311744697-10264-2-git-send-email-boojin.kim@samsung.com> (raw)
In-Reply-To: <1311744697-10264-1-git-send-email-boojin.kim@samsung.com>

Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
---
 drivers/dma/pl330.c |   75 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 6abe1ec..b7ecf47 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/pl330.h>
+#include <linux/pm_runtime.h>
 
 #define NR_DEFAULT_DESC	16
 
@@ -83,6 +84,8 @@ struct dma_pl330_dmac {
 
 	/* Peripheral channels connected to this DMAC */
 	struct dma_pl330_chan peripherals[0]; /* keep at end */
+
+	struct clk *clk;
 };
 
 struct dma_pl330_desc {
@@ -696,6 +699,30 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		goto probe_err1;
 	}
 
+	pdmac->clk = clk_get(&adev->dev, "dma");
+	if (IS_ERR(pdmac->clk)) {
+		dev_err(&adev->dev, "Cannot get operation clock.\n");
+		ret = -EINVAL;
+		goto probe_err1;
+	}
+
+	amba_set_drvdata(adev, pdmac);
+
+#ifdef CONFIG_PM_RUNTIME
+	/* to use the runtime PM helper functions */
+	pm_runtime_enable(&adev->dev);
+
+	/* enable the power domain */
+	if (pm_runtime_get_sync(&adev->dev)) {
+		dev_err(&adev->dev, "failed to get runtime pm\n");
+		ret = -ENODEV;
+		goto probe_err1;
+	}
+#else
+	/* enable dma clk */
+	clk_enable(pdmac->clk);
+#endif
+
 	irq = adev->irq[0];
 	ret = request_irq(irq, pl330_irq_handler, 0,
 			dev_name(&adev->dev), pi);
@@ -763,8 +790,6 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		goto probe_err4;
 	}
 
-	amba_set_drvdata(adev, pdmac);
-
 	dev_info(&adev->dev,
 		"Loaded driver for PL330 DMAC-%d\n", adev->periphid);
 	dev_info(&adev->dev,
@@ -825,6 +850,13 @@ static int __devexit pl330_remove(struct amba_device *adev)
 	res = &adev->res;
 	release_mem_region(res->start, resource_size(res));
 
+#ifdef CONFIG_PM_RUNTIME
+	pm_runtime_put(&adev->dev);
+	pm_runtime_disable(&adev->dev);
+#else
+	clk_disable(pdmac->clk);
+#endif
+
 	kfree(pdmac);
 
 	return 0;
@@ -838,10 +870,49 @@ static struct amba_id pl330_ids[] = {
 	{ 0, 0 },
 };
 
+#ifdef CONFIG_PM_RUNTIME
+static int pl330_runtime_suspend(struct device *dev)
+{
+	struct dma_pl330_dmac *pdmac = dev_get_drvdata(dev);
+
+	if (!pdmac) {
+		dev_err(dev, "failed to get dmac\n");
+		return -ENODEV;
+	}
+
+	clk_disable(pdmac->clk);
+
+	return 0;
+}
+
+static int pl330_runtime_resume(struct device *dev)
+{
+	struct dma_pl330_dmac *pdmac = dev_get_drvdata(dev);
+
+	if (!pdmac) {
+		dev_err(dev, "failed to get dmac\n");
+		return -ENODEV;
+	}
+
+	clk_enable(pdmac->clk);
+
+	return 0;
+}
+#else
+#define pl330_runtime_suspend	NULL
+#define pl330_runtime_resume	NULL
+#endif /* CONFIG_PM_RUNTIME */
+
+static const struct dev_pm_ops pl330_pm_ops = {
+	.runtime_suspend = pl330_runtime_suspend,
+	.runtime_resume = pl330_runtime_resume,
+};
+
 static struct amba_driver pl330_driver = {
 	.drv = {
 		.owner = THIS_MODULE,
 		.name = "dma-pl330",
+		.pm = &pl330_pm_ops,
 	},
 	.id_table = pl330_ids,
 	.probe = pl330_probe,
-- 
1.7.1

WARNING: multiple messages have this Message-ID (diff)
From: boojin.kim@samsung.com (Boojin Kim)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/15] DMA: PL330: Add support runtime PM for PL330 DMAC
Date: Wed, 27 Jul 2011 14:31:23 +0900	[thread overview]
Message-ID: <1311744697-10264-2-git-send-email-boojin.kim@samsung.com> (raw)
In-Reply-To: <1311744697-10264-1-git-send-email-boojin.kim@samsung.com>

Signed-off-by: Boojin Kim <boojin.kim@samsung.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
---
 drivers/dma/pl330.c |   75 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 6abe1ec..b7ecf47 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/pl330.h>
+#include <linux/pm_runtime.h>
 
 #define NR_DEFAULT_DESC	16
 
@@ -83,6 +84,8 @@ struct dma_pl330_dmac {
 
 	/* Peripheral channels connected to this DMAC */
 	struct dma_pl330_chan peripherals[0]; /* keep at end */
+
+	struct clk *clk;
 };
 
 struct dma_pl330_desc {
@@ -696,6 +699,30 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		goto probe_err1;
 	}
 
+	pdmac->clk = clk_get(&adev->dev, "dma");
+	if (IS_ERR(pdmac->clk)) {
+		dev_err(&adev->dev, "Cannot get operation clock.\n");
+		ret = -EINVAL;
+		goto probe_err1;
+	}
+
+	amba_set_drvdata(adev, pdmac);
+
+#ifdef CONFIG_PM_RUNTIME
+	/* to use the runtime PM helper functions */
+	pm_runtime_enable(&adev->dev);
+
+	/* enable the power domain */
+	if (pm_runtime_get_sync(&adev->dev)) {
+		dev_err(&adev->dev, "failed to get runtime pm\n");
+		ret = -ENODEV;
+		goto probe_err1;
+	}
+#else
+	/* enable dma clk */
+	clk_enable(pdmac->clk);
+#endif
+
 	irq = adev->irq[0];
 	ret = request_irq(irq, pl330_irq_handler, 0,
 			dev_name(&adev->dev), pi);
@@ -763,8 +790,6 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 		goto probe_err4;
 	}
 
-	amba_set_drvdata(adev, pdmac);
-
 	dev_info(&adev->dev,
 		"Loaded driver for PL330 DMAC-%d\n", adev->periphid);
 	dev_info(&adev->dev,
@@ -825,6 +850,13 @@ static int __devexit pl330_remove(struct amba_device *adev)
 	res = &adev->res;
 	release_mem_region(res->start, resource_size(res));
 
+#ifdef CONFIG_PM_RUNTIME
+	pm_runtime_put(&adev->dev);
+	pm_runtime_disable(&adev->dev);
+#else
+	clk_disable(pdmac->clk);
+#endif
+
 	kfree(pdmac);
 
 	return 0;
@@ -838,10 +870,49 @@ static struct amba_id pl330_ids[] = {
 	{ 0, 0 },
 };
 
+#ifdef CONFIG_PM_RUNTIME
+static int pl330_runtime_suspend(struct device *dev)
+{
+	struct dma_pl330_dmac *pdmac = dev_get_drvdata(dev);
+
+	if (!pdmac) {
+		dev_err(dev, "failed to get dmac\n");
+		return -ENODEV;
+	}
+
+	clk_disable(pdmac->clk);
+
+	return 0;
+}
+
+static int pl330_runtime_resume(struct device *dev)
+{
+	struct dma_pl330_dmac *pdmac = dev_get_drvdata(dev);
+
+	if (!pdmac) {
+		dev_err(dev, "failed to get dmac\n");
+		return -ENODEV;
+	}
+
+	clk_enable(pdmac->clk);
+
+	return 0;
+}
+#else
+#define pl330_runtime_suspend	NULL
+#define pl330_runtime_resume	NULL
+#endif /* CONFIG_PM_RUNTIME */
+
+static const struct dev_pm_ops pl330_pm_ops = {
+	.runtime_suspend = pl330_runtime_suspend,
+	.runtime_resume = pl330_runtime_resume,
+};
+
 static struct amba_driver pl330_driver = {
 	.drv = {
 		.owner = THIS_MODULE,
 		.name = "dma-pl330",
+		.pm = &pl330_pm_ops,
 	},
 	.id_table = pl330_ids,
 	.probe = pl330_probe,
-- 
1.7.1

  reply	other threads:[~2011-07-27  5:39 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27  5:31 [PATCH V5 00/15] To use DMA generic APIs for Samsung DMA Boojin Kim
2011-07-27  5:31 ` Boojin Kim
2011-07-27  5:31 ` Boojin Kim [this message]
2011-07-27  5:31   ` [PATCH 01/15] DMA: PL330: Add support runtime PM for PL330 DMAC Boojin Kim
2011-07-27  6:14   ` [RFC PATCH] DMA: PL330: Update PL330 DMAC to support runtime PM Chanwoo Choi
2011-07-27  6:14     ` Chanwoo Choi
2011-07-27  7:31     ` Jassi Brar
2011-07-27  7:31       ` Jassi Brar
2011-07-27  8:53     ` Russell King - ARM Linux
2011-07-27  8:53       ` Russell King - ARM Linux
2011-07-27  9:43       ` Chanwoo Choi
2011-07-27  9:43         ` Chanwoo Choi
2011-07-27  7:43   ` [PATCH 01/15] DMA: PL330: Add support runtime PM for PL330 DMAC Jassi Brar
2011-07-27  7:43     ` Jassi Brar
2011-07-27  5:31 ` [PATCH 02/15] DMA: PL330: Update PL330 DMA API driver Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 03/15] DMA: PL330: Support DMA_SLAVE_CONFIG command Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 04/15] DMA: PL330: Add DMA_CYCLIC capability Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 05/15] ARM: SAMSUNG: Update to use PL330-DMA driver Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 06/15] ARM: SAMSUNG: Add common DMA operations Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 07/15] ARM: EXYNOS4: Use generic DMA PL330 driver Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-08-15  9:36   ` Thomas Abraham
2011-08-15  9:36     ` Thomas Abraham
2011-08-15 14:15   ` Thomas Abraham
2011-08-15 14:15     ` Thomas Abraham
2011-08-21  8:51     ` Russell King - ARM Linux
2011-08-21  8:51       ` Russell King - ARM Linux
2011-07-27  5:31 ` [PATCH 08/15] ARM: S5PV210: " Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 09/15] ARM: S5PC100: " Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 10/15] ARM: S5P64X0: " Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 11/15] ARM: SAMSUNG: Remove S3C-PL330-DMA driver Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-07-27  5:31 ` [PATCH 12/15] spi/s3c64xx: Add support DMA engine API Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-08-08 17:47   ` Jassi Brar
2011-08-08 17:47     ` Jassi Brar
2011-08-08 17:55     ` Heiko Stübner
2011-08-08 17:55       ` Heiko Stübner
2011-08-08 18:16       ` Jassi Brar
2011-08-08 18:16         ` Jassi Brar
2011-08-08 18:26         ` Heiko Stübner
2011-08-08 18:26           ` Heiko Stübner
2011-08-09  4:13     ` Alim Akhtar
2011-08-09  4:13       ` Alim Akhtar
2011-08-19 10:30       ` Alim Akhtar
2011-08-19 10:30         ` Alim Akhtar
2011-08-21  8:46       ` Russell King - ARM Linux
2011-08-21  8:46         ` Russell King - ARM Linux
2011-08-25  1:13         ` Alim Akhtar
2011-08-25  1:13           ` Alim Akhtar
2011-08-11  7:42     ` Boojin Kim
2011-08-11  7:42       ` Boojin Kim
2011-07-27  5:31 ` [PATCH 13/15] spi/s3c64xx: Merge dma control code Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-08-08 18:32   ` Jassi Brar
2011-08-08 18:32     ` Jassi Brar
2011-07-27  5:31 ` [PATCH 14/15] ASoC: Samsung: Update DMA interface Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-08-08 19:27   ` Jassi Brar
2011-08-08 19:27     ` Jassi Brar
2011-08-11 10:04     ` Boojin Kim
2011-08-11 10:04       ` Boojin Kim
2011-07-27  5:31 ` [PATCH 15/15] ARM: SAMSUNG: Remove Samsung specific enum type for dma direction Boojin Kim
2011-07-27  5:31   ` Boojin Kim
2011-08-04 16:53 ` [PATCH V5 00/15] To use DMA generic APIs for Samsung DMA Linus Walleij
2011-08-04 16:53   ` Linus Walleij
2011-08-08 16:45   ` Koul, Vinod
2011-08-08 16:45     ` Koul, Vinod
2011-08-11  7:26     ` Kukjin Kim
2011-08-11  7:26       ` Kukjin Kim
2011-08-11 22:27       ` Koul, Vinod
2011-08-11 22:27         ` Koul, Vinod
2011-08-13  4:11         ` Kukjin Kim
2011-08-13  4:11           ` Kukjin Kim
2011-08-16 11:01           ` Koul, Vinod
2011-08-16 11:01             ` Koul, Vinod
2011-08-19  5:24             ` Kukjin Kim
2011-08-19  5:24               ` Kukjin Kim
2011-08-19 13:04               ` Koul, Vinod
2011-08-19 13:04                 ` Koul, Vinod

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311744697-10264-2-git-send-email-boojin.kim@samsung.com \
    --to=boojin.kim@samsung.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dan.j.williams@intel.com \
    --cc=grant.likely@secretlab.ca \
    --cc=jassisinghbrar@gmail.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.