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

Jon Loeliger jdl at freescale.com
Fri May 21 16:49:42 CEST 2004


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








More information about the U-Boot mailing list