Skip to contentSkip to conversation

i2c: i2c-omap: Fix standard and fast mode prescalers

PATCH In review [email protected] 2 participants 2 messages Nov 11, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i2c-omap: Fix standard and fast mode prescalers

From: Eero Nurkkala <[email protected]>

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.

---
 drivers/i2c/busses/i2c-omap.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-omap.c +9 -3
index f15668d..cee2f2d 100644
@@ -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;
Signature · 1 line
1.6.0
#1 lore raw

----- Original Message ----- From: <[email protected]>
To: <[email protected]>
Cc: "Eero Nurkkala" <[email protected]>
Sent: Tuesday, November 11, 2008 12:22 PM
Subject: [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers

Quoted 22 lines

From: Eero Nurkkala <[email protected]>

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.

---
drivers/i2c/busses/i2c-omap.c | 12 +++++++++---

1 files changed, 9 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-omap.c +0 -0
index f15668d..cee2f2d 100644

drivers/i2c/busses/i2c-omap.c static int omap_i2c_init(struct omap_i2c_dev *dev) · line 296

Quoted 10 lines
drivers/i2c/busses/i2c-omap.c +6 -1
@@ -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;

Is internal clk 4000 valid?? PSC_REG field cannot encompass ( its 4 bit field) the calculated psc if internal_clk is 4000.

Quoted 23 lines
drivers/i2c/busses/i2c-omap.c +3 -2
+
 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;
Signature · 6 lines
1.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html