On Sun, Mar 22, 2009 at 11:21 AM, Wolfgang Denk <w...@denx.de> wrote: > Dear Jon, > > In message <9e4733910903220720l723de65fm59a7e6a7fed1e...@mail.gmail.com> you > wrote: >> >> > And how much do we make I2C faster this way? Where do we save time, >> > and how much? >> >> I measured the delay. It is between 40us and 52us on my hardware so I >> adjusted the loop to 60us. The previous 1ms delay was 20x bigger than >> necessary. If the hardware is slower, it will just loop and add more >> delay. > > You did not answer my question in which way this actually makes I2C > faster? Where do we save time, and how much?
I increased the retry loop to 10,000. This definitely makes my system faster. On my bus the actual i2c delay is 40-55us. The original code always delayed 1,000us so for me it a gain of 940us on each i2c operation. This is visible during things like probe. mpc5200: reduce delays in i2c From: Sascha Hauer <s.ha...@pengutronix.de> The mpc5xxx i2c driver has great delays while waiting for the chip status. make the delays smaller and the driver faster. The measured delay is 55us at 100Khz. Set the delay to 15us which should work for 400Khz. 100Khz will loop four times and get a 60us delay. Signed-off-by: Sascha Hauer <s.ha...@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 0860ecf..58470d1 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(®s->mcr, 0, 0); mpc_reg_out(®s->mcr, I2C_EN, 0); #endif - udelay(1000); + udelay(15); status = mpc_reg_in(®s->msr); } @@ -109,7 +109,7 @@ static int wait_for_pin(int *status) *status = mpc_reg_in(®s->msr); while (timeout-- && !(*status & I2C_IF)) { - udelay(1000); + udelay(15); *status = mpc_reg_in(®s->msr); } -- Jon Smirl jonsm...@gmail.com _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot