aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2013-01-17 05:31:06 -0500
committerWolfram Sang <w.sang@pengutronix.de>2013-01-27 23:26:42 -0500
commit7272194ed391f9db8bb320c50d715e7e6bba8ff3 (patch)
treeff8aa304c2d9d345b961d6d91f9460d5957b68a1
parent17a76b4b32aca7c19df6988213dfe2eb4b631431 (diff)
i2c-designware: add minimal support for runtime PM
In order to save power the device should be put to low power states whenever it is not being used. We implement this by enabling minimal runtime PM support. There isn't much to do for the device itself as it is disabled once the last transfer is completed but subsystem/domain runtime PM hooks can save more power by power gating the device etc. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 343357a2b5b4..d8afc85420be 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -37,6 +37,7 @@
37#include <linux/of_i2c.h> 37#include <linux/of_i2c.h>
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/pm.h> 39#include <linux/pm.h>
40#include <linux/pm_runtime.h>
40#include <linux/io.h> 41#include <linux/io.h>
41#include <linux/slab.h> 42#include <linux/slab.h>
42#include "i2c-designware-core.h" 43#include "i2c-designware-core.h"
@@ -149,6 +150,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
149 } 150 }
150 of_i2c_register_devices(adap); 151 of_i2c_register_devices(adap);
151 152
153 pm_runtime_set_active(&pdev->dev);
154 pm_runtime_enable(&pdev->dev);
155 pm_runtime_put(&pdev->dev);
156
152 return 0; 157 return 0;
153 158
154err_free_irq: 159err_free_irq:
@@ -175,6 +180,8 @@ static int dw_i2c_remove(struct platform_device *pdev)
175 struct resource *mem; 180 struct resource *mem;
176 181
177 platform_set_drvdata(pdev, NULL); 182 platform_set_drvdata(pdev, NULL);
183 pm_runtime_get_sync(&pdev->dev);
184
178 i2c_del_adapter(&dev->adapter); 185 i2c_del_adapter(&dev->adapter);
179 put_device(&pdev->dev); 186 put_device(&pdev->dev);
180 187
@@ -186,6 +193,9 @@ static int dw_i2c_remove(struct platform_device *pdev)
186 free_irq(dev->irq, dev); 193 free_irq(dev->irq, dev);
187 kfree(dev); 194 kfree(dev);
188 195
196 pm_runtime_put(&pdev->dev);
197 pm_runtime_disable(&pdev->dev);
198
189 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 199 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
190 release_mem_region(mem->start, resource_size(mem)); 200 release_mem_region(mem->start, resource_size(mem));
191 return 0; 201 return 0;