diff options
author | Dirk Behme <dirk.behme@googlemail.com> | 2008-12-14 09:47:18 +0100 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2009-01-24 17:51:22 +0100 |
commit | 7d264c1ef267cfc8d928bc8577a7cc907f2f5e47 (patch) | |
tree | 7a83a39da5b9f032e4b1bd9f98e2dbd3641c21ec /drivers | |
parent | b1c3bf99fb477675d464aeadb5dd69d2cbc9dc7b (diff) | |
download | u-boot-imx-7d264c1ef267cfc8d928bc8577a7cc907f2f5e47.zip u-boot-imx-7d264c1ef267cfc8d928bc8577a7cc907f2f5e47.tar.gz u-boot-imx-7d264c1ef267cfc8d928bc8577a7cc907f2f5e47.tar.bz2 |
OMAP3: Add I2C support
Add I2C support.
Signed-off-by: Dirk Behme <dirk.behme@googlemail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/Makefile | 1 | ||||
-rw-r--r-- | drivers/i2c/omap24xx_i2c.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 6079c05..12e9e05 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -29,6 +29,7 @@ COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o +COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 4427938..6784603 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -109,7 +109,11 @@ static int i2c_read_byte (u8 devaddr, u8 regoffset, u8 * value) status = wait_for_pin (); if (status & I2C_STAT_RRDY) { +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) + *value = readb (I2C_DATA); +#else *value = readw (I2C_DATA); +#endif udelay (20000); } else { i2c_error = 1; @@ -150,8 +154,23 @@ static int i2c_write_byte (u8 devaddr, u8 regoffset, u8 value) status = wait_for_pin (); if (status & I2C_STAT_XRDY) { +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) + /* send out 1 byte */ + writeb (regoffset, I2C_DATA); + writew (I2C_STAT_XRDY, I2C_STAT); + + status = wait_for_pin (); + if ((status & I2C_STAT_XRDY)) { + /* send out next 1 byte */ + writeb (value, I2C_DATA); + writew (I2C_STAT_XRDY, I2C_STAT); + } else { + i2c_error = 1; + } +#else /* send out two bytes */ writew ((value << 8) + regoffset, I2C_DATA); +#endif /* must have enough delay to allow BB bit to go low */ udelay (50000); if (readw (I2C_STAT) & I2C_STAT_NACK) { @@ -188,7 +207,11 @@ static void flush_fifo(void) while(1){ stat = readw(I2C_STAT); if(stat == I2C_STAT_RRDY){ +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) + readb(I2C_DATA); +#else readw(I2C_DATA); +#endif writew(I2C_STAT_RRDY,I2C_STAT); udelay(1000); }else |