[U-Boot] [PATCH v2 01/26] dm: i2c: Provide an offset length parameter where needed
Masahiro Yamada
yamada.m at jp.panasonic.com
Wed Jan 21 11:45:38 CET 2015
Hi Simon,
On Mon, 19 Jan 2015 20:12:30 -0700
Simon Glass <sjg at chromium.org> wrote:
> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
> index 1e500fb..7c3ad00 100644
> --- a/common/cmd_i2c.c
> +++ b/common/cmd_i2c.c
> @@ -168,7 +168,7 @@ static int i2c_get_cur_bus_chip(uint chip_addr, struct udevice **devp)
> if (ret)
> return ret;
>
> - return i2c_get_chip(bus, chip_addr, devp);
> + return i2c_get_chip(bus, chip_addr, 1, devp);
> }
The i2c command calls
[1] i2c_get_cur_bus_chip() = set the offset len to 1
[2] i2c_set_chip_offset_len = change the offset
Now we can do [1] and [2] at the same time, right?
If we set the offset address when we get the device,
we won't need i2c_set_chip_offset_len(), I think.
The offset_len for each device does not change.
Chainging it on the way makes no sense.
> }
>
> -int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp)
> +int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len,
> + struct udevice **devp)
If the device tree for the child device is not found
(i.e. i2c_bind_driver() is called), the new generic chip
will be given with the offset_len.
On the other hand, if the device tree is found,
offset_len is default to 1 because
i2c_chip_ofdata_to_platdata() always set chip->offset_len to 1.
It is a pity.
I wonder if it would not be possible to
get the default offset_len from the device tree node of the child device.
For example, the EEPROM on my board expects chip->offset_len == 2.
It would be nice if we could have the offset property for the EEPROM device node.
I dug into Documentation/devicetree/bindings/, but I could not find the one.
Best Regards
Masahiro Yamada
More information about the U-Boot
mailing list