Message ID | 1340338339-11626-13-git-send-email-troy.kisky@boundarydevices.com |
---|---|
State | Superseded |
Delegated to: | Heiko Schocher |
Headers | show |
Dear Troy Kisky, > No need to continue waiting if arbitration lost. > > Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> Acked-by: Marek Vasut <marex@denx.de> > --- > drivers/i2c/mxc_i2c.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c > index 2bff2b8..df033ea 100644 > --- a/drivers/i2c/mxc_i2c.c > +++ b/drivers/i2c/mxc_i2c.c > @@ -54,6 +54,7 @@ struct mxc_i2c_regs { > > #define I2SR_ICF (1 << 7) > #define I2SR_IBB (1 << 5) > +#define I2SR_IAL (1 << 4) > #define I2SR_IIF (1 << 1) > #define I2SR_RX_NO_AK (1 << 0) > > @@ -164,6 +165,12 @@ static unsigned wait_for_sr_state(struct mxc_i2c_regs > *i2c_regs, unsigned state) ulong start_time = get_timer(0); > for (;;) { > sr = readb(&i2c_regs->i2sr); > + if (sr & I2SR_IAL) { > + writeb(sr & ~I2SR_IAL, &i2c_regs->i2sr); > + printf("%s: Arbitration lost sr=%x cr=%x state=%x\n", > + __func__, sr, readb(&i2c_regs->i2cr), state); > + return -ERESTART; > + } > if ((sr & (state >> 8)) == (unsigned char)state) > return sr; > elapsed = get_timer(start_time); Best regards, Marek Vasut
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 2bff2b8..df033ea 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -54,6 +54,7 @@ struct mxc_i2c_regs { #define I2SR_ICF (1 << 7) #define I2SR_IBB (1 << 5) +#define I2SR_IAL (1 << 4) #define I2SR_IIF (1 << 1) #define I2SR_RX_NO_AK (1 << 0) @@ -164,6 +165,12 @@ static unsigned wait_for_sr_state(struct mxc_i2c_regs *i2c_regs, unsigned state) ulong start_time = get_timer(0); for (;;) { sr = readb(&i2c_regs->i2sr); + if (sr & I2SR_IAL) { + writeb(sr & ~I2SR_IAL, &i2c_regs->i2sr); + printf("%s: Arbitration lost sr=%x cr=%x state=%x\n", + __func__, sr, readb(&i2c_regs->i2cr), state); + return -ERESTART; + } if ((sr & (state >> 8)) == (unsigned char)state) return sr; elapsed = get_timer(start_time);
No need to continue waiting if arbitration lost. Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> --- drivers/i2c/mxc_i2c.c | 7 +++++++ 1 file changed, 7 insertions(+)