[U-Boot] [PATCH] 7/12 Multiadapter/multibus I2C, drivers part 4

Wolfgang Denk wd at denx.de
Wed Feb 18 23:48:37 CET 2009


Dear ksi at koi8.net,

In message <Pine.LNX.4.64ksi.0902181400470.5729 at home-gw.koi8.net> you wrote:
>
> How would you know what to initialize and what not to? We were initializing

I don't know. You probably need some way to encode some kind of
routing information that tells you which adapter(s) need to be
initialized to reach some specific device.

> _ALL_ I2C adapters up to today with a single i2c_init() function. It just

Yes, that's the status quo. And it is not good as is, and shall be
changed.

> It is easy to initialize just a selected set of adapters in the new code but
> how do we decide what to initialize and what not to?

Good question. Probably each  I2C  device  will  have  some  list  of
bus/adapter  ID's  that need to be up to access it, and that will get
shut down afterwards.

> Should we add a config option like CONFIG_I2C_INIT_ADAPTERS {1,3,5,9} ? But

No, because we probably do not need to activate all tehse adapters at
the same time.

> Or should we remove i2c_init() from _ALL_ common places and let board
> developers to call i2c_adap[X]->init() as they see fit? But that is a big
> rewrite... And there is another place, cmd_i2c.c that must be taken care
> of...

You will always call i2c_init() for a specific I2C device.

The code should automatically know which adapters need to be  initia-
lized  to  "talk"  to that device. Yes, you must somehow describe the
I2C bus topology, but a single one-way description for the path  from
the specific device to the CPU should be sufficient.

> There is also no way of DE-initilizing those interfaces so that init is like
> a gun trigger -- once it is pulled, there is no way to bring the bullet
> back.

That needs to be changed, too.

> And the final question -- what is wrong with initializing all I2C adapters
> for a handful of boards that have more than one? What is the problem? I can

Initializing things that are not actually  needed  is  bad  for  many
reasons. It takes time, and boot time is critical on many systems. It
increases  the  power  consumption,  and  we have a growing number of
mobile devices where power consumption is critical.  It  carries  big
potential for "unexpected" behaviour (read: nasty failure modes), and
so on.

There are projets around that paid a bite  price  for  not  deinitia-
lizing  devices  after  use.  I2C  may be relatively harmless, but we
thought the same about USB until it bit. And it bit  hard.  That's  a
lesson learned.

> make that init_all function a weak alias so if there's some problem with
> performing total init it can be replaced with board-specific function. But
> frankly I can not see any problems with initializing all 2-3 adapters for
> a few multiadapter boards...

A rule is a rule is a rule.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Nature is very un-American.  Nature never hurries."
- William George Jordan


More information about the U-Boot mailing list