[U-Boot] [PATCH v3 01/10] dm: i2c: Add a uclass for I2C

Simon Glass sjg at chromium.org
Thu Dec 4 03:36:15 CET 2014


Hi Masahiro,

On 3 December 2014 at 19:01, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> Hi Simon,
>
>
> More comments again.
>
>
> On Mon, 24 Nov 2014 11:57:15 -0700
>> +
>> +static int i2c_probe_chip(struct udevice *bus, uint chip_addr)
>> +{
>> +     struct dm_i2c_ops *ops = i2c_get_ops(bus);
>> +     struct i2c_msg msg[1];
>> +     uint8_t ch = 0;
>> +
>> +     if (!ops->xfer)
>> +             return -ENOSYS;
>> +
>> +     msg->addr = chip_addr;
>> +     msg->flags = 0;
>> +     msg->len = 1;
>> +     msg->buf = &ch;
>> +
>> +     return ops->xfer(bus, msg, 1);
>> +}
>
> i2c_probe_chip() issues a write transaction with one length,
> but a read transaction should be used.
>
> For most of chips, the first write data is the first byte of
> the offset address, so no real data will be written into the chip.
>
> But it is possible to have offset_address_length == 0.
>
> The read transaction is always safer than the write transaction.
>

I originally had a probe method to allow the driver to decide what to
do. Many drivers can in fact just write the address and don't need a
data / offset byte. But not all. With a read byte the tegra driver
takes ages to respond and the probe takes a lot longer than it should.

Yes I agree that read is safer, but even safer is nothing. Perhaps I
should go back to having a probe_chip() method? Or at least it could
be optional.

Regards,
Simon


More information about the U-Boot mailing list