diff mbox

[2/3] i2c: davinci: Add suspend/resume support

Message ID 1260178136-26416-3-git-send-email-chaithrika@ti.com (mailing list archive)
State Superseded
Headers show

Commit Message

chaithrika@ti.com Dec. 7, 2009, 9:28 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 5f3838c..5f0888d 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -623,6 +623,36 @@  static int davinci_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int davinci_i2c_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
+
+	/* put I2C into reset */
+	davinci_i2c_reset_ctrl(dev, 0);
+
+	clk_disable(dev->clk);
+
+	return 0;
+}
+
+static int davinci_i2c_resume(struct platform_device *pdev)
+{
+	struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
+
+	clk_enable(dev->clk);
+
+	/* take I2C out of reset */
+	davinci_i2c_reset_ctrl(dev, 1);
+
+	return 0;
+}
+
+#else
+#define davinci_i2c_suspend NULL
+#define davinci_i2c_resume NULL
+#endif
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:i2c_davinci");
 
@@ -633,6 +663,8 @@  static struct platform_driver davinci_i2c_driver = {
 		.name	= "i2c_davinci",
 		.owner	= THIS_MODULE,
 	},
+	.suspend	= davinci_i2c_suspend,
+	.resume		= davinci_i2c_resume,
 };
 
 /* I2C may be needed to bring up other drivers */