All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Viresh Kumar <viresh.kumar@st.com>,
	pratyush.anand@st.com, rajeev-dlh.kumar@st.com,
	armando.visconti@st.com, bhupesh.sharma@st.com,
	vinod.koul@intel.com, linux-kernel@vger.kernel.org,
	vipin.kumar@st.com, shiraz.hashim@st.com, amit.virdi@st.com,
	vipulkumar.samar@st.com, viresh.linux@gmail.com,
	deepak.sikri@st.com, dan.j.williams@intel.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 07/18] dmaengine/amba-pl08x: Enable/Disable amba_pclk with channel requests
Date: Wed, 3 Aug 2011 13:55:24 +0100	[thread overview]
Message-ID: <20110803125524.GC23953@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CACRpkdZTsD=7woN1qV-sFpsJTyT0LQBq+q=xTOwuewAk=ijBjQ@mail.gmail.com>

On Tue, Aug 02, 2011 at 11:05:38AM +0200, Linus Walleij wrote:
> On Sun, Jul 31, 2011 at 7:04 PM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > On Sun, Jul 31, 2011 at 02:04:47AM +0200, Linus Walleij wrote:
> >>
> >> ..and while it will just cause some double refcounts on the clock,
> >> it makes sense to delete the pclk manipulation from the PL022
> >> driver code as part of the patch, like this:
> >
> > Yes, this looks fine.  Shall I wrap it up as part of my patch?
> 
> Yes please.
> Acked-by.

Can you give this a try - this adds runtime PM to the primecell core,
updates the SPI driver for those changes, and adds runtime PM to the
MMCI driver.  I've briefly tested this on Versatile PB926, though
obviously not the SPI stuff very much because Versatile has no SPI
peripherals.

I chose the PCI methodology to this - rather than having every driver
fiddle about with enabling runtime PM, that's dealt with in the core
and instead, drivers just do a put() in their probe and a balancing
get() in their remove function to activate runtime PM for the device.

Thanks.

 drivers/amba/bus.c      |   57 +++++++++++++++++++++++++++++++--
 drivers/mmc/host/mmci.c |   12 +++++++
 drivers/spi/spi-pl022.c |   80 ++++++++++++++++++++++++++++-------------------
 3 files changed, 114 insertions(+), 35 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index d74926e..84bdaac 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -365,6 +365,40 @@ static int amba_pm_restore_noirq(struct device *dev)
 
 #endif /* !CONFIG_HIBERNATE_CALLBACKS */
 
+#ifdef CONFIG_PM_RUNTIME
+/*
+ * Hooks to provide runtime PM of the pclk (bus clock).  It is safe to
+ * enable/disable the bus clock at runtime PM suspend/resume as this
+ * does not result in loss of context.  However, disabling vcore power
+ * would do, so we leave that to the driver.
+ */
+static int amba_pm_runtime_suspend(struct device *dev)
+{
+	struct amba_device *pcdev = to_amba_device(dev);
+	int ret = pm_generic_runtime_suspend(dev);
+
+	if (ret == 0 && dev->driver)
+		clk_disable(pcdev->pclk);
+
+	return ret;
+}
+
+static int amba_pm_runtime_resume(struct device *dev)
+{
+	struct amba_device *pcdev = to_amba_device(dev);
+	int ret;
+
+	if (dev->driver) {
+		ret = clk_enable(pcdev->pclk);
+		/* Failure is probably fatal to the system, but... */
+		if (ret)
+			return ret;
+	}
+
+	return pm_generic_runtime_resume(dev);
+}
+#endif
+
 #ifdef CONFIG_PM
 
 static const struct dev_pm_ops amba_pm = {
@@ -383,8 +417,8 @@ static const struct dev_pm_ops amba_pm = {
 	.poweroff_noirq	= amba_pm_poweroff_noirq,
 	.restore_noirq	= amba_pm_restore_noirq,
 	SET_RUNTIME_PM_OPS(
-		pm_generic_runtime_suspend,
-		pm_generic_runtime_resume,
+		amba_pm_runtime_suspend,
+		amba_pm_runtime_resume,
 		pm_generic_runtime_idle
 	)
 };
@@ -494,10 +528,18 @@ static int amba_probe(struct device *dev)
 		if (ret)
 			break;
 
+		pm_runtime_get_noresume(dev);
+		pm_runtime_set_active(dev);
+		pm_runtime_enable(dev);
+
 		ret = pcdrv->probe(pcdev, id);
 		if (ret == 0)
 			break;
 
+		pm_runtime_disable(dev);
+		pm_runtime_set_suspended(dev);
+		pm_runtime_put_noidle(dev);
+
 		amba_put_disable_pclk(pcdev);
 		amba_put_disable_vcore(pcdev);
 	} while (0);
@@ -509,7 +551,16 @@ static int amba_remove(struct device *dev)
 {
 	struct amba_device *pcdev = to_amba_device(dev);
 	struct amba_driver *drv = to_amba_driver(dev->driver);
-	int ret = drv->remove(pcdev);
+	int ret;
+
+	pm_runtime_get_sync(dev);
+	ret = drv->remove(pcdev);
+	pm_runtime_put_noidle(dev);
+
+	/* Undo the runtime PM settings in amba_probe() */
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
+	pm_runtime_put_noidle(dev);
 
 	amba_put_disable_pclk(pcdev);
 	amba_put_disable_vcore(pcdev);
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 56e9a41..5e142b7 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -29,6 +29,7 @@
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/amba/mmci.h>
+#include <linux/pm_runtime.h>
 
 #include <asm/div64.h>
 #include <asm/io.h>
@@ -170,6 +171,7 @@ mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
 	 * back into the driver...
 	 */
 	spin_unlock(&host->lock);
+	pm_runtime_put(mmc_dev(host->mmc));
 	mmc_request_done(host->mmc, mrq);
 	spin_lock(&host->lock);
 }
@@ -984,6 +986,8 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		return;
 	}
 
+	pm_runtime_get_sync(mmc_dev(mmc));
+
 	spin_lock_irqsave(&host->lock, flags);
 
 	host->mrq = mrq;
@@ -1327,6 +1331,8 @@ static int __devinit mmci_probe(struct amba_device *dev,
 
 	mmci_dma_setup(host);
 
+	pm_runtime_put(&dev->dev);
+
 	mmc_add_host(mmc);
 
 	return 0;
@@ -1364,6 +1370,12 @@ static int __devexit mmci_remove(struct amba_device *dev)
 	if (mmc) {
 		struct mmci_host *host = mmc_priv(mmc);
 
+		/*
+		 * Undo pm_runtime_put() in probe.  We use the _sync
+		 * version here so that we can access the primecell.
+		 */
+		pm_runtime_get_sync(&dev->dev);
+
 		mmc_remove_host(mmc);
 
 		writel(0, host->base + MMCIMASK0);
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index eba88c7..9f1e927 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -515,9 +515,6 @@ static void giveback(struct pl022 *pl022)
 	if (msg->complete)
 		msg->complete(msg->context);
 	/* This message is completed, so let's turn off the clocks & power */
-	clk_disable(pl022->clk);
-	amba_pclk_disable(pl022->adev);
-	amba_vcore_disable(pl022->adev);
 	pm_runtime_put(&pl022->adev->dev);
 }
 
@@ -1545,9 +1542,6 @@ static void pump_messages(struct work_struct *work)
 	 * (poll/interrupt/DMA)
 	 */
 	pm_runtime_get_sync(&pl022->adev->dev);
-	amba_vcore_enable(pl022->adev);
-	amba_pclk_enable(pl022->adev);
-	clk_enable(pl022->clk);
 	restore_state(pl022);
 	flush(pl022);
 
@@ -2186,8 +2180,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	}
 	printk(KERN_INFO "pl022: mapped registers from 0x%08x to %p\n",
 	       adev->res.start, pl022->virtbase);
-	pm_runtime_enable(dev);
-	pm_runtime_resume(dev);
 
 	pl022->clk = clk_get(&adev->dev, NULL);
 	if (IS_ERR(pl022->clk)) {
@@ -2195,7 +2187,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
 		goto err_no_clk;
 	}
-
 	/* Disable SSP */
 	writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)),
 	       SSP_CR1(pl022->virtbase));
@@ -2235,12 +2226,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 		goto err_spi_register;
 	}
 	dev_dbg(dev, "probe succeeded\n");
-	/*
-	 * Disable the silicon block pclk and any voltage domain and just
-	 * power it up and clock it when it's needed
-	 */
-	amba_pclk_disable(adev);
-	amba_vcore_disable(adev);
+
+	/* let runtime pm put suspend */
+	pm_runtime_put(dev);
 	return 0;
 
  err_spi_register:
@@ -2249,7 +2237,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	destroy_queue(pl022);
 	pl022_dma_remove(pl022);
 	free_irq(adev->irq[0], pl022);
-	pm_runtime_disable(&adev->dev);
  err_no_irq:
 	clk_put(pl022->clk);
  err_no_clk:
@@ -2271,6 +2258,12 @@ pl022_remove(struct amba_device *adev)
 	if (!pl022)
 		return 0;
 
+	/*
+	 * undo pm_runtime_put() in probe.  I assume that we're not
+	 * accessing the primecell here.
+	 */
+	pm_runtime_get_noresume(&adev->dev);
+
 	/* Remove the queue */
 	status = destroy_queue(pl022);
 	if (status != 0) {
@@ -2293,10 +2286,10 @@ pl022_remove(struct amba_device *adev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int pl022_suspend(struct amba_device *adev, pm_message_t state)
+#ifdef CONFIG_SUSPEND
+static int pl011_suspend(struct device *dev)
 {
-	struct pl022 *pl022 = amba_get_drvdata(adev);
+	struct pl022 *pl022 = dev_get_drvdata(dev);
 	int status = 0;
 
 	status = stop_queue(pl022);
@@ -2305,34 +2298,58 @@ static int pl022_suspend(struct amba_device *adev, pm_message_t state)
 		return status;
 	}
 
-	amba_vcore_enable(adev);
-	amba_pclk_enable(adev);
+	amba_vcore_enable(pl022->adev);
+	amba_pclk_enable(pl022->adev);
 	load_ssp_default_config(pl022);
-	amba_pclk_disable(adev);
-	amba_vcore_disable(adev);
+	amba_pclk_disable(pl022->adev);
+	amba_vcore_disable(pl022->adev);
 	dev_dbg(&adev->dev, "suspended\n");
 	return 0;
 }
 
-static int pl022_resume(struct amba_device *adev)
+static int pl022_resume(struct device *dev)
 {
-	struct pl022 *pl022 = amba_get_drvdata(adev);
+	struct pl022 *pl022 = dev_get_drvdata(dev);
 	int status = 0;
 
 	/* Start the queue running */
 	status = start_queue(pl022);
 	if (status)
-		dev_err(&adev->dev, "problem starting queue (%d)\n", status);
+		dev_err(dev, "problem starting queue (%d)\n", status);
 	else
-		dev_dbg(&adev->dev, "resumed\n");
+		dev_dbg(dev, "resumed\n");
 
 	return status;
 }
-#else
-#define pl022_suspend NULL
-#define pl022_resume NULL
 #endif	/* CONFIG_PM */
 
+#ifdef CONFIG_PM_RUNTIME
+static int pl022_runtime_suspend(struct device *dev)
+{
+	struct pl022 *pl022 = dev_get_drvdata(dev);
+
+	clk_disable(pl022->clk);
+	amba_vcore_disable(pl022->adev);
+
+	return 0;
+}
+
+static int pl022_runtime_resume(struct device *dev)
+{
+	struct pl022 *pl022 = dev_get_drvdata(dev);
+
+	amba_vcore_enable(pl022->adev);
+	clk_enable(pl022->clk);
+
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops pl022_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
+	SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
+};
+
 static struct vendor_data vendor_arm = {
 	.fifodepth = 8,
 	.max_bpw = 16,
@@ -2412,12 +2429,11 @@ static struct amba_id pl022_ids[] = {
 static struct amba_driver pl022_driver = {
 	.drv = {
 		.name	= "ssp-pl022",
+		.pm	= &pl022_dev_pm_ops,
 	},
 	.id_table	= pl022_ids,
 	.probe		= pl022_probe,
 	.remove		= __devexit_p(pl022_remove),
-	.suspend        = pl022_suspend,
-	.resume         = pl022_resume,
 };
 
 

WARNING: multiple messages have this Message-ID (diff)
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/18] dmaengine/amba-pl08x: Enable/Disable amba_pclk with channel requests
Date: Wed, 3 Aug 2011 13:55:24 +0100	[thread overview]
Message-ID: <20110803125524.GC23953@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CACRpkdZTsD=7woN1qV-sFpsJTyT0LQBq+q=xTOwuewAk=ijBjQ@mail.gmail.com>

On Tue, Aug 02, 2011 at 11:05:38AM +0200, Linus Walleij wrote:
> On Sun, Jul 31, 2011 at 7:04 PM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > On Sun, Jul 31, 2011 at 02:04:47AM +0200, Linus Walleij wrote:
> >>
> >> ..and while it will just cause some double refcounts on the clock,
> >> it makes sense to delete the pclk manipulation from the PL022
> >> driver code as part of the patch, like this:
> >
> > Yes, this looks fine. ?Shall I wrap it up as part of my patch?
> 
> Yes please.
> Acked-by.

Can you give this a try - this adds runtime PM to the primecell core,
updates the SPI driver for those changes, and adds runtime PM to the
MMCI driver.  I've briefly tested this on Versatile PB926, though
obviously not the SPI stuff very much because Versatile has no SPI
peripherals.

I chose the PCI methodology to this - rather than having every driver
fiddle about with enabling runtime PM, that's dealt with in the core
and instead, drivers just do a put() in their probe and a balancing
get() in their remove function to activate runtime PM for the device.

Thanks.

 drivers/amba/bus.c      |   57 +++++++++++++++++++++++++++++++--
 drivers/mmc/host/mmci.c |   12 +++++++
 drivers/spi/spi-pl022.c |   80 ++++++++++++++++++++++++++++-------------------
 3 files changed, 114 insertions(+), 35 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index d74926e..84bdaac 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -365,6 +365,40 @@ static int amba_pm_restore_noirq(struct device *dev)
 
 #endif /* !CONFIG_HIBERNATE_CALLBACKS */
 
+#ifdef CONFIG_PM_RUNTIME
+/*
+ * Hooks to provide runtime PM of the pclk (bus clock).  It is safe to
+ * enable/disable the bus clock at runtime PM suspend/resume as this
+ * does not result in loss of context.  However, disabling vcore power
+ * would do, so we leave that to the driver.
+ */
+static int amba_pm_runtime_suspend(struct device *dev)
+{
+	struct amba_device *pcdev = to_amba_device(dev);
+	int ret = pm_generic_runtime_suspend(dev);
+
+	if (ret == 0 && dev->driver)
+		clk_disable(pcdev->pclk);
+
+	return ret;
+}
+
+static int amba_pm_runtime_resume(struct device *dev)
+{
+	struct amba_device *pcdev = to_amba_device(dev);
+	int ret;
+
+	if (dev->driver) {
+		ret = clk_enable(pcdev->pclk);
+		/* Failure is probably fatal to the system, but... */
+		if (ret)
+			return ret;
+	}
+
+	return pm_generic_runtime_resume(dev);
+}
+#endif
+
 #ifdef CONFIG_PM
 
 static const struct dev_pm_ops amba_pm = {
@@ -383,8 +417,8 @@ static const struct dev_pm_ops amba_pm = {
 	.poweroff_noirq	= amba_pm_poweroff_noirq,
 	.restore_noirq	= amba_pm_restore_noirq,
 	SET_RUNTIME_PM_OPS(
-		pm_generic_runtime_suspend,
-		pm_generic_runtime_resume,
+		amba_pm_runtime_suspend,
+		amba_pm_runtime_resume,
 		pm_generic_runtime_idle
 	)
 };
@@ -494,10 +528,18 @@ static int amba_probe(struct device *dev)
 		if (ret)
 			break;
 
+		pm_runtime_get_noresume(dev);
+		pm_runtime_set_active(dev);
+		pm_runtime_enable(dev);
+
 		ret = pcdrv->probe(pcdev, id);
 		if (ret == 0)
 			break;
 
+		pm_runtime_disable(dev);
+		pm_runtime_set_suspended(dev);
+		pm_runtime_put_noidle(dev);
+
 		amba_put_disable_pclk(pcdev);
 		amba_put_disable_vcore(pcdev);
 	} while (0);
@@ -509,7 +551,16 @@ static int amba_remove(struct device *dev)
 {
 	struct amba_device *pcdev = to_amba_device(dev);
 	struct amba_driver *drv = to_amba_driver(dev->driver);
-	int ret = drv->remove(pcdev);
+	int ret;
+
+	pm_runtime_get_sync(dev);
+	ret = drv->remove(pcdev);
+	pm_runtime_put_noidle(dev);
+
+	/* Undo the runtime PM settings in amba_probe() */
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
+	pm_runtime_put_noidle(dev);
 
 	amba_put_disable_pclk(pcdev);
 	amba_put_disable_vcore(pcdev);
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 56e9a41..5e142b7 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -29,6 +29,7 @@
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/amba/mmci.h>
+#include <linux/pm_runtime.h>
 
 #include <asm/div64.h>
 #include <asm/io.h>
@@ -170,6 +171,7 @@ mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
 	 * back into the driver...
 	 */
 	spin_unlock(&host->lock);
+	pm_runtime_put(mmc_dev(host->mmc));
 	mmc_request_done(host->mmc, mrq);
 	spin_lock(&host->lock);
 }
@@ -984,6 +986,8 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		return;
 	}
 
+	pm_runtime_get_sync(mmc_dev(mmc));
+
 	spin_lock_irqsave(&host->lock, flags);
 
 	host->mrq = mrq;
@@ -1327,6 +1331,8 @@ static int __devinit mmci_probe(struct amba_device *dev,
 
 	mmci_dma_setup(host);
 
+	pm_runtime_put(&dev->dev);
+
 	mmc_add_host(mmc);
 
 	return 0;
@@ -1364,6 +1370,12 @@ static int __devexit mmci_remove(struct amba_device *dev)
 	if (mmc) {
 		struct mmci_host *host = mmc_priv(mmc);
 
+		/*
+		 * Undo pm_runtime_put() in probe.  We use the _sync
+		 * version here so that we can access the primecell.
+		 */
+		pm_runtime_get_sync(&dev->dev);
+
 		mmc_remove_host(mmc);
 
 		writel(0, host->base + MMCIMASK0);
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index eba88c7..9f1e927 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -515,9 +515,6 @@ static void giveback(struct pl022 *pl022)
 	if (msg->complete)
 		msg->complete(msg->context);
 	/* This message is completed, so let's turn off the clocks & power */
-	clk_disable(pl022->clk);
-	amba_pclk_disable(pl022->adev);
-	amba_vcore_disable(pl022->adev);
 	pm_runtime_put(&pl022->adev->dev);
 }
 
@@ -1545,9 +1542,6 @@ static void pump_messages(struct work_struct *work)
 	 * (poll/interrupt/DMA)
 	 */
 	pm_runtime_get_sync(&pl022->adev->dev);
-	amba_vcore_enable(pl022->adev);
-	amba_pclk_enable(pl022->adev);
-	clk_enable(pl022->clk);
 	restore_state(pl022);
 	flush(pl022);
 
@@ -2186,8 +2180,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	}
 	printk(KERN_INFO "pl022: mapped registers from 0x%08x to %p\n",
 	       adev->res.start, pl022->virtbase);
-	pm_runtime_enable(dev);
-	pm_runtime_resume(dev);
 
 	pl022->clk = clk_get(&adev->dev, NULL);
 	if (IS_ERR(pl022->clk)) {
@@ -2195,7 +2187,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 		dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
 		goto err_no_clk;
 	}
-
 	/* Disable SSP */
 	writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)),
 	       SSP_CR1(pl022->virtbase));
@@ -2235,12 +2226,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 		goto err_spi_register;
 	}
 	dev_dbg(dev, "probe succeeded\n");
-	/*
-	 * Disable the silicon block pclk and any voltage domain and just
-	 * power it up and clock it when it's needed
-	 */
-	amba_pclk_disable(adev);
-	amba_vcore_disable(adev);
+
+	/* let runtime pm put suspend */
+	pm_runtime_put(dev);
 	return 0;
 
  err_spi_register:
@@ -2249,7 +2237,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 	destroy_queue(pl022);
 	pl022_dma_remove(pl022);
 	free_irq(adev->irq[0], pl022);
-	pm_runtime_disable(&adev->dev);
  err_no_irq:
 	clk_put(pl022->clk);
  err_no_clk:
@@ -2271,6 +2258,12 @@ pl022_remove(struct amba_device *adev)
 	if (!pl022)
 		return 0;
 
+	/*
+	 * undo pm_runtime_put() in probe.  I assume that we're not
+	 * accessing the primecell here.
+	 */
+	pm_runtime_get_noresume(&adev->dev);
+
 	/* Remove the queue */
 	status = destroy_queue(pl022);
 	if (status != 0) {
@@ -2293,10 +2286,10 @@ pl022_remove(struct amba_device *adev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int pl022_suspend(struct amba_device *adev, pm_message_t state)
+#ifdef CONFIG_SUSPEND
+static int pl011_suspend(struct device *dev)
 {
-	struct pl022 *pl022 = amba_get_drvdata(adev);
+	struct pl022 *pl022 = dev_get_drvdata(dev);
 	int status = 0;
 
 	status = stop_queue(pl022);
@@ -2305,34 +2298,58 @@ static int pl022_suspend(struct amba_device *adev, pm_message_t state)
 		return status;
 	}
 
-	amba_vcore_enable(adev);
-	amba_pclk_enable(adev);
+	amba_vcore_enable(pl022->adev);
+	amba_pclk_enable(pl022->adev);
 	load_ssp_default_config(pl022);
-	amba_pclk_disable(adev);
-	amba_vcore_disable(adev);
+	amba_pclk_disable(pl022->adev);
+	amba_vcore_disable(pl022->adev);
 	dev_dbg(&adev->dev, "suspended\n");
 	return 0;
 }
 
-static int pl022_resume(struct amba_device *adev)
+static int pl022_resume(struct device *dev)
 {
-	struct pl022 *pl022 = amba_get_drvdata(adev);
+	struct pl022 *pl022 = dev_get_drvdata(dev);
 	int status = 0;
 
 	/* Start the queue running */
 	status = start_queue(pl022);
 	if (status)
-		dev_err(&adev->dev, "problem starting queue (%d)\n", status);
+		dev_err(dev, "problem starting queue (%d)\n", status);
 	else
-		dev_dbg(&adev->dev, "resumed\n");
+		dev_dbg(dev, "resumed\n");
 
 	return status;
 }
-#else
-#define pl022_suspend NULL
-#define pl022_resume NULL
 #endif	/* CONFIG_PM */
 
+#ifdef CONFIG_PM_RUNTIME
+static int pl022_runtime_suspend(struct device *dev)
+{
+	struct pl022 *pl022 = dev_get_drvdata(dev);
+
+	clk_disable(pl022->clk);
+	amba_vcore_disable(pl022->adev);
+
+	return 0;
+}
+
+static int pl022_runtime_resume(struct device *dev)
+{
+	struct pl022 *pl022 = dev_get_drvdata(dev);
+
+	amba_vcore_enable(pl022->adev);
+	clk_enable(pl022->clk);
+
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops pl022_dev_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
+	SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
+};
+
 static struct vendor_data vendor_arm = {
 	.fifodepth = 8,
 	.max_bpw = 16,
@@ -2412,12 +2429,11 @@ static struct amba_id pl022_ids[] = {
 static struct amba_driver pl022_driver = {
 	.drv = {
 		.name	= "ssp-pl022",
+		.pm	= &pl022_dev_pm_ops,
 	},
 	.id_table	= pl022_ids,
 	.probe		= pl022_probe,
 	.remove		= __devexit_p(pl022_remove),
-	.suspend        = pl022_suspend,
-	.resume         = pl022_resume,
 };
 
 

  reply	other threads:[~2011-08-03 12:55 UTC|newest]

Thread overview: 204+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 10:49 [PATCH 00/18] dmaengine/amba-pl08x updates Viresh Kumar
2011-07-29 10:49 ` Viresh Kumar
2011-07-29 10:49 ` [PATCH 01/18] ARM: asm/pl080.h: Protect against multiple inclusion of header file Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-30 22:16   ` Linus Walleij
2011-07-30 22:16     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 02/18] dmaengine/amba-pl08x: Resolve formatting issues Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 11:00   ` Russell King - ARM Linux
2011-07-29 11:00     ` Russell King - ARM Linux
2011-07-29 11:21     ` viresh kumar
2011-07-29 11:21       ` viresh kumar
2011-07-29 12:05   ` Koul, Vinod
2011-07-29 12:05     ` Koul, Vinod
2011-07-29 15:25     ` viresh kumar
2011-07-29 15:25       ` viresh kumar
2011-07-29 10:49 ` [PATCH 03/18] dmaengine/amba-pl08x: Complete doc comment for struct pl08x_txd Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 10:49 ` [PATCH 04/18] dmaengine/amba-pl08x: Remove redundant comment and rewrite original Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 12:09   ` Koul, Vinod
2011-07-29 12:09     ` Koul, Vinod
2011-07-29 15:47     ` viresh kumar
2011-07-29 15:47       ` viresh kumar
2011-07-29 16:34       ` Russell King - ARM Linux
2011-07-29 16:34         ` Russell King - ARM Linux
2011-07-30 22:32       ` Linus Walleij
2011-07-30 22:32         ` Linus Walleij
2011-07-30 22:57         ` Russell King - ARM Linux
2011-07-30 22:57           ` Russell King - ARM Linux
2011-07-30 23:37           ` Linus Walleij
2011-07-30 23:37             ` Linus Walleij
2011-07-31  5:51             ` viresh kumar
2011-07-31  5:51               ` viresh kumar
2011-07-31  9:06             ` Russell King - ARM Linux
2011-07-31  9:06               ` Russell King - ARM Linux
2011-07-29 10:49 ` [PATCH 05/18] dmaengine/amba-pl08x: Changing few prints to dev_dbg from dev_info Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-30 22:34   ` Linus Walleij
2011-07-30 22:34     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 06/18] dmaengine/amba-pl08x: Simplify pl08x_ensure_on() Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-30 22:36   ` Linus Walleij
2011-07-30 22:36     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 07/18] dmaengine/amba-pl08x: Enable/Disable amba_pclk with channel requests Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-30 12:07   ` Russell King - ARM Linux
2011-07-30 12:07     ` Russell King - ARM Linux
2011-07-30 13:05     ` Russell King - ARM Linux
2011-07-30 13:05       ` Russell King - ARM Linux
2011-07-30 23:53       ` Linus Walleij
2011-07-30 23:53         ` Linus Walleij
2011-07-31  0:04         ` Linus Walleij
2011-07-31  0:04           ` Linus Walleij
2011-07-31 17:04           ` Russell King - ARM Linux
2011-07-31 17:04             ` Russell King - ARM Linux
2011-08-02  9:05             ` Linus Walleij
2011-08-02  9:05               ` Linus Walleij
2011-08-03 12:55               ` Russell King - ARM Linux [this message]
2011-08-03 12:55                 ` Russell King - ARM Linux
2011-08-09 19:50                 ` Linus Walleij
2011-08-09 19:50                   ` Linus Walleij
2011-07-29 10:49 ` [PATCH 08/18] dmaengine/amba-pl08x: No need to check "ch->signal < 0" Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-31  0:09   ` Linus Walleij
2011-07-31  0:09     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 09/18] dmaengine/amba-pl08x: Schedule tasklet in case of error interrupt Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 12:16   ` Koul, Vinod
2011-07-29 12:16     ` Koul, Vinod
2011-07-29 13:02     ` Russell King - ARM Linux
2011-07-29 13:02       ` Russell King - ARM Linux
2011-07-29 15:30     ` viresh kumar
2011-07-29 15:30       ` viresh kumar
2011-08-04  4:25       ` Koul, Vinod
2011-08-04  4:25         ` Koul, Vinod
2011-08-04  5:54         ` viresh kumar
2011-08-04  5:54           ` viresh kumar
2011-08-04  5:32           ` Koul, Vinod
2011-08-04  5:32             ` Koul, Vinod
2011-08-14  8:29             ` Russell King - ARM Linux
2011-08-14  8:29               ` Russell King - ARM Linux
2011-07-31  0:19   ` Linus Walleij
2011-07-31  0:19     ` Linus Walleij
2011-07-31  5:33     ` viresh kumar
2011-07-31  5:33       ` viresh kumar
2011-07-29 10:49 ` [PATCH 10/18] dmaengine/amba-pl08x: Get rid of pl08x_pre_boundary() Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 11:05   ` Russell King - ARM Linux
2011-07-29 11:05     ` Russell King - ARM Linux
2011-07-29 12:32     ` Koul, Vinod
2011-07-29 12:32       ` Koul, Vinod
2011-07-29 15:58       ` viresh kumar
2011-07-29 15:58         ` viresh kumar
2011-07-29 12:19   ` Koul, Vinod
2011-07-29 12:19     ` Koul, Vinod
2011-07-29 15:40     ` viresh kumar
2011-07-29 15:40       ` viresh kumar
2011-07-31  0:24   ` Linus Walleij
2011-07-31  0:24     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 11/18] dmaengine/amba-pl08x: max_bytes_per_lli is TRANSFER_SIZE * src_width (not MIN(width)) Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-31  0:27   ` Linus Walleij
2011-07-31  0:27     ` Linus Walleij
2011-07-31  9:09     ` Russell King - ARM Linux
2011-07-31  9:09       ` Russell King - ARM Linux
2011-07-29 10:49 ` [PATCH 12/18] dmaengine/amba-pl08x: Add prep_single_byte_llis() routine Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 11:06   ` Russell King - ARM Linux
2011-07-29 11:06     ` Russell King - ARM Linux
2011-07-29 11:30     ` viresh kumar
2011-07-29 11:30       ` viresh kumar
2011-07-29 10:49 ` [PATCH 13/18] dmaengine/amba-pl08x: Align lli_len to max(src.width, dst.width) Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 12:43   ` Koul, Vinod
2011-07-29 12:43     ` Koul, Vinod
2011-07-29 15:39     ` viresh kumar
2011-07-29 15:39       ` viresh kumar
2011-07-31  0:30   ` Linus Walleij
2011-07-31  0:30     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 14/18] dmaengine/amba-pl08x: Choose peripheral bus as master bus Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-31  0:36   ` Linus Walleij
2011-07-31  0:36     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 15/18] dmaengine/amba-pl08x: Pass flow controller information with slave channel data Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 11:10   ` Russell King - ARM Linux
2011-07-29 11:10     ` Russell King - ARM Linux
2011-07-29 11:31     ` viresh kumar
2011-07-29 11:31       ` viresh kumar
2011-07-31  0:40   ` Linus Walleij
2011-07-31  0:40     ` Linus Walleij
2011-07-31  5:36     ` viresh kumar
2011-07-31  5:36       ` viresh kumar
2011-07-29 10:49 ` [PATCH 16/18] dmaengine/amba-pl08x: Add support for sg len greater than one for slave transfers Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-31  0:41   ` Linus Walleij
2011-07-31  0:41     ` Linus Walleij
2011-08-14  8:36   ` Russell King - ARM Linux
2011-08-14  8:36     ` Russell King - ARM Linux
2011-08-15 10:11     ` Linus Walleij
2011-08-15 10:11       ` Linus Walleij
2011-08-18  8:38     ` Viresh Kumar
2011-08-18  8:38       ` Viresh Kumar
2011-08-21  8:33       ` Russell King - ARM Linux
2011-08-21  8:33         ` Russell King - ARM Linux
2011-08-23  4:22         ` Viresh Kumar
2011-08-23  4:22           ` Viresh Kumar
2011-08-23  5:20           ` Koul, Vinod
2011-08-23  5:20             ` Koul, Vinod
2011-08-26  3:41           ` Viresh Kumar
2011-08-26  3:41             ` Viresh Kumar
2011-08-26  8:03             ` Linus Walleij
2011-08-26  8:03               ` Linus Walleij
2011-08-26  8:51               ` Viresh Kumar
2011-08-26  8:51                 ` Viresh Kumar
2011-09-01 10:07                 ` Viresh Kumar
2011-09-01 10:07                   ` Viresh Kumar
2011-09-07 18:42                   ` Koul, Vinod
2011-09-07 18:42                     ` Koul, Vinod
2011-09-07 23:01                     ` Linus Walleij
2011-09-07 23:01                       ` Linus Walleij
2011-09-08  3:50                       ` Viresh Kumar
2011-09-08  3:50                         ` Viresh Kumar
2011-09-08 10:29                         ` Linus Walleij
2011-09-08 10:29                           ` Linus Walleij
2011-09-08 21:54                           ` [PATCH 16/18] dmaengine/ambhe rest oa-pl08x: " Vinod Koul
2011-09-08 21:54                             ` Vinod Koul
2011-09-20  6:19                             ` Vinod Koul
2011-09-20  6:19                               ` Vinod Koul
2011-09-20  6:27                               ` Viresh Kumar
2011-09-20  6:27                                 ` Viresh Kumar
2011-09-20  8:08                                 ` Vinod Koul
2011-09-20  8:08                                   ` Vinod Koul
2011-07-29 10:49 ` [PATCH 17/18] dmaengine/amba-pl08x: Check txd->llis_va before freeing dma_pool Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-31  0:44   ` Linus Walleij
2011-07-31  0:44     ` Linus Walleij
2011-07-29 10:49 ` [PATCH 18/18] dmaengine/amba-pl08x: Call pl08x_free_txd() instead of calling kfree() directly Viresh Kumar
2011-07-29 10:49   ` Viresh Kumar
2011-07-29 11:15   ` Russell King - ARM Linux
2011-07-29 11:15     ` Russell King - ARM Linux
2011-07-29 11:38     ` viresh kumar
2011-07-29 11:38       ` viresh kumar
2011-07-31  0:45   ` Linus Walleij
2011-07-31  0:45     ` Linus Walleij
2011-07-31  5:39     ` viresh kumar
2011-07-31  5:39       ` viresh kumar
2011-07-29 10:57 ` [PATCH 00/18] dmaengine/amba-pl08x updates Russell King - ARM Linux
2011-07-29 10:57   ` Russell King - ARM Linux
2011-07-29 11:14   ` viresh kumar
2011-07-29 11:14     ` viresh kumar
2011-07-29 11:19     ` Russell King - ARM Linux
2011-07-29 11:19       ` Russell King - ARM Linux
2011-07-29 11:23       ` viresh kumar
2011-07-29 11:23         ` viresh kumar
2011-07-29 12:43         ` Russell King - ARM Linux
2011-07-29 12:43           ` Russell King - ARM Linux
2011-07-29 15:22           ` viresh kumar
2011-07-29 15:22             ` viresh kumar
2011-07-29 11:58 ` Koul, Vinod
2011-07-29 11:58   ` Koul, Vinod
2011-08-01  5:30   ` viresh kumar
2011-08-01  5:30     ` viresh kumar

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=20110803125524.GC23953@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=amit.virdi@st.com \
    --cc=armando.visconti@st.com \
    --cc=bhupesh.sharma@st.com \
    --cc=dan.j.williams@intel.com \
    --cc=deepak.sikri@st.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pratyush.anand@st.com \
    --cc=rajeev-dlh.kumar@st.com \
    --cc=shiraz.hashim@st.com \
    --cc=vinod.koul@intel.com \
    --cc=vipin.kumar@st.com \
    --cc=vipulkumar.samar@st.com \
    --cc=viresh.kumar@st.com \
    --cc=viresh.linux@gmail.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.