[U-Boot] [PATCH] OMAP I2C: fix handling of alen = 0

Daniel Mack zonque at gmail.com
Mon Mar 26 13:06:22 CEST 2012


Allow raw I2C message transfers by setting the alen parameter to 0.
Currently, this doesn't work due to false assumptions to what is
appearantly considered a corner case.

With this patch applied, it is possible to send multibyte transfers
in one single transaction instead of using multiple STOP-bit-ommited
transfers.

Signed-off-by: Daniel Mack <zonque at gmail.com>
Cc: Dirk Behme <dirk.behme at gmail.com>
Cc: Igor Grinberg <grinberg at compulab.co.il>
Cc: Tom Rini <trini at ti.com>
Cc: Steve Sakoman <sakoman at gmail.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Tom Rix <Tom.Rix at windriver.com>

---

On a OMAP3-based board, I needed raw I2C messages to configure
peripheral devices, and it turned out that the current omap-i2c
driver is not capable of send such due to assumption that are
made wrt register/payload data on the wire.

I couldn't figure who's best to take care for such a patch, so I
picked some people who have been working on this driver and
similar boards before.

Thanks for routing this in the right direction :)

 drivers/i2c/omap24xx_i2c.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index f06af02..30914df 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -401,7 +401,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 		i2c_error = 1;
 
 	if (!i2c_error) {
-		if (status & I2C_STAT_XRDY) {
+		if (status & I2C_STAT_XRDY && alen > 0) {
 			switch (alen) {
 #if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \
 			defined(CONFIG_AM33XX)
@@ -445,7 +445,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 			i2c_error = 1;
 
 		if (!i2c_error) {
-			for (i = ((alen > 1) ? 0 : 1); i < len; i++) {
+			for (i = ((alen == 1) ? 1 : 0); i < len; i++) {
 				if (status & I2C_STAT_XRDY) {
 #if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \
 				defined(CONFIG_AM33XX)
-- 
1.7.7.6



More information about the U-Boot mailing list