public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
@ 2008-11-26 13:44 ext-eero.nurkkala
  2008-11-27  8:38 ` Eero Nurkkala
  2009-01-09 20:27 ` Kainan Cha
  0 siblings, 2 replies; 21+ messages in thread
From: ext-eero.nurkkala @ 2008-11-26 13:44 UTC (permalink / raw)
  To: linux-omap; +Cc: Eero Nurkkala

From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>

The prescalers for 100 kHz and 400 kHz mode
are wrong for omap 3430 and omap 2430. The
internal clock is the fclock divided by the
prescaler. The PSC is an 8 bit field in
omap3430 and omap2430. Moreover, the scll and
sclh values should be adjusted properly.
Having the correct prescaler is important in
the process of getting a finite i2c clock. In
addition, the prescaler is used in the process
of activating the correct noise filter and thus,
lets more error resilient i2c communications.

Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
---
 drivers/i2c/busses/i2c-omap.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 630702c..c21af3f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -337,7 +337,13 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	if (cpu_is_omap2430() || cpu_is_omap34xx()) {
 
 		/* HSI2C controller internal clk rate should be 19.2 Mhz */
-		internal_clk = 19200;
+		if (dev->speed > 400)
+			internal_clk = 19200;
+		else if (dev->speed > 100)
+			internal_clk = 9600;
+		else
+			internal_clk = 4000;
+
 		fclk_rate = clk_get_rate(dev->fclk) / 1000;
 
 		/* Compute prescaler divisor */
@@ -355,8 +361,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			hssclh = fclk_rate / (dev->speed * 2) - 6;
 		} else {
 			/* To handle F/S modes */
-			fsscll = internal_clk / (dev->speed * 2) - 6;
-			fssclh = internal_clk / (dev->speed * 2) - 6;
+			fsscll = internal_clk / (dev->speed * 2) - 3;
+			fssclh = internal_clk / (dev->speed * 2) - 9;
 		}
 		scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
 		sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
-- 
1.6.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread
* Re: [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
@ 2009-01-13  6:06 Eero Nurkkala
  2009-01-23  2:04 ` Tony Lindgren
  0 siblings, 1 reply; 21+ messages in thread
From: Eero Nurkkala @ 2009-01-13  6:06 UTC (permalink / raw)
  To: linux-omap

Feel free to revert this patch.

There appears to be problems with the noised filters
not obeying the i2c standard.

I will come up with a new patch in the future.



^ permalink raw reply	[flat|nested] 21+ messages in thread
* [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
@ 2008-11-25  6:56 ext-eero.nurkkala
  0 siblings, 0 replies; 21+ messages in thread
From: ext-eero.nurkkala @ 2008-11-25  6:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Eero Nurkkala

From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>

The prescalers for 100 kHz and 400 kHz mode
are wrong for omap 3430 and omap 2430. The
internal clock is the fclock divided by the
prescaler. The PSC is an 8 bit field in
omap3430 and omap2430. Moreover, the scll and
sclh values should be adjusted properly.
Having the correct prescaler is important in
the process of getting a finite i2c clock. In
addition, the prescaler is used in the process
of activating the correct noise filter and thus,
lets more error resilient i2c communications.

Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
---
 drivers/i2c/busses/i2c-omap.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 630702c..c21af3f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -337,7 +337,13 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	if (cpu_is_omap2430() || cpu_is_omap34xx()) {
 
 		/* HSI2C controller internal clk rate should be 19.2 Mhz */
-		internal_clk = 19200;
+		if (dev->speed > 400)
+			internal_clk = 19200;
+		else if (dev->speed > 100)
+			internal_clk = 9600;
+		else
+			internal_clk = 4000;
+
 		fclk_rate = clk_get_rate(dev->fclk) / 1000;
 
 		/* Compute prescaler divisor */
@@ -355,8 +361,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			hssclh = fclk_rate / (dev->speed * 2) - 6;
 		} else {
 			/* To handle F/S modes */
-			fsscll = internal_clk / (dev->speed * 2) - 6;
-			fssclh = internal_clk / (dev->speed * 2) - 6;
+			fsscll = internal_clk / (dev->speed * 2) - 7;
+			fssclh = internal_clk / (dev->speed * 2) - 5;
 		}
 		scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
 		sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
-- 
1.6.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
@ 2008-11-14  8:41 ext-eero.nurkkala
  2008-11-14 19:45 ` David Brownell
  2008-11-21 22:08 ` Tony Lindgren
  0 siblings, 2 replies; 21+ messages in thread
From: ext-eero.nurkkala @ 2008-11-14  8:41 UTC (permalink / raw)
  To: linux-omap; +Cc: Eero Nurkkala

From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>

The prescalers for 100 kHz and 400 kHz mode
are wrong. The internal clock is the fclock
divided by the prescaler. The PSC is an 8 bit
field in omap3430. Moreover, the scll and
sclh values should be adjusted properly.
Having the correct prescaler is important in
the process of getting a finite i2c clock. In
addition, the prescaler is used in the process
of activating the correct noise filter and thus,
lets more error resilient i2c communications.

Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
---
 drivers/i2c/busses/i2c-omap.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e708ebd..a42003a 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -288,7 +288,17 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	if (cpu_is_omap2430() || cpu_is_omap34xx()) {
 
 		/* HSI2C controller internal clk rate should be 19.2 Mhz */
-		internal_clk = 19200;
+		if (cpu_is_omap34xx()) {
+			if (dev->speed > 400)
+				internal_clk = 19200;
+			else if (dev->speed > 100)
+				internal_clk = 9600;
+			else
+				internal_clk = 4000;
+		} else {
+			internal_clk = 19200;
+		}
+
 		fclk_rate = clk_get_rate(dev->fclk) / 1000;
 
 		/* Compute prescaler divisor */
@@ -306,8 +316,13 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			hssclh = fclk_rate / (dev->speed * 2) - 6;
 		} else {
 			/* To handle F/S modes */
-			fsscll = internal_clk / (dev->speed * 2) - 6;
-			fssclh = internal_clk / (dev->speed * 2) - 6;
+			if (cpu_is_omap34xx()) {
+				fsscll = internal_clk / (dev->speed * 2) - 7;
+				fssclh = internal_clk / (dev->speed * 2) - 5;
+			} else {
+				fsscll = internal_clk / (dev->speed * 2) - 6;
+				fssclh = internal_clk / (dev->speed * 2) - 6;
+			}
 		}
 		scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
 		sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
-- 
1.6.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
@ 2008-11-11  6:52 ext-eero.nurkkala
  2008-11-11 13:21 ` shekhar, chandra
  0 siblings, 1 reply; 21+ messages in thread
From: ext-eero.nurkkala @ 2008-11-11  6:52 UTC (permalink / raw)
  To: linux-omap; +Cc: Eero Nurkkala

From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>

The prescalers for 100 kHz and 400 kHz mode
are wrong. The internal clock is the fclock
divided by the prescaler. Also, the scll and
sclh values should be adjusted correctly.
Having the correct prescaler is important in
the process of getting standard i2c clock. In
addition, it (psc) is used to get the correct
noise filter and thus, lets more error resilient
i2c communications.

Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
---
 drivers/i2c/busses/i2c-omap.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index f15668d..cee2f2d 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -288,7 +288,13 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	if (cpu_is_omap2430() || cpu_is_omap34xx()) {
 
 		/* HSI2C controller internal clk rate should be 19.2 Mhz */
-		internal_clk = 19200;
+		if (dev->speed > 400)
+			internal_clk = 19200;
+		else if (dev->speed > 100)
+			internal_clk = 9600;
+		else
+			internal_clk = 4000;
+
 		fclk_rate = clk_get_rate(dev->fclk) / 1000;
 
 		/* Compute prescaler divisor */
@@ -306,8 +312,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			hssclh = fclk_rate / (dev->speed * 2) - 6;
 		} else {
 			/* To handle F/S modes */
-			fsscll = internal_clk / (dev->speed * 2) - 6;
-			fssclh = internal_clk / (dev->speed * 2) - 6;
+			fsscll = internal_clk / (dev->speed * 2) - 7;
+			fssclh = internal_clk / (dev->speed * 2) - 5;
 		}
 		scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
 		sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
-- 
1.6.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread
* [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
@ 2008-11-10 10:46 ext-eero.nurkkala
  0 siblings, 0 replies; 21+ messages in thread
From: ext-eero.nurkkala @ 2008-11-10 10:46 UTC (permalink / raw)
  To: linux-omap; +Cc: Eero Nurkkala

From: Eero Nurkkala <ext-eero.nurkkala@nokia.com>


Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
---
 drivers/i2c/busses/i2c-omap.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 9ae3ad3..92653ce 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -304,7 +304,13 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 	if (cpu_is_omap2430() || cpu_is_omap34xx()) {
 
 		/* HSI2C controller internal clk rate should be 19.2 Mhz */
-		internal_clk = 19200;
+		if (dev->speed > 400)
+			internal_clk = 19200;
+		else if (dev->speed > 100)
+			internal_clk = 9600;
+		else
+			internal_clk = 4000;
+
 		fclk_rate = clk_get_rate(dev->fclk) / 1000;
 
 		/* Compute prescaler divisor */
@@ -322,8 +328,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
 			hssclh = fclk_rate / (dev->speed * 2) - 6;
 		} else {
 			/* To handle F/S modes */
-			fsscll = internal_clk / (dev->speed * 2) - 6;
-			fssclh = internal_clk / (dev->speed * 2) - 6;
+			fsscll = internal_clk / (dev->speed * 2) - 7;
+			fssclh = internal_clk / (dev->speed * 2) - 5;
 		}
 		scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll;
 		sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh;
-- 
1.5.2


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

end of thread, other threads:[~2009-01-23  2:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 13:44 [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers ext-eero.nurkkala
2008-11-27  8:38 ` Eero Nurkkala
2009-01-08 13:39   ` Tony Lindgren
2009-01-09 20:27 ` Kainan Cha
2009-01-12  6:29   ` Eero Nurkkala
  -- strict thread matches above, loose matches on Subject: below --
2009-01-13  6:06 Eero Nurkkala
2009-01-23  2:04 ` Tony Lindgren
2008-11-25  6:56 ext-eero.nurkkala
2008-11-14  8:41 ext-eero.nurkkala
2008-11-14 19:45 ` David Brownell
2008-11-14 20:02   ` Felipe Balbi
2008-11-14 20:08     ` David Brownell
2008-11-14 21:46       ` Felipe Balbi
2008-11-17  2:46         ` shekhar, chandra
2008-11-18  5:36           ` David Brownell
2008-11-14 20:38   ` Steve Sakoman
2008-11-19 12:07   ` Eero Nurkkala
2008-11-21 22:08 ` Tony Lindgren
2008-11-11  6:52 ext-eero.nurkkala
2008-11-11 13:21 ` shekhar, chandra
2008-11-10 10:46 ext-eero.nurkkala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox