spi/s3c64xx: Convert to dev_pm_ops
Subsystems (3)
PATCH 1/2 spi/s3c64xx: Convert to dev_pm_ops
In preparation for the addition of runtime PM ops.
--- drivers/spi/spi-s3c64xx.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-)
drivers/spi/spi-s3c64xx.c +10 -9
@@ -1226,9 +1226,9 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) }#ifdef CONFIG_PM -static int s3c64xx_spi_suspend (struct platform_device *pdev,pm_message_t state) +static int s3c64xx_spi_suspend (struct device *dev) { -struct spi_master *master =spi_master_get (platform_get_drvdata (pdev)); +struct spi_master *master =spi_master_get (dev_get_drvdata (dev));struct s3c64xx_spi_driver_data *sdd =spi_master_get_devdata (master);unsigned long flags;
@@ -1248,9 +1248,10 @@ static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state)return 0 ; } -static int s3c64xx_spi_resume (struct platform_device *pdev) +static int s3c64xx_spi_resume (struct device *dev) { -struct spi_master *master =spi_master_get (platform_get_drvdata (pdev)); +struct platform_device *pdev =to_platform_device (dev); +struct spi_master *master =spi_master_get (dev_get_drvdata (dev));struct s3c64xx_spi_driver_data *sdd =spi_master_get_devdata (master);struct s3c64xx_spi_info *sci = sdd->cntrlr_info;unsigned long flags;
@@ -1269,19 +1270,19 @@ static int s3c64xx_spi_resume(struct platform_device *pdev) return 0; } -#else -#define s3c64xx_spi_suspend NULL -#define s3c64xx_spi_resume NULL#endif /* CONFIG_PM */ +static struct dev_pm_ops s3c64xx_spi_pm = { +SET_SYSTEM_SLEEP_PM_OPS (s3c64xx_spi_suspend, s3c64xx_spi_resume) +}; +static struct platform_driver s3c64xx_spi_driver = { .driver = { .name ="s3c64xx-spi" , .owner =THIS_MODULE , + .pm = &s3c64xx_spi_pm, }, .remove = s3c64xx_spi_remove, - .suspend = s3c64xx_spi_suspend, - .resume = s3c64xx_spi_resume, };MODULE_ALIAS ("platform:s3c64xx-spi" );
Signature · 1 line
1.7.7.3
PATCH 2/2 spi/s3c64xx: Implement runtime PM support
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.
--- drivers/spi/spi-s3c64xx.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)
drivers/spi/spi-s3c64xx.c +39 -0
@@ -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 = {
Signature · 1 line
1.7.7.3
Re: [PATCH 2/2] spi/s3c64xx: Implement runtime PM support
Quoted 3 lines · 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.
(...)
Quoted 13 lines
drivers/spi/spi-s3c64xx.c +13
-0+#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)
drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_resume(struct device *dev) · line 1310
Quoted 10 lines
drivers/spi/spi-s3c64xx.c +10
-0+{ + 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 */
This is similar to how I'm doing things in my drivers so this looks good to me, Acked-by.
Just wanted to mention that I had this discussion with Magnus Damm about how they do this in shmobile: in there their central runtime PM policy in arch/arm/mach-shmobile/pm_runtime.c adds in the pm_clk_notifier from drivers/base/power/clock_ops.c to gate/ungate the clocks centrally acting on bus notifiers without any per-driver hooks like these.
I clearly see that in this platform it's *not* going to work since for this one driver atleast, there are two clocks, not just one, that need to be managed for the device.
So I guess that some platforms will do central clock management and some will do driver-local management.
I fear for the day one of these devices turn up in two platforms:
one using central clock management and one using distributed clock management ...
Yours,
Linus Walleij
Re: [PATCH 2/2] spi/s3c64xx: Implement runtime PM support
Quoted 6 lines · Linus Walleij
Just wanted to mention that I had this discussion with Magnus Damm about how they do this in shmobile: in there their central runtime PM policy in
arch/arm/mach-shmobile/pm_runtime.cadds in thepm_clk_notifierfromdrivers/base/power/clock_ops.cto gate/ungate the clocks centrally acting on bus notifiers without any per-driver hooks like these.
Yeah, I'm familiar with that - some other platforms were looking into a similar scheme I think.
Quoted 3 lines
I clearly see that in this platform it's *not* going to work since for this one driver atleast, there are two clocks, not just one, that need to be managed for the device.
Well, that's not something that's a blocker to central management - the core can always work with two clocks. What's more of an issue is when devices need to work with their clocks independantly of the core, but that's not insurmountable.
I do also think that if we do decide to move more platforms to central management it's going to be easier to first transition all their drivers to a repetitive style of clock management and then do a big factor out once the pattern is clearly visible. It's a big undertaking for things like the Samsung family of processors where you've got a huge set of chips to work with going all the way back to s3c24xx so anything we can do to make it easier is going to be a win.
A message that is not in the archive (sent off-list or not yet received): 20111205231647.GA21083-yzvPICuk2AATkU/[email protected]
Re: [PATCH 2/2] spi/s3c64xx: Implement runtime PM support
Quoted 4 lines · Mark Brown
I do also think that if we do decide to move more platforms to central management it's going to be easier to first transition all their drivers to a repetitive style of clock management and then do a big factor out once the pattern is clearly visible.
I agree with this. I will go forward in the same manner with Ux500 for the time being.
Thanks,
Linus Walleij
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization This white paper is intended to serve as a reference, checklist and point of discussion for anyone considering optimizing the pricing and packaging model of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
Re: [PATCH 2/2] spi/s3c64xx: Implement runtime PM support
In reply to Mark BrownAm Montag, 5. Dezember 2011, 17:50:13 schrieb Mark Brown:
Quoted 5 lines
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 <[email protected]>
Kgene and/or Grant: could we move this forward, as I would like to profit from this change later on too :-)
Thanks
Heiko
Quoted 105 lines
--- drivers/spi/spi-s3c64xx.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)drivers/spi/spi-s3c64xx.c +39
-0@@ -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 = {
Re: [PATCH 2/2] spi/s3c64xx: Implement runtime PM support
Am Dienstag, 13. Dezember 2011, 15:49:44 schrieb Heiko Stübner:
Quoted 11 lines
Am Montag, 5. Dezember 2011, 17:50:13 schrieb Mark Brown:
Quoted 5 lines
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 <[email protected]>Acked-by Heiko Stuebner <[email protected]Kgene and/or Grant: could we move this forward, as I would like to profit from this change later on too :-)
it seems I got the wrong patch and the one from 2011-12-05 21:01 +0000
[PATCH 3/3] spi/s3c64xx: Implement runtime PM support
which seems to have the same content would have been the correct one to ack and ping.
Sorry for the confusion
Heiko
Quoted 146 lines
Thanks
HeikoQuoted 128 lines
---
drivers/spi/spi-s3c64xx.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)drivers/spi/spi-s3c64xx.c +1
-0@@ -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>drivers/spi/spi-s3c64xx.c +2
-0@@ -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); +drivers/spi/spi-s3c64xx.c +2
-0spin_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,drivers/spi/spi-s3c64xx.c +2
-0@@ -892,6 +897,8 @@ static int s3c64xx_spi_setup(struct spi_device *spi) goto setup_exit; } +pm_runtime_get_sync (&sdd->pdev->dev); +drivers/spi/spi-s3c64xx.c +2
-0/* 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:drivers/spi/spi-s3c64xx.c +2
-0/* 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:
drivers/spi/spi-s3c64xx.c +2
-0@@ -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);drivers/spi/spi-s3c64xx.c +24
-0sdd->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 */ +drivers/spi/spi-s3c64xx.c static int s3c64xx_spi_resume(struct device *dev) · line 1318
Quoted 10 lines
drivers/spi/spi-s3c64xx.c +2
-0static 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 = {--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html