aboutsummaryrefslogtreecommitdiff
path: root/src/soc/mediatek/common/dpm.c
diff options
context:
space:
mode:
authorXi Chen <xixi.chen@mediatek.com>2021-03-03 17:58:07 +0800
committerHung-Te Lin <hungte@chromium.org>2021-03-08 01:50:11 +0000
commite8c681cc6249cc7717885a12373e4fcf34034b1c (patch)
treea9daf5f6700869b9e6dc3b5faaf8fe1ab8b53d7f /src/soc/mediatek/common/dpm.c
parent022b1b992f24890a04851dccc2829284a0431d6a (diff)
soc/mediatek/common: Move DRAM implementation from mt8192 to common
To reduce duplicated dram sources on seperate SOCs, add dpm, dram_init, dramc_params, memory(fast-k or full-k) implementations, also add dramc log level macro header files. Signed-off-by: Xi Chen <xixi.chen@mediatek.com> Change-Id: I557c96b3d09828472b8b6f932b0192a90894043e Reviewed-on: https://review.coreboot.org/c/coreboot/+/51203 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Diffstat (limited to 'src/soc/mediatek/common/dpm.c')
-rw-r--r--src/soc/mediatek/common/dpm.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/soc/mediatek/common/dpm.c b/src/soc/mediatek/common/dpm.c
new file mode 100644
index 0000000000..991441e74c
--- /dev/null
+++ b/src/soc/mediatek/common/dpm.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <device/mmio.h>
+#include <soc/dpm.h>
+#include <soc/mcu_common.h>
+#include <soc/symbols.h>
+
+static void reset_dpm(struct mtk_mcu *mcu)
+{
+ /* write bootargs */
+ write32(&mtk_dpm->twam_window_len, 0x0);
+ write32(&mtk_dpm->twam_mon_type, 0x0);
+
+ /* free RST */
+ setbits32(&mtk_dpm->sw_rstn, DPM_SW_RSTN_RESET);
+}
+
+static struct mtk_mcu dpm_mcu[] = {
+ {
+ .firmware_name = CONFIG_DPM_DM_FIRMWARE,
+ .run_address = (void *)DPM_DM_SRAM_BASE,
+ },
+ {
+ .firmware_name = CONFIG_DPM_PM_FIRMWARE,
+ .run_address = (void *)DPM_PM_SRAM_BASE,
+ .reset = reset_dpm,
+ },
+};
+
+int dpm_init(void)
+{
+ int i;
+ struct mtk_mcu *dpm;
+
+ /* config DPM SRAM layout */
+ clrsetbits32(&mtk_dpm->sw_rstn, DPM_MEM_RATIO_MASK, DPM_MEM_RATIO_CFG1);
+
+ for (i = 0; i < ARRAY_SIZE(dpm_mcu); i++) {
+ dpm = &dpm_mcu[i];
+ dpm->load_buffer = _dram_dma;
+ dpm->buffer_size = REGION_SIZE(dram_dma);
+ if (mtk_init_mcu(dpm))
+ return -1;
+ }
+
+ return 0;
+}