i2c: designware: add PM support
authorDeepak Sikri <deepak.sikri@st.com>
Fri, 24 Feb 2012 11:31:15 +0000 (17:01 +0530)
committerWolfram Sang <w.sang@pengutronix.de>
Sat, 12 May 2012 12:28:15 +0000 (14:28 +0200)
This patch adds in support for standby/S2R/hybernate for i2c-designware driver.

Signed-off-by: Deepak Sikri <deepak.sikri@st.com>
Signed-off-by: Rajeev Kumar <rajeev-dlh.kumar@st.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
drivers/i2c/busses/i2c-designware-platdrv.c

index 4ba589ab8614050d65ec1f45d918899a36e3ac0b..f08d0248cf6b4daa264ba3f7fbdb8194195a7a45 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/interrupt.h>
 #include <linux/of_i2c.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/io.h>
 #include <linux/slab.h>
 #include "i2c-designware-core.h"
@@ -198,6 +199,31 @@ static const struct of_device_id dw_i2c_of_match[] = {
 MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
 #endif
 
+#ifdef CONFIG_PM
+static int dw_i2c_suspend(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
+
+       clk_disable(i_dev->clk);
+
+       return 0;
+}
+
+static int dw_i2c_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
+
+       clk_enable(i_dev->clk);
+       i2c_dw_init(i_dev);
+
+       return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(dw_i2c_dev_pm_ops, dw_i2c_suspend, dw_i2c_resume);
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:i2c_designware");
 
@@ -207,6 +233,7 @@ static struct platform_driver dw_i2c_driver = {
                .name   = "i2c_designware",
                .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(dw_i2c_of_match),
+               .pm     = &dw_i2c_dev_pm_ops,
        },
 };
 
This page took 0.025314 seconds and 5 git commands to generate.