linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 1/1] i2c-s3c2410: Enable i2c clock only when doing some transfert
@ 2010-07-15 13:06 Arnaud Patard
  2010-07-23  9:02 ` Vasily Khoruzhick
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaud Patard @ 2010-07-15 13:06 UTC (permalink / raw)
  To: ben-linux; +Cc: linux-i2c, linux-samsung-soc

[-- Attachment #1: i2c_enable_clock_only_on_transfert.patch --]
[-- Type: text/plain, Size: 1330 bytes --]

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>

Index: linux-2.6/drivers/i2c/busses/i2c-s3c2410.c
===================================================================
--- linux-2.6.orig/drivers/i2c/busses/i2c-s3c2410.c	2010-07-03 22:47:14.473885834 +0200
+++ linux-2.6/drivers/i2c/busses/i2c-s3c2410.c	2010-07-03 22:48:43.261886656 +0200
@@ -555,18 +555,23 @@ static int s3c24xx_i2c_xfer(struct i2c_a
 	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 plat
 	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:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/1] i2c-s3c2410: Enable i2c clock only when doing some transfert
  2010-07-15 13:06 [patch 1/1] i2c-s3c2410: Enable i2c clock only when doing some transfert Arnaud Patard
@ 2010-07-23  9:02 ` Vasily Khoruzhick
  2010-08-27 19:33   ` Vasily Khoruzhick
  0 siblings, 1 reply; 4+ messages in thread
From: Vasily Khoruzhick @ 2010-07-23  9:02 UTC (permalink / raw)
  To: Arnaud Patard (Rtp); +Cc: ben-linux, linux-i2c, linux-samsung-soc

[-- Attachment #1: Type: Text/Plain, Size: 580 bytes --]

В сообщении от 15 июля 2010 16:06:14 автор Arnaud Patard написал:
> 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>

Fixes same bug with uda1380 on rx1950 aswell.

Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/1] i2c-s3c2410: Enable i2c clock only when doing some transfert
  2010-07-23  9:02 ` Vasily Khoruzhick
@ 2010-08-27 19:33   ` Vasily Khoruzhick
  2010-10-01  6:34     ` Vasily Khoruzhick
  0 siblings, 1 reply; 4+ messages in thread
From: Vasily Khoruzhick @ 2010-08-27 19:33 UTC (permalink / raw)
  To: Arnaud Patard (Rtp); +Cc: ben-linux, linux-i2c, linux-samsung-soc

[-- Attachment #1: Type: Text/Plain, Size: 839 bytes --]

В сообщении от 23 июля 2010 12:02:49 автор Vasily Khoruzhick написал:
> В сообщении от 15 июля 2010 16:06:14 автор Arnaud Patard написал:
> > 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>
> 
> Fixes same bug with uda1380 on rx1950 aswell.
> 
> Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>

This patch has problem with suspend/resume, clock needs to be enabled on i2c 
re-init. Here's fixed version of patch in attachment.

[-- Attachment #2: 0001-i2c-s3c2410-Enable-i2c-clock-only-when-doing-some-tr.patch --]
[-- Type: text/x-patch, Size: 2038 bytes --]

From a7b655bc82e21dcd8ae380efd39ec0455cd48779 Mon Sep 17 00:00:00 2001
From: Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org>
Date: Thu, 15 Jul 2010 15:06:14 +0200
Subject: [PATCH v2 1/1] 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).

v2: enable clock on i2c init in resume handler

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 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 72902e0..0e2a2c7 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;
 }
-- 
1.7.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch 1/1] i2c-s3c2410: Enable i2c clock only when doing some transfert
  2010-08-27 19:33   ` Vasily Khoruzhick
@ 2010-10-01  6:34     ` Vasily Khoruzhick
  0 siblings, 0 replies; 4+ messages in thread
From: Vasily Khoruzhick @ 2010-10-01  6:34 UTC (permalink / raw)
  To: Arnaud Patard (Rtp); +Cc: ben-linux, linux-i2c, linux-samsung-soc

On 27 of August 2010 22:33:00 Vasily Khoruzhick wrote:

> This patch has problem with suspend/resume, clock needs to be enabled on
> i2c re-init. Here's fixed version of patch in attachment.

Ping

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-01  6:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-15 13:06 [patch 1/1] i2c-s3c2410: Enable i2c clock only when doing some transfert Arnaud Patard
2010-07-23  9:02 ` Vasily Khoruzhick
2010-08-27 19:33   ` Vasily Khoruzhick
2010-10-01  6:34     ` Vasily Khoruzhick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).