diff options
author | Wolfgang Denk <wd@denx.de> | 2011-04-20 22:48:47 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-04-20 22:48:47 +0200 |
commit | a94028338c8cfc55665cecb04aeb4f70785db0e1 (patch) | |
tree | 8247adbe58b33dd8ba399717bf093bf6f63a48ae | |
parent | 4f27f0ab984b3cabd696b1ad73bbe77e27756c73 (diff) | |
parent | 0e57968a215d1b9d271f3fa5bebeddeaea0c8075 (diff) | |
download | u-boot-imx-a94028338c8cfc55665cecb04aeb4f70785db0e1.zip u-boot-imx-a94028338c8cfc55665cecb04aeb4f70785db0e1.tar.gz u-boot-imx-a94028338c8cfc55665cecb04aeb4f70785db0e1.tar.bz2 |
Merge branch 'master' of git://git.denx.de/u-boot-i2c
-rw-r--r-- | drivers/i2c/omap24xx_i2c.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 215be34..71251d8 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -321,43 +321,23 @@ int i2c_probe (uchar chip) /* wait until bus not busy */ wait_for_bb (); - /* try to read one byte */ + /* try to write one byte */ writew (1, &i2c_base->cnt); /* set slave address */ writew (chip, &i2c_base->sa); /* stop bit needed here */ - writew (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP, &i2c_base->con); + writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX | + I2C_CON_STP, &i2c_base->con); - while (1) { - status = wait_for_pin(); - if (status == 0 || status & I2C_STAT_AL) { - res = 1; - goto probe_exit; - } - if (status & I2C_STAT_NACK) { - res = 1; - writew(0xff, &i2c_base->stat); - writew (readw (&i2c_base->con) | I2C_CON_STP, &i2c_base->con); - wait_for_bb (); - break; - } - if (status & I2C_STAT_ARDY) { - writew(I2C_STAT_ARDY, &i2c_base->stat); - break; - } - if (status & I2C_STAT_RRDY) { - res = 0; -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ - defined(CONFIG_OMAP44XX) - readb(&i2c_base->data); -#else - readw(&i2c_base->data); -#endif - writew(I2C_STAT_RRDY, &i2c_base->stat); - } - } + status = wait_for_pin(); + + /* check for ACK (!NAK) */ + if (!(status & I2C_STAT_NACK)) + res = 0; + + /* abort transfer (force idle state) */ + writew(0, &i2c_base->con); -probe_exit: flush_fifo(); writew (0, &i2c_base->cnt); /* don't allow any more data in...we don't want it.*/ writew(0xFFFF, &i2c_base->stat); |