summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorArnaud Patard (Rtp) <arnaud.patard@rtp-net.org>2010-07-15 13:06:14 (GMT)
committerBen Dooks <ben-linux@fluff.org>2010-10-21 22:43:27 (GMT)
commitd2360b8e845ce0e142e72697a504ee9372421dc3 (patch)
tree36d8af296af35099cf5bea8c0f36bb613260278d /drivers/i2c
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff)
downloadlinux-d2360b8e845ce0e142e72697a504ee9372421dc3.tar.xz
i2c-s3c2410: Enable i2c clock only when doing some transfert
This patch modify the s3c2410 i2c driver behaviour to enable the i2c clock only when needed. I'm not sure if this has a big impact on power usage but at least it's fixing a bug with the uda1380 codec which needs to be hard reset'ed if the i2c clock is enabled before it's powered on (at least on h1940). Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index bf831bf..3dc1eb9 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -555,18 +555,23 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
int retry;
int ret;
+ clk_enable(i2c->clk);
+
for (retry = 0; retry < adap->retries; retry++) {
ret = s3c24xx_i2c_doxfer(i2c, msgs, num);
- if (ret != -EAGAIN)
+ if (ret != -EAGAIN) {
+ clk_disable(i2c->clk);
return ret;
+ }
dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry);
udelay(100);
}
+ clk_disable(i2c->clk);
return -EREMOTEIO;
}
@@ -911,6 +916,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c);
dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
+ clk_disable(i2c->clk);
return 0;
err_cpufreq:
@@ -978,7 +984,9 @@ static int s3c24xx_i2c_resume(struct device *dev)
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
i2c->suspended = 0;
+ clk_enable(i2c->clk);
s3c24xx_i2c_init(i2c);
+ clk_disable(i2c->clk);
return 0;
}