On Sat, Mar 21, 2009 at 3:48 PM, Wolfgang Denk <w...@denx.de> wrote: > Dear Jon, > > In message <20090321133848.11905.59350.st...@localhost> you wrote: >> 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. >> >> Signed-off-by: Sascha Hauer <s.ha...@pengutronix.de> >> --- >> cpu/mpc5xxx/i2c.c | 6 +++--- >> 1 files changed, 3 insertions(+), 3 deletions(-) > > Are you absolutely sure that reducing these delays from 1 millisecond > to 1 microsecond will work on all boards with all currently supported > devices? > > 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. ---------------------------------------------------------------------- mpc5200: reduce delays in i2c 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: Jon Smirl <jonsm...@gmail.com> --- 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 a5478b2..dcb184c 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 1000 #define I2C_RETRIES 3 #ifdef CONFIG_ENV_IS_IN_EEPROM @@ -101,7 +101,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); } @@ -116,7 +116,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); } > > Best regards, > > Wolfgang Denk > > -- > DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de > It's certainly convenient the way the crime (or condition) of > stupidity carries with it its own punishment, automatically > admisistered without remorse, pity, or prejudice. :-) > -- Tom Christiansen in <559seq$ag...@csnews.cs.colorado.edu> > -- Jon Smirl jonsm...@gmail.com _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot