public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] mpc5200: make i2c faster
Date: Mon, 23 Mar 2009 00:16:51 +0100	[thread overview]
Message-ID: <20090322231651.GE20099@pengutronix.de> (raw)
In-Reply-To: <20090321133848.11905.59350.stgit@localhost>

Hi,

On Sat, Mar 21, 2009 at 09:38:48AM -0400, Jon wrote:
> From: Sascha Hauer <s.hauer@pengutronix.de>
> 
> The mpc5xxx i2c driver has great delays while waiting for the chip status.
> make the delays smaller and the driver faster.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  cpu/mpc5xxx/i2c.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/cpu/mpc5xxx/i2c.c b/cpu/mpc5xxx/i2c.c
> index 843af9c..41feb1d 100644
> --- a/cpu/mpc5xxx/i2c.c
> +++ b/cpu/mpc5xxx/i2c.c
> @@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  #error CONFIG_SYS_I2C_MODULE is not properly configured
>  #endif
>  
> -#define I2C_TIMEOUT	100
> +#define I2C_TIMEOUT	10000
>  #define I2C_RETRIES	3
>  
>  struct mpc5xxx_i2c_tap {
> @@ -94,7 +94,7 @@ static int wait_for_bb(void)
>  		mpc_reg_out(&regs->mcr, 0, 0);
>  		mpc_reg_out(&regs->mcr, I2C_EN, 0);
>  #endif
> -		udelay(1000);
> +		udelay(1);
>  		status = mpc_reg_in(&regs->msr);
>  	}
>  

The actual condition we wait for takes only a few useconds to become
true, but we wait for at least 1ms. As the I2C EEPROM environment
routine reads nearly the complete EEPROM several times during startup
the speed gain is enormous.
I can't recall if it was intentional to reduce the overall timeout with
this patch, but I can imagine that the i2c detect function will be
faster aswell.

> @@ -109,7 +109,7 @@ static int wait_for_pin(int *status)
>  	*status = mpc_reg_in(&regs->msr);
>  
>  	while (timeout-- && !(*status & I2C_IF)) {
> -		udelay(1000);
> +		udelay(1);
>  		*status = mpc_reg_in(&regs->msr);

Same here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  parent reply	other threads:[~2009-03-22 23:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-21 13:38 [U-Boot] [PATCH 0/3] Three mpc5200 patches from Pengutronix.de Jon
2009-03-21 13:38 ` [U-Boot] [PATCH 1/3] mpc5200: do not use printf in i2c_init() Jon
2009-03-21 19:47   ` Wolfgang Denk
2009-03-21 20:39     ` Jon Smirl
2009-03-21 20:54       ` Wolfgang Denk
2009-03-21 20:56       ` Wolfgang Denk
2009-03-22 14:01         ` Jon Smirl
2009-03-22 14:21           ` Wolfgang Denk
2009-03-22 14:23             ` Jon Smirl
2009-03-22 15:23               ` Wolfgang Denk
2009-03-23  2:55                 ` Jon Smirl
2009-03-24  8:38                   ` Heiko Schocher
2009-03-25 21:51                   ` Wolfgang Denk
2009-03-25 22:31                     ` Jon Smirl
2009-03-21 13:38 ` [U-Boot] [PATCH 2/3] mpc52xx phy: initialize only when needed Jon
2009-03-25 19:12   ` Jon Smirl
2009-03-25 21:53     ` Wolfgang Denk
2009-03-31  1:04       ` Jon Smirl
2009-03-31  6:13         ` Ben Warren
2009-04-04 20:37   ` Wolfgang Denk
2009-03-21 13:38 ` [U-Boot] [PATCH 3/3] mpc5200: make i2c faster Jon
2009-03-21 19:48   ` Wolfgang Denk
2009-03-22 14:20     ` Jon Smirl
2009-03-22 15:21       ` Wolfgang Denk
2009-03-23  2:59         ` Jon Smirl
2009-03-23  8:24           ` Wolfgang Denk
2009-03-22 23:16   ` Sascha Hauer [this message]
2009-03-23  3:00     ` Grant Likely
2009-03-23  6:24       ` Wolfgang Denk

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=20090322231651.GE20099@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=u-boot@lists.denx.de \
    /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