From b1c3b9963b5627bab9b05ce0eabc1369afad591d Mon Sep 17 00:00:00 2001 From: Rex-BC Chen Date: Mon, 15 Aug 2022 10:17:48 +0800 Subject: soc/mediatek: Move emi.c to common folder The emi.c is the same for MT8186 and MT8188, so we could move it to the common folder and reuse it. TEST=build pass BUG=b:236331724 Signed-off-by: Bo-Chen Chen Change-Id: I225f1d07c973129172f01bf7f4d7f5d5abe7c02b Reviewed-on: https://review.coreboot.org/c/coreboot/+/66328 Reviewed-by: Yidi Lin Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/soc/mediatek/common/emi.c | 32 +++++++++++++++++++++++++++++++ src/soc/mediatek/mt8186/Makefile.inc | 4 ++-- src/soc/mediatek/mt8186/emi.c | 37 ------------------------------------ 3 files changed, 34 insertions(+), 39 deletions(-) create mode 100644 src/soc/mediatek/common/emi.c delete mode 100644 src/soc/mediatek/mt8186/emi.c (limited to 'src/soc/mediatek') diff --git a/src/soc/mediatek/common/emi.c b/src/soc/mediatek/common/emi.c new file mode 100644 index 0000000000..d5470d2fd3 --- /dev/null +++ b/src/soc/mediatek/common/emi.c @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +size_t sdram_size(void) +{ + const struct mem_chip_info *mc; + size_t size = 0; + + if (ENV_RAMINIT) { + 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) +{ + /* Do nothing */ +} diff --git a/src/soc/mediatek/mt8186/Makefile.inc b/src/soc/mediatek/mt8186/Makefile.inc index f214bbdaef..5f070a0b06 100644 --- a/src/soc/mediatek/mt8186/Makefile.inc +++ b/src/soc/mediatek/mt8186/Makefile.inc @@ -19,7 +19,7 @@ bootblock-y += ../common/wdt.c ../common/wdt_req.c wdt.c romstage-y += ../common/cbmem.c romstage-y += ../common/dram_init.c romstage-y += ../common/dramc_param.c -romstage-y += emi.c +romstage-y += ../common/emi.c romstage-y += ../common/memory.c romstage-y += ../common/memory_test.c romstage-y += ../common/mmu_operations.c ../common/mmu_cmops.c @@ -31,7 +31,7 @@ ramstage-y += ../common/ddp.c ddp.c ramstage-y += devapc.c ramstage-y += ../common/dfd.c ramstage-y += ../common/dsi.c ../common/mtk_mipi_dphy.c -ramstage-y += emi.c +ramstage-y += ../common/emi.c ramstage-y += ../common/mcu.c ramstage-y += ../common/mmu_operations.c ../common/mmu_cmops.c ramstage-$(CONFIG_COMMONLIB_STORAGE_MMC) += ../common/msdc.c msdc.c diff --git a/src/soc/mediatek/mt8186/emi.c b/src/soc/mediatek/mt8186/emi.c deleted file mode 100644 index 4f300da793..0000000000 --- a/src/soc/mediatek/mt8186/emi.c +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -/* - * This file is created based on MT8186 Functional Specification - * Chapter number: 4.8 - */ - -#include -#include -#include -#include - -size_t sdram_size(void) -{ - const struct mem_chip_info *mc; - size_t size = 0; - - if (ENV_RAMINIT) { - 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) -{ - /* Do nothing */ -} -- cgit v1.2.3