]> git.ipfire.org Git - thirdparty/u-boot.git/commit
sunxi: dram: detect non-power-of-2 sized DRAM chips
authorAndre Przywara <andre.przywara@arm.com>
Tue, 21 Oct 2025 23:53:34 +0000 (00:53 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Sun, 25 Jan 2026 23:29:32 +0000 (23:29 +0000)
commitc47b636737366d9bc017b915ca6fcbcce8706e6e
tree071c70f6724950401e6173977e3607c2b670eb5c
parentd8ee42f113474c81f2d25a98e6cbcd60cf5bdfd5
sunxi: dram: detect non-power-of-2 sized DRAM chips

Some boards feature an "odd" DRAM size, where the total RAM is 1.5GB or
3GB. Our existing DRAM size detection routines can only detect power-of-2
sized configuration, and on those boards the DRAM size is overestimated,
so this typically breaks the boot quite early.

There doesn't seem to be an easy explicit way to detect those odd-sized
chips, but we can test whether the later part of the memory behaves like
memory, by verifying that a written pattern can be read back.
Experiments show that there is no aliasing effect here, as all locations
in the unimplemented range always return some fixed pattern, and cannot
be changed.

Also so far all those boards use a factor of 3 of some lower power-of-2
number, or 3/4th of some higher number. The size detection routine
discovers the higher number, so we can check for some memory cells beyond
75% of the detected size to be legit.

Add a routine the inverts all bits at a given location in memory, and
reads that back to prove that the new value was stored.
Then test the memory cell at exactly 3/4th of the detected size, and cap
the size of the memory to 75% when this test fails. For good measure
also make sure that memory just below the assumed memory end really
works.

This enables boards which ship with such odd memory sizes.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
arch/arm/include/asm/arch-sunxi/dram.h
arch/arm/mach-sunxi/dram_dw_helpers.c
arch/arm/mach-sunxi/dram_helpers.c