[U-Boot-Users] Advice on approach for adding a new memory bank initialization

Hey U-Booters,
I have a board that has two completely disjoint banks of RAM, on different buses, that will most likely never be mapped contiguously. I need U-Boot to initialize both banks, make one of them available as the normal system RAM for U-Boot and Linux, and then after initializing the second, leave it for some future Linux device driver to use.
As the code stands now, the initialization sequence is fairly standard:
init_sequence[] references init_func_ram() near the end, init_func_ram() then prints "DRAM:" and calls initdram() initdram() calls spd_sdram() where the actual DRAM initialization happens, returning its size. init_dram() then prints out the spd_dram's returned size.
I want to extend this model to initialize the second bank of memory as well. Clearly, I can do this, but I would like advice on the correct approach and style in which to do so.
Should I:
A) Add a new init_func_ram_other() entry to the init_sequence[] array, clone the init_func_ram() into init_func_ram_other(), and duplicate the whole chain of events down to the init of the other bank of memory. This init_func_ram_other() entry would be #ifdef conditional on my particular boards.
B) Add a second "paragraph" of code to init_func_ram(), one for each type of memory, sort of like this:
static int init_func_ram (void) { puts("DRAM: "); if ((gd->ram_size = initdram(board_type)) > 0) { print_size(gd->ram_size, "\n"); return (0); } puts(failed);
puts("SDRAM: "); if ((sdram_size = initsdram(board_type)) > 0) { print_size(sdram_size, "\n"); return (0); } puts(failed); }
Naturally, we'd have to invert the return handling here to make sure that both paragraphs of code are executed in the "working correctly" case.
C) Re-work the printing of "DRAM" and the size into initdram() so that that function can have two sections to it, one for each bank of memory and still correctly printout two lines like:
DRAM: 512MB SDRAM: 64 MB
This option might entail pushing the establishment of the gd->sdram_size into the initdram() function, which in turn would then return just a boolean to indicate overall success or failure for all of RAM initialization.
So, if I missed a better approach, let me know. I am leaning toward plan B), with A) as followup. C) gives me some headache just due to the implications of fixing up the code on other boards, of course.
Thanks, jdl

In message 1085150982.15257.31.camel@gleep.sps.mot.com you wrote:
I have a board that has two completely disjoint banks of RAM, on different buses, that will most likely never be mapped contiguously. I need U-Boot to initialize both banks, make one of them available as the normal system RAM for U-Boot and Linux, and then after initializing the second, leave it for some future Linux device driver to use.
Normally, it is good policy to have the Linux driver not make any assumptions about what the firmware did or did not, and instead perform all required initialization itself.
I'd recommend to deal with this in the Linux driver, and if you don;t need to use this second bank of memory in U-Boot, then deal with it in the Linux driver only.
As the code stands now, the initialization sequence is fairly standard:
...
I want to extend this model to initialize the second bank
Don't.
Should I:
A) Add a new init_func_ram_other() entry to the init_sequence[]
No. Please don't add very board specific stuff to global files.
B) Add a second "paragraph" of code to init_func_ram(), one for each type of memory, sort of like this:
This sounds better to me than A), but I'll still reject such a patch.
C) Re-work the printing of "DRAM" and the size into initdram()
No.
So, if I missed a better approach, let me know. I am leaning toward plan B), with A) as followup. C) gives me some headache just due to the implications of fixing up the code on other boards, of course.
I think: Leave it to the Linux driver.
Best regards,
Wolfgang Denk
participants (2)
-
Jon Loeliger
-
Wolfgang Denk