fsl_i2c: Use timebase timer functions instead of get_timer()
PATCH 1/1 fsl_i2c: Use timebase timer functions instead of get_timer()
The current implementation of get_timer() is only really useful after we have relocated u-boot to memory. The i2c code is used before that as part of the SPD DDR setup.
We actually have a bug when using the get_timer() code before relocation because the .bss hasn't been setup and thus we could be reading/writing a random location (probably in flash).
---
This is a fix for 1.3.4.
- k
drivers/i2c/fsl_i2c.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/i2c/fsl_i2c.c +4 -5
@@ -168,12 +168,11 @@ i2c_init(int speed, int slaveadd)static __inline__int i2c_wait4bus (void ) { -ulong timeval =get_timer (0 ); +unsigned long long timeval =get_ticks ();while (readb (&i2c_dev[i2c_bus_num]->sr) &I2C_SR_MBB ) { -if (get_timer (timeval) >I2C_TIMEOUT ) { +if ((get_ticks () - timeval) >usec2ticks (I2C_TIMEOUT ))return -1 ; - } }return 0 ;
@@ -183,7 +182,7 @@ static __inline__ int i2c_wait(int write) {u32 csr; -ulong timeval =get_timer (0 ); +unsigned long long timeval =get_ticks (); do { csr = readb(&i2c_dev[i2c_bus_num]->sr);
@@ -208,7 +207,7 @@ i2c_wait(int write) }return 0 ; - }while (get_timer (timeval) <I2C_TIMEOUT ); + }while ((get_ticks () - timeval) <usec2ticks (I2C_TIMEOUT ));debug ("i2c_wait: timed out\n" );return -1 ;
Signature · 1 line
1.5.5.1
Wolfgang Denk
AppliedPATCH 1/1 fsl_i2c: Use timebase timer functions instead of get_timer()
Quoted 9 lines · In message <[email protected]> you wrote:
The current implementation of
get_timer()is only really useful after we have relocated u-boot to memory. The i2c code is used before that as part of the SPD DDR setup.We actually have a bug when using the
get_timer()code before relocation because the .bss hasn't been setup and thus we could be reading/writing a random location (probably in flash).Signed-off-by Kumar Gala <[email protected]>
Quoted 8 lines
---
This is a fix for 1.3.4.
- k
drivers/i2c/fsl_i2c.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
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: wd at denx.de Extended Epstein-Heisenberg Principle: In an R & D orbit, only 2 of the existing 3 parameters can be defined simultaneously. The parame- ters are: task, time and resources ($).