mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-10 12:39:22 -04:00
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). Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
parent
1ca9950b46
commit
09d318a8bb
@ -173,12 +173,11 @@ i2c_init(int speed, int slaveadd)
|
|||||||
static __inline__ int
|
static __inline__ int
|
||||||
i2c_wait4bus(void)
|
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) {
|
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 -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -188,7 +187,7 @@ static __inline__ int
|
|||||||
i2c_wait(int write)
|
i2c_wait(int write)
|
||||||
{
|
{
|
||||||
u32 csr;
|
u32 csr;
|
||||||
ulong timeval = get_timer(0);
|
unsigned long long timeval = get_ticks();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
csr = readb(&i2c_dev[i2c_bus_num]->sr);
|
csr = readb(&i2c_dev[i2c_bus_num]->sr);
|
||||||
@ -213,7 +212,7 @@ i2c_wait(int write)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} while (get_timer (timeval) < I2C_TIMEOUT);
|
} while ((get_ticks() - timeval) < usec2ticks(I2C_TIMEOUT));
|
||||||
|
|
||||||
debug("i2c_wait: timed out\n");
|
debug("i2c_wait: timed out\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user