LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: Komal Shah <komal_shah802003@yahoo.com>,
	David Brownell <david-b@pacbell.net>,
	r-woodruff2@ti.com, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@osdl.org>, Greg KH <gregkh@suse.de>,
	i2c@lm-sensors.org
Subject: Re: [PATCH] OMAP: I2C driver for TI OMAP boards #3
Date: Mon, 7 Aug 2006 17:58:33 +0300	[thread overview]
Message-ID: <20060807145832.GF10387@atomide.com> (raw)
In-Reply-To: <20060805103113.058ce8fe.khali@linux-fr.org>

Hi,

* Jean Delvare <khali@linux-fr.org> [060805 11:31]:
> 
> > >> +		if (armxor_rate > 16000000)
> > >> +			psc = (armxor_rate + 8000000) / 12000000;
> > >> +		else
> > >> +			psc = 0;
> > 
> > >Can you please explain this formula?
> > 
> > The OMAP core uses 8-bit value to divide the system clock (SCLK) and
> > generates its own sampling clock (ICLK), and the core logic is sampled
> > at clock rate of the system clock for the module, divided by (prescaler value + 1)
> 
> I should have been more precise, I guess. What surprises me are the
> numbers themselves. It's frequent to see forumlae of the form
> "a = (b + c/2) / c" to divide with proper rounding, but here you have
> 2c/3 instread of c/2. My question was more like: is it intentional, or a
> typo? Also, with the code above, psc will never have value 1. The "if"
> part will always compute to at least 2, and the "else" part to 0. Is
> this OK?
> 

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

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.

Regards,

Tony

[1] http://focus.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=spru681
[2] http://linux-omap.bkbits.net:8080/main/diffs/drivers/i2c/busses/i2c-omap.c@1.12?nav=index.html|src/|src/drivers|src/drivers/i2c|src/drivers/i2c/busses|hist/drivers/i2c/busses/i2c-omap.c

  reply	other threads:[~2006-08-07 14:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1154689868.12791.267626769@webmail.messagingengine.com>
2006-08-05  8:31 ` Jean Delvare
2006-08-07 14:58   ` Tony Lindgren [this message]
2006-08-08 12:57     ` Komal Shah
2006-08-08 13:09       ` Jean Delvare
2006-08-10  8:29     ` Jean Delvare
2006-08-10 13:19       ` Tony Lindgren
2006-12-04 17:49         ` Jean Delvare
2006-12-06 22:45           ` Tony Lindgren
2006-08-06 14:35 ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060807145832.GF10387@atomide.com \
    --to=tony@atomide.com \
    --cc=akpm@osdl.org \
    --cc=david-b@pacbell.net \
    --cc=gregkh@suse.de \
    --cc=i2c@lm-sensors.org \
    --cc=khali@linux-fr.org \
    --cc=komal_shah802003@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=r-woodruff2@ti.com \
    --subject='Re: [PATCH] OMAP: I2C driver for TI OMAP boards #3' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).