diff options
author | Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org> | 2010-07-15 09:06:14 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2010-10-21 18:43:27 -0400 |
commit | d2360b8e845ce0e142e72697a504ee9372421dc3 (patch) | |
tree | 36d8af296af35099cf5bea8c0f36bb613260278d /drivers/i2c | |
parent | f6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff) |
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.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index bf831bf81587..3dc1eb9f8088 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, | |||
555 | int retry; | 555 | int retry; |
556 | int ret; | 556 | int ret; |
557 | 557 | ||
558 | clk_enable(i2c->clk); | ||
559 | |||
558 | for (retry = 0; retry < adap->retries; retry++) { | 560 | for (retry = 0; retry < adap->retries; retry++) { |
559 | 561 | ||
560 | ret = s3c24xx_i2c_doxfer(i2c, msgs, num); | 562 | ret = s3c24xx_i2c_doxfer(i2c, msgs, num); |
561 | 563 | ||
562 | if (ret != -EAGAIN) | 564 | if (ret != -EAGAIN) { |
565 | clk_disable(i2c->clk); | ||
563 | return ret; | 566 | return ret; |
567 | } | ||
564 | 568 | ||
565 | dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry); | 569 | dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry); |
566 | 570 | ||
567 | udelay(100); | 571 | udelay(100); |
568 | } | 572 | } |
569 | 573 | ||
574 | clk_disable(i2c->clk); | ||
570 | return -EREMOTEIO; | 575 | return -EREMOTEIO; |
571 | } | 576 | } |
572 | 577 | ||
@@ -911,6 +916,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
911 | platform_set_drvdata(pdev, i2c); | 916 | platform_set_drvdata(pdev, i2c); |
912 | 917 | ||
913 | dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); | 918 | dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); |
919 | clk_disable(i2c->clk); | ||
914 | return 0; | 920 | return 0; |
915 | 921 | ||
916 | err_cpufreq: | 922 | err_cpufreq: |
@@ -978,7 +984,9 @@ static int s3c24xx_i2c_resume(struct device *dev) | |||
978 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); | 984 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); |
979 | 985 | ||
980 | i2c->suspended = 0; | 986 | i2c->suspended = 0; |
987 | clk_enable(i2c->clk); | ||
981 | s3c24xx_i2c_init(i2c); | 988 | s3c24xx_i2c_init(i2c); |
989 | clk_disable(i2c->clk); | ||
982 | 990 | ||
983 | return 0; | 991 | return 0; |
984 | } | 992 | } |