[U-Boot] Reading multiple bytes using I2C in U-Boot

Nildo Junior njunior at taranawireless.com
Sat Jul 26 03:17:04 CEST 2014


I am having a problem with the I2C driver for a Freescale p1022tw board.
There is the command on U-Boot's console to read from an I2C device:

    i2c md chip address[.0, .1, .2] [# of objects]

When I read 4 bytes from a device with id 0x60, at address 0x0, I get:

    tw=>i2c md 60 0 4
    0000: 45 45 45 45    EEEE

These values that it returned are wrong. I can get the right values if I
read one byte at the time:

    tw=>i2c md 60 0 1
    0000: 45    E
    tw=>i2c md 60 1 1
    0001: 45    E
    tw=>i2c md 60 2 1
    0002: 46    F
    tw=>i2c md 60 3 1
    0003: 00    .

I should have gotten `45 45 46 00` or `EEF0` in the first command. In
multiple readings for this device, it is returning always just the first
byte value. If I try to get 6 bytes starting at address 0x2, this is the
output:

    tw=>i2c md 60 2 6
    0002: 46 46 46 46 46 46    FFFFFF

This problem does not happen on other devices on the bus. For instance, in
the device with id 0x4F, the right values are printed:

    tw=>i2c md 4F 0.2 6
    0000: 18 00 f6 48 00 00    ...H..

The address in the previous command has a ".2" because the chip uses 2
bytes for addresses. The first device only uses 1, so there's no need to
put a ".1" (I already tested that).

I went through the implementation of the Freescale driver for the I2C
communication, but I didn't change anything on it and it works for other
devices. My coworker also says that the very same code works on his board.
Have anybody had a similar issue or has any theory about why this is
happening?

Thanks in advance.


More information about the U-Boot mailing list