mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-11 05:02:26 -04:00
omap24xx_i2c: Handle wait_for_bb error
We add a return code to wait_for_bb() to be able to report errors to the callers properly. We in turn handle this new error code in i2c_read, i2c_write and i2c_probe. Signed-off-by: Vincent Stehlé <v-stehle@ti.com>
This commit is contained in:
parent
dcee1ab320
commit
febc4cd48a
@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
|
|
||||||
#define I2C_TIMEOUT 1000
|
#define I2C_TIMEOUT 1000
|
||||||
|
|
||||||
static void wait_for_bb(void);
|
static int wait_for_bb(void);
|
||||||
static u16 wait_for_pin(void);
|
static u16 wait_for_pin(void);
|
||||||
static void flush_fifo(void);
|
static void flush_fifo(void);
|
||||||
|
|
||||||
@ -159,7 +159,8 @@ static int i2c_read_byte(u8 devaddr, u16 regoffset, u8 alen, u8 *value)
|
|||||||
u16 w;
|
u16 w;
|
||||||
|
|
||||||
/* wait until bus not busy */
|
/* wait until bus not busy */
|
||||||
wait_for_bb();
|
if (wait_for_bb())
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* one byte only */
|
/* one byte only */
|
||||||
writew(alen, &i2c_base->cnt);
|
writew(alen, &i2c_base->cnt);
|
||||||
@ -260,7 +261,8 @@ int i2c_probe(uchar chip)
|
|||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* wait until bus not busy */
|
/* wait until bus not busy */
|
||||||
wait_for_bb();
|
if (wait_for_bb())
|
||||||
|
return res;
|
||||||
|
|
||||||
/* try to read one byte */
|
/* try to read one byte */
|
||||||
writew(1, &i2c_base->cnt);
|
writew(1, &i2c_base->cnt);
|
||||||
@ -279,7 +281,10 @@ int i2c_probe(uchar chip)
|
|||||||
res = 1;
|
res = 1;
|
||||||
writew(0xff, &i2c_base->stat);
|
writew(0xff, &i2c_base->stat);
|
||||||
writew (readw (&i2c_base->con) | I2C_CON_STP, &i2c_base->con);
|
writew (readw (&i2c_base->con) | I2C_CON_STP, &i2c_base->con);
|
||||||
wait_for_bb ();
|
|
||||||
|
if (wait_for_bb())
|
||||||
|
res = 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (status & I2C_STAT_ARDY) {
|
if (status & I2C_STAT_ARDY) {
|
||||||
@ -351,7 +356,8 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* wait until bus not busy */
|
/* wait until bus not busy */
|
||||||
wait_for_bb();
|
if (wait_for_bb())
|
||||||
|
return 1;
|
||||||
|
|
||||||
/* start address phase - will write regoffset + len bytes data */
|
/* start address phase - will write regoffset + len bytes data */
|
||||||
/* TODO consider case when !CONFIG_OMAP243X/34XX/44XX */
|
/* TODO consider case when !CONFIG_OMAP243X/34XX/44XX */
|
||||||
@ -394,7 +400,7 @@ write_exit:
|
|||||||
return i2c_error;
|
return i2c_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wait_for_bb(void)
|
static int wait_for_bb(void)
|
||||||
{
|
{
|
||||||
int timeout = I2C_TIMEOUT;
|
int timeout = I2C_TIMEOUT;
|
||||||
u16 stat;
|
u16 stat;
|
||||||
@ -408,8 +414,10 @@ static void wait_for_bb(void)
|
|||||||
if (timeout <= 0) {
|
if (timeout <= 0) {
|
||||||
printf("timed out in wait_for_bb: I2C_STAT=%x\n",
|
printf("timed out in wait_for_bb: I2C_STAT=%x\n",
|
||||||
readw(&i2c_base->stat));
|
readw(&i2c_base->stat));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
writew(0xFFFF, &i2c_base->stat); /* clear delayed stuff*/
|
writew(0xFFFF, &i2c_base->stat); /* clear delayed stuff*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u16 wait_for_pin(void)
|
static u16 wait_for_pin(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user