On Sat, Oct 31, 2026 at 08:27:21PM +0800, Hung-Chun Tseng wrote:
> The DDR firmware marks the CS1 address map valid even when it trained
> one chip select, and dram_init() adds up every valid map. A 4 GiB
> Milk-V Jupiter (cs_num 1 in its EEPROM) is reported as 8 GiB, so
> U-Boot reserves memory past the end of DRAM and passes 8 GiB to Linux.
> 
> Clear the CS1 map valid bit after DDR init when the EEPROM says there
> is one chip select, which matches what the vendor U-Boot does by only
> counting CS1 when ddr_cs_num > 1.
> 
> Fixes: 3691fbccfc89 ("riscv: spacemit: k1: probe dram size during boot 
> phase.")
> Signed-off-by: Hung-Chun Tseng <[email protected]>
> ---
> This depends on "spacemit: k1: initialise the EEPROM index in
> read_ddr_info()" [1]; without it the EEPROM read can fail, cs_num stays
> at the default of 2 and this change does nothing.
> 
> Tested on a 4 GiB Milk-V Jupiter booting from SD: the SPL reads
> cs_num=1, U-Boot reports "DRAM: 4 GiB" and the second bank is
> 0x100000000 + 2 GiB (it was 6 GiB).
> 
> [1] 
> https://lore.kernel.org/u-boot/[email protected]/
> 
>  board/spacemit/k1/spl.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Leo Yu-Chi Liang <[email protected]>

Reply via email to