From: "Heiko Stübner" <heiko@sntech.de>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>,
Grant Likely <grant.likely@secretlab.ca>,
linux-samsung-soc@vger.kernel.org,
spi-devel-general@lists.sourceforge.net
Subject: Re: [PATCH 2/2] spi/s3c64xx: Implement runtime PM support
Date: Tue, 13 Dec 2011 15:49:44 +0100 [thread overview]
Message-ID: <201112131549.45384.heiko@sntech.de> (raw)
In-Reply-To: <1323103813-5325-2-git-send-email-broonie@opensource.wolfsonmicro.com>
Am Montag, 5. Dezember 2011, 17:50:13 schrieb Mark Brown:
> Enable and disable the clocks to the SPI controller using runtime PM. This
> serves the dual purpose of reducing power consumption a little and letting
> the core know when the device is idle.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Heiko Stuebner <heiko@sntech.de
Kgene and/or Grant: could we move this forward, as I would like to profit from
this change later on too :-)
Thanks
Heiko
> ---
> drivers/spi/spi-s3c64xx.c | 39 +++++++++++++++++++++++++++++++++++++++
> 1 files changed, 39 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index fef1c90..9031783 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -25,6 +25,7 @@
> #include <linux/clk.h>
> #include <linux/dma-mapping.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> #include <linux/spi/spi.h>
>
> #include <mach/dma.h>
> @@ -782,6 +783,8 @@ static void s3c64xx_spi_work(struct work_struct *work)
> while (!acquire_dma(sdd))
> msleep(10);
>
> + pm_runtime_get_sync(&sdd->pdev->dev);
> +
> spin_lock_irqsave(&sdd->lock, flags);
>
> while (!list_empty(&sdd->queue)
> @@ -810,6 +813,8 @@ static void s3c64xx_spi_work(struct work_struct *work)
> /* Free DMA channels */
> sdd->ops->release(sdd->rx_dma.ch, &s3c64xx_spi_dma_client);
> sdd->ops->release(sdd->tx_dma.ch, &s3c64xx_spi_dma_client);
> +
> + pm_runtime_put(&sdd->pdev->dev);
> }
>
> static int s3c64xx_spi_transfer(struct spi_device *spi,
> @@ -892,6 +897,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
> goto setup_exit;
> }
>
> + pm_runtime_get_sync(&sdd->pdev->dev);
> +
> /* Check if we can provide the requested rate */
> if (!sci->clk_from_cmu) {
> u32 psr, speed;
> @@ -924,6 +931,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
> err = -EINVAL;
> }
>
> + pm_runtime_put(&sdd->pdev->dev);
> +
> setup_exit:
>
> /* setup() returns with device de-selected */
> @@ -1159,6 +1168,8 @@ static int __init s3c64xx_spi_probe(struct
> platform_device *pdev) mem_res->end, mem_res->start,
> sdd->rx_dma.dmach, sdd->tx_dma.dmach);
>
> + pm_runtime_enable(&pdev->dev);
> +
> return 0;
>
> err9:
> @@ -1192,6 +1203,8 @@ static int s3c64xx_spi_remove(struct platform_device
> *pdev) struct resource *mem_res;
> unsigned long flags;
>
> + pm_runtime_disable(&pdev->dev);
> +
> spin_lock_irqsave(&sdd->lock, flags);
> sdd->state |= SUSPND;
> spin_unlock_irqrestore(&sdd->lock, flags);
> @@ -1272,8 +1285,34 @@ static int s3c64xx_spi_resume(struct device *dev)
> }
> #endif /* CONFIG_PM */
>
> +#ifdef CONFIG_PM_RUNTIME
> +static int s3c64xx_spi_runtime_suspend(struct device *dev)
> +{
> + struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
> + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
> +
> + clk_disable(sdd->clk);
> + clk_disable(sdd->src_clk);
> +
> + return 0;
> +}
> +
> +static int s3c64xx_spi_runtime_resume(struct device *dev)
> +{
> + struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
> + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
> +
> + clk_enable(sdd->src_clk);
> + clk_enable(sdd->clk);
> +
> + return 0;
> +}
> +#endif /* CONFIG_PM_RUNTIME */
> +
> static struct dev_pm_ops s3c64xx_spi_pm = {
> SET_SYSTEM_SLEEP_PM_OPS(s3c64xx_spi_suspend, s3c64xx_spi_resume)
> + SET_RUNTIME_PM_OPS(s3c64xx_spi_runtime_suspend,
> + s3c64xx_spi_runtime_resume, NULL)
> };
>
> static struct platform_driver s3c64xx_spi_driver = {
next prev parent reply other threads:[~2011-12-13 14:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 16:50 [PATCH 1/2] spi/s3c64xx: Convert to dev_pm_ops Mark Brown
2011-12-05 16:50 ` [PATCH 2/2] spi/s3c64xx: Implement runtime PM support Mark Brown
2011-12-05 21:41 ` Linus Walleij
2011-12-05 23:16 ` Mark Brown
[not found] ` <20111205231647.GA21083-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-12-06 14:05 ` Linus Walleij
2011-12-13 14:49 ` Heiko Stübner [this message]
2011-12-13 15:02 ` Heiko Stübner
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=201112131549.45384.heiko@sntech.de \
--to=heiko@sntech.de \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=grant.likely@secretlab.ca \
--cc=kgene.kim@samsung.com \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=spi-devel-general@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).