
On Wed, 18 Feb 2009, Wolfgang Denk wrote:
Dear ksi@koi8.net,
In message Pine.LNX.4.64ksi.0902181054310.5002@home-gw.koi8.net you wrote:
You are multiplying entities. i2c_init() is invoked as a part of system bootup process in libXXX/board.c anyways. There is no need for any global variables, even non-writable for proposed code to initialize adapters.
Please keep in mind that (even if it should be different at the moment), I2C should only be initialized when needed, i. e. when U-Boot is running any code that needs to access the I2C bus, but not always after each reset on all systems that have I2C enabled.
This is a mandatory requirement for a rewrite.
How would you know what to initialize and what not to? We were initializing _ALL_ I2C adapters up to today with a single i2c_init() function. It just happened that in most cases the total number of adapters was 1 but not always (fsl_i2c.c is a notable example.) There was no mechanism for selective initialization in current U-Boot.
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?
Should we add a config option like CONFIG_I2C_INIT_ADAPTERS {1,3,5,9} ? But that is simply ridiculous and adds _ABSOLUTELY_ unnecessary code.
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...
We can easily add such an initialization to i2c_set_current_bus() (or however it is called) so it will be initializing adapters as bus is changed but that does _NOT_ solve all the problems and requires messing with the entire U-Boot source -- that set_bus call should be added everywhere where I2C is used and it is not a simple grep-and-replace because there is absolutely no reason to add set_bus to each of e.g. 3 i2c_write() calls executed in a row...
Please remember, that even with the new code we don't have to modify anything but config file (trivial one-time changes) for 99% of supported boards that only use one I2C bus -- no set_bus needed at all.
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.
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 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...
--- ****************************************************************** * KSI@home KOI8 Net < > The impossible we do immediately. * * Las Vegas NV, USA < > Miracles require 24-hour notice. * ******************************************************************