]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
i2c-s3c2410: Add stub runtime power management
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 21 Jan 2012 13:28:47 +0000 (13:28 +0000)
committerWolfram Sang <w.sang@pengutronix.de>
Wed, 7 Mar 2012 18:06:59 +0000 (19:06 +0100)
Add stub runtime_pm calls which go through the flow of enabling and
disabling but don't actually do anything with the device itself as
there's nothing useful we can do. This provides the core PM framework
with information about when the device is idle, enabling chip wide
power savings.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
drivers/i2c/busses/i2c-s3c2410.c

index e6f982be89a8fa35b4df6a078ef242808bfdecc9..737f7218a32ce5b136af3ecb4156f807f4fd28b8 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
 #include <linux/slab.h>
@@ -564,6 +565,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
        int retry;
        int ret;
 
+       pm_runtime_get_sync(&adap->dev);
        clk_enable(i2c->clk);
 
        for (retry = 0; retry < adap->retries; retry++) {
@@ -572,6 +574,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
 
                if (ret != -EAGAIN) {
                        clk_disable(i2c->clk);
+                       pm_runtime_put_sync(&adap->dev);
                        return ret;
                }
 
@@ -581,6 +584,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
        }
 
        clk_disable(i2c->clk);
+       pm_runtime_put_sync(&adap->dev);
        return -EREMOTEIO;
 }
 
@@ -1013,6 +1017,9 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
        of_i2c_register_devices(&i2c->adap);
        platform_set_drvdata(pdev, i2c);
 
+       pm_runtime_enable(&pdev->dev);
+       pm_runtime_enable(&i2c->adap.dev);
+
        dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
        clk_disable(i2c->clk);
        return 0;
@@ -1047,6 +1054,9 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 {
        struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
 
+       pm_runtime_disable(&i2c->adap.dev);
+       pm_runtime_disable(&pdev->dev);
+
        s3c24xx_i2c_deregister_cpufreq(i2c);
 
        i2c_del_adapter(&i2c->adap);