src/mediatek/mt8186: Implement sdram_size() to get real dram size

Originally, dram size is hard-coded to 4GB by default. To support
different dram size, calculate it from the mem chip info stored
in CBMEM.

BUG=b:206014043
TEST=Output "dram size: 0x100000000" on Kingler

Signed-off-by: Xi Chen <xixi.chen@mediatek.corp-partner.google.com>
Change-Id: I017e9d1a2d6e26f1fc21b67b5962dfb5c6ade8a5
Reviewed-on: https://review.coreboot.org/c/coreboot/+/62065
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
Xi Chen 2022-02-17 16:48:52 +08:00 committed by Hung-Te Lin
parent 555c2aeb67
commit ad63eabe3a
1 changed files with 20 additions and 1 deletions

View File

@ -5,11 +5,30 @@
* Chapter number: 4.8
*/
#include <assert.h>
#include <cbmem.h>
#include <commonlib/bsd/mem_chip_info.h>
#include <soc/emi.h>
size_t sdram_size(void)
{
return (size_t)4 * GiB;
const struct mem_chip_info *mc;
size_t size = 0;
if (ENV_ROMSTAGE) {
size = mtk_dram_size();
printk(BIOS_INFO, "dram size (romstage): %#lx\n", size);
return size;
}
mc = cbmem_find(CBMEM_ID_MEM_CHIP_INFO);
assert(mc);
for (unsigned int i = 0; i < mc->num_channels; ++i)
size += mc->channel[i].density;
printk(BIOS_INFO, "dram size: %#lx\n", size);
return size;
}
void mt_set_emi(struct dramc_param *dparam)