From: Tony Lindgren <tony@atomide.com>
To: ext-eero.nurkkala@nokia.com
Cc: linux-omap@vger.kernel.org
Subject: Re: [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers
Date: Fri, 21 Nov 2008 14:08:57 -0800 [thread overview]
Message-ID: <20081121220856.GD4927@atomide.com> (raw)
In-Reply-To: <12266521173159-git-send-email-ext-eero.nurkkala@nokia.com>
* ext-eero.nurkkala@nokia.com <ext-eero.nurkkala@nokia.com> [081114 00:43]:
> 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.
I guess this should be also updated to use dev->rev so it works on
2430 too?
Tony
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-11-21 22:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-14 8:41 [PATCH] i2c: i2c-omap: Fix standard and fast mode prescalers 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 [this message]
-- 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-26 13:44 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
2008-11-25 6:56 ext-eero.nurkkala
2008-11-11 6:52 ext-eero.nurkkala
2008-11-11 13:21 ` shekhar, chandra
2008-11-10 10:46 ext-eero.nurkkala
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=20081121220856.GD4927@atomide.com \
--to=tony@atomide.com \
--cc=ext-eero.nurkkala@nokia.com \
--cc=linux-omap@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox