Re: [PATCH] OMAP: I2C driver for TI OMAP boards #3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tony, Komal,

> Hmmm, this sounds like a bug somewhere. TRM for 5912 says the I2C clock
> must be prescaled to be between 7 - 12 MHz [1]. The XOR input clock is
> typically 12, 13 or 19.2 MHz. So we should have code that produces:
> 
> XOR Mhz	Divider	Prescaler
> 12		1	0
> 13		2	1
> 19.2		2	1

Not that 13 MHz cannot actually be prescaled between 7 and 12 MHz, no
matter how you look at it.

> Then again the original old code produces something different too [2]...
> 
> I suspect the original code had some hw workarounds and and later code
> may have a conversion bug somewhere :)
> 
> I suggest we keep the code as is for now since it's known to work on
> all omaps, and then submit a follow-up patch later once we have
> verified that that code based on the TRM works on all omaps.

I've now taken Komal's patch (#4). Here is a proposed patch which brings
the prescaler computation formula in line with your comment and table
above. It could be applied on top of Komal's patch unless it causes a
problem on some of the OMAP systems. For XOR = 13 MHz, it changes the
prescaler from 0 to 1. For XOR = 19.2 MHz it changes the prescaler from
2 to 1.

I don't have any hardware to test it, though. If it happens to be
better to be slightly over 12 MHz than slightly below 7 MHz, the
"> 12000000" condition below can be replaced with "> 14000000".


i2c: Fix OMAP clock prescaler to match the comment

Signed-off-by: Jean Delvare <[email protected]>
---
 drivers/i2c/busses/i2c-omap.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.18-rc4.orig/drivers/i2c/busses/i2c-omap.c	2006-08-10 09:56:54.000000000 +0200
+++ linux-2.6.18-rc4/drivers/i2c/busses/i2c-omap.c	2006-08-10 10:12:03.000000000 +0200
@@ -231,8 +231,8 @@
 		 * 13		2		1
 		 * 19.2		2		1
 		 */
-		if (fclk_rate > 16000000)
-			psc = (fclk_rate + 8000000) / 12000000;
+		if (fclk_rate > 12000000)
+			psc = fclk_rate / 12000000;
 	}
 
 	/* Setup clock prescaler to obtain approx 12MHz I2C module clock: */


-- 
Jean Delvare
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux