
Hi Wolfgang,
On Wed, 31 Jul 2013 07:18:21 +0200, Wolfgang Denk wd@denx.de wrote:
Dear Albert ARIBAUD,
In message 20130731000921.724f5c71@lilith you wrote:
board_init_f() is supposed to initialize just enough of the system to allow relocation. Is initializing i2c necessary in this context?
On some boards, yes. For example, if they store the environment in an I2C attached EEPROM. Then you need I2C support early, before console, to read for example the baudrate setting.
Thanks, so some I2C reads are needed. Next question: on these boards, do these I2C reads require DT reads? Maybe a few hard-coded low level I2C reads are enough. I guess DT writes are completely unneeded at that point. Also, why exactly do I2C and, as the case may be, DT, need to write to .data?
More generally, while I think the board_init_f() part of U-Boot should be as short and compact as possible, I understand and admit that it might have to read from just about any (local) storage resource, be it environment or DT or any stored information it needs.
On the other hand, it may be hard to immediately know what functions throughout U-boot are safe to call from within board_init_f(); maybe we should start thinking about checking and marking these, the simplest way being to suffix them with "_f" once we have made sure they are safe to call from within board_init_f().
But we should strictly limit the scope of board_init_f() or we'll find the board_init_f()/board_init_r() pair following a patch similar to the SPL/U-Boot pair, where SPL started out as a tiny helper piece of code and ending up a resizeable (and, I dare to say, sizeable as well) kind of U-boot. If we let too many features slip in board_init_f(), it'll blur into a board_init_r() like and before we know it, it'll *require* DDR, and write access to it too...
So, board_init_() should *strictly* be limited to setting up a console (for information purposes) and giving access to DDR while in the same time never writing to it itself. Bonus points if it can limit itself to *enabling* and postpone any *optimizing*(I am thinking of DDR settings here and no, I don't have specific existing cases in mind; just sayin').
In the present instance, I'd rather we either:
- removed dependency on DT etc. by using "hard-coded" low level I2C reads for those boards that need it (I assume that for each of these boards the I2C slave, offset, and length to read are constant) in _f phase, or
- parsed the _f phase looking for offending functions or calls which write to .data or .bss and fix them, suffixing them with _f; in essence, that amounts to starting the implementation of my suggestion above alongside fixing the issue at hand.
The first approach is rather "let's bring the thing back up first", so it does not have my preference, but I would understand the need to quickly fix things.
The second approach seems to be going in the same direction as Heiko's proposal of 07:52 +0200, which I thus second provided it is applicable to all the boards Wolfgang had in mind.
Best regards,
Wolfgang Denk
Amicalement,