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 <zon...@gmail.com>
Cc: Dirk Behme <dirk.be...@gmail.com>
Cc: Igor Grinberg <grinb...@compulab.co.il>
Cc: Tom Rini <tr...@ti.com>
Cc: Steve Sakoman <sako...@gmail.com>
Cc: Michal Simek <mon...@monstr.eu>
Cc: Wolfgang Denk <w...@denx.de>
Cc: Tom Rix <tom....@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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to