[U-Boot] [PATCH v3] i2c: merge all i2c_reg_read() and i2c_reg_write() into inline functions

ksi at koi8.net ksi at koi8.net
Tue Dec 16 01:24:26 CET 2008


On Mon, 15 Dec 2008, Timur Tabi wrote:

> ksi at koi8.net wrote:
>> On Mon, 15 Dec 2008, Wolfgang Denk wrote:
>>
>> Are you going to implement support for multiple I2C busses on some
> boards?
>> I'm working on something like this now so it would be nice to
> coordinate our
>> efforts somehow...
>
> Yes, my goal is to add low-level i2c functions that take an i2c bus as a
> parameter.  So instead of
>
> 	i2c_set_bus_num(1);
> 	i2c_read(...);
>
> you can do
>
> 	i2c_read(1, ...)
>
> or something like that.  My goal is to eliminate i2c_set_bus_num() and
> everything related to it.
>
> It sounds like we're working on something very similar.  This is very
> low-priority for me, though.

That looks similar. But why do you want to remove i2c_set_bus_num()? I think
it would be less work to keep it. This way you can leave 90% or so of
existing I2C code unchanged by setting bus number to 0 at init. In your case
you will have to find each and every call to i2c_read... and change it to
the new format that includes bus number in parameters list.

My idea is to have global bus number variable in a single place and a single
i2c_set_bus_num() that can be excluded for most boards with a single bus
with #ifdef...

Then, we could use some kind of array of I2C structures each containing
pointers to appropriate i2c-{read,write,probe,init}() functions with generic
i2c functions just calling those pointers using bus number as index into
that array.

That would allow for unlimited number of different adapters for any board.
Initial code for initializing such an array would have to go into each and
every $(BOARD).c board specific file.

We could even make some default #ifdef'd structure that would've included
automagically if something like CONFIG_I2C_MULTIBUS was not defined thus
making most of the boards (actually almost all of them) work without
modifications.

Please let me know what you think...

---
******************************************************************
*  KSI at home    KOI8 Net  < >  The impossible we do immediately.  *
*  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
******************************************************************


More information about the U-Boot mailing list