[coreboot] v2: Detection of sdram densities.

Mats Erik Andersson mats.andersson at gisladisker.se
Wed Sep 3 19:26:20 CEST 2008

Hello again,

I have been experimenting with an algorithm to detect
and register with the northbridge i440bx the correct
amount of sdram present. A C-coded version is appended
to this message. Feel free to comment on the method.

In the actually working code, I had to split the
algorithm into a lower and an upper part, in order
not to run out of internal registers under romcc,
but the idea remains the same.

Since there are also some later stages where I have
not understood how the previous author hard coded
a single 64MB bank,  I presently achieve a running
system only when I dynamically detect a distribution
identical to what was earlier hard coded.

My detection works with any combination of 0MB and
64MB in two rows for DIMM0 and DIMM1.

Question: In case an sdram device has rows of mixed
sizes, can one depend on the larger density being
in row zero, and the smaller content in row one?

The input value to my function sdram_find_rowsize,
is typically the byte captured using


and similar calls. The output has the largest density
in the least significant byte, and the smaller density
(or a copy for non-mixed devices) in the most significant

Best regards,

Mats E Andersson


static uint16_t sdram_find_rowsize(unsigned char d)
	char mask = 1;

	/* Bail out for empty socket and obviously invalid data. */
	if ( d == 0x00 || d == 0xff )
		return 0;

	while (1)
		if ( d & mask )
			if ( d & ~mask )
				/* Largest chunk in zero'th row, smallest chunk in first row. */
				return ((d & mask) << 8) | (d & ~mask);

			/* Make a duplicate copy in high and low part. */
			return (d << 8) | d;
		mask <<= 1;

More information about the coreboot mailing list