From 18dbdda89f5cf0540e577280395f16079308e87d Mon Sep 17 00:00:00 2001 From: Dirk Brandewie Date: Thu, 6 Oct 2011 11:26:36 -0700 Subject: i2c-designware: Add runtime power management support Add runtime power management to the PCI driver. Signed-off-by: Dirk Brandewie Signed-off-by: Ben Dooks --- drivers/i2c/busses/i2c-designware-core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/i2c/busses/i2c-designware-core.c') diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index b9f18dd..df87992 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "i2c-designware-core.h" @@ -501,6 +502,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num); mutex_lock(&dev->lock); + pm_runtime_get_sync(dev->dev); INIT_COMPLETION(dev->cmd_complete); dev->msgs = msgs; @@ -550,6 +552,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) ret = -EIO; done: + pm_runtime_put(dev->dev); mutex_unlock(&dev->lock); return ret; @@ -671,10 +674,13 @@ void i2c_dw_enable(struct dw_i2c_dev *dev) dw_writel(dev, 1, DW_IC_ENABLE); } -void i2c_dw_disable(struct dw_i2c_dev *dev) +u32 i2c_dw_is_enabled(struct dw_i2c_dev *dev) { - int ret; + return dw_readl(dev, DW_IC_ENABLE); +} +void i2c_dw_disable(struct dw_i2c_dev *dev) +{ /* Disable controller */ dw_writel(dev, 0, DW_IC_ENABLE); -- cgit v1.1