mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-27 16:01:27 +00:00
mxc_i2c: add bus recovery support
Add support for calling a function that will toggle the SCL line to return the bus to idle condition. The actual toggling function is added in a later patch. Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
This commit is contained in:
parent
e4ff525f91
commit
96c19bd3ef
1 changed files with 26 additions and 0 deletions
|
@ -251,6 +251,8 @@ static int i2c_init_transfer_(struct mxc_i2c_regs *i2c_regs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int i2c_idle_bus(void *base);
|
||||||
|
|
||||||
static int i2c_init_transfer(struct mxc_i2c_regs *i2c_regs,
|
static int i2c_init_transfer(struct mxc_i2c_regs *i2c_regs,
|
||||||
uchar chip, uint addr, int alen)
|
uchar chip, uint addr, int alen)
|
||||||
{
|
{
|
||||||
|
@ -269,6 +271,8 @@ static int i2c_init_transfer(struct mxc_i2c_regs *i2c_regs,
|
||||||
if (ret != -ERESTART)
|
if (ret != -ERESTART)
|
||||||
writeb(0, &i2c_regs->i2cr); /* Disable controller */
|
writeb(0, &i2c_regs->i2cr); /* Disable controller */
|
||||||
udelay(100);
|
udelay(100);
|
||||||
|
if (i2c_idle_bus(i2c_regs) < 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
printf("%s: give up i2c_regs=%p\n", __func__, i2c_regs);
|
printf("%s: give up i2c_regs=%p\n", __func__, i2c_regs);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -390,6 +394,28 @@ void *get_base(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct i2c_parms *i2c_get_parms(void *base)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
struct i2c_parms *p = srdata.i2c_data;
|
||||||
|
while (i < ARRAY_SIZE(srdata.i2c_data)) {
|
||||||
|
if (p->base == base)
|
||||||
|
return p;
|
||||||
|
p++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
printf("Invalid I2C base: %p\n", base);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int i2c_idle_bus(void *base)
|
||||||
|
{
|
||||||
|
struct i2c_parms *p = i2c_get_parms(base);
|
||||||
|
if (p && p->idle_bus_fn)
|
||||||
|
return p->idle_bus_fn(p->idle_bus_data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
|
int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
|
||||||
{
|
{
|
||||||
return bus_i2c_read(get_base(), chip, addr, alen, buf, len);
|
return bus_i2c_read(get_base(), chip, addr, alen, buf, len);
|
||||||
|
|
Loading…
Add table
Reference in a new issue