@@ -28,6 +28,7 @@
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/err.h>
+#include <linux/pm_runtime.h>
#include <linux/clk.h>
#include <linux/io.h>
@@ -165,6 +166,9 @@ static void activate_ch(struct sh_mobile
u_int32_t denom;
u_int32_t tmp;
+ /* Runtime PM must wake up device */
+ pm_runtime_resume(pd->dev);
+
/* Make sure the clock is enabled */
clk_enable(pd->clk);
@@ -215,6 +219,9 @@ static void deactivate_ch(struct sh_mobi
/* Disable clock */
clk_disable(pd->clk);
+
+ /* Runtime PM code may suspend now */
+ pm_runtime_suspend(pd->dev);
}
static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
@@ -572,6 +579,20 @@ static int sh_mobile_i2c_probe(struct pl
goto err_irq;
}
+ /* Enable Runtime PM for this device.
+ *
+ * Also tell the Runtime PM core to ignore children
+ * for this device since it is valid for us to suspend
+ * this I2C master driver even though the slave devices
+ * on the I2C bus may not be suspended.
+ *
+ * The state of the I2C hardware bus is unaffected by
+ * the Runtime PM state.
+ */
+ pm_suspend_ignore_children(&dev->dev, true);
+ pm_runtime_set_suspended(&dev->dev);
+ pm_runtime_enable(&dev->dev);
+
/* setup the private data */
adap = &pd->adap;
i2c_set_adapdata(adap, pd);