- From https://gitlab.collabora.com/mediatek/aiot/boot/-/tree/main/patches/trusted-firmware-a at bc779c20dd5ea72a9f3edd248eb08460e3c837b6
106 lines
3.6 KiB
Diff
106 lines
3.6 KiB
Diff
From fc8cefeadefca5e4568f4266a619961537c107a5 Mon Sep 17 00:00:00 2001
|
|
From: Bartosz Bilas <b.bilas@grinn-global.com>
|
|
Date: Thu, 2 Oct 2025 13:08:24 +0200
|
|
Subject: [PATCH] plat: mediatek: use libdram to pass actual memory size to
|
|
U-Boot
|
|
|
|
Since libdram can obtain the actual memory size at runtime, make it possible
|
|
to pass this value to U-Boot. This allows the bootloader to adapt to boards
|
|
with different DRAM sizes without requiring manual configuration.
|
|
---
|
|
plat/mediatek/mt8188/bl2_plat_setup.c | 5 +++++
|
|
plat/mediatek/mt8188/drivers/libdram/libdram.h | 14 ++++++++++++++
|
|
plat/mediatek/mt8188/drivers/libdram/rules.mk | 12 ++++++++++++
|
|
plat/mediatek/mt8188/include/platform_def.h | 2 ++
|
|
plat/mediatek/mt8188/platform_bl2.mk | 1 +
|
|
5 files changed, 34 insertions(+)
|
|
create mode 100644 plat/mediatek/mt8188/drivers/libdram/libdram.h
|
|
create mode 100644 plat/mediatek/mt8188/drivers/libdram/rules.mk
|
|
|
|
diff --git a/plat/mediatek/mt8188/bl2_plat_setup.c b/plat/mediatek/mt8188/bl2_plat_setup.c
|
|
index 70a0564ff..8e6e33e4d 100644
|
|
--- a/plat/mediatek/mt8188/bl2_plat_setup.c
|
|
+++ b/plat/mediatek/mt8188/bl2_plat_setup.c
|
|
@@ -33,6 +33,7 @@
|
|
#if defined(PLAT_AB_BOOT_ENABLE)
|
|
#include <mtk_ab.h>
|
|
#endif
|
|
+#include "libdram.h"
|
|
|
|
void pwrap_init(void);
|
|
void mt_mem_init(void);
|
|
@@ -396,6 +397,10 @@ void bl2_platform_setup(void)
|
|
load_partition_table(GPT_IMAGE_ID);
|
|
blkdev_set_dramk_data_offset(get_part_addr("dramk"));
|
|
mt_mem_init();
|
|
+
|
|
+ BOOT_ARGUMENT->magic_number = BOOT_ARGUMENT_MAGIC;
|
|
+ BOOT_ARGUMENT->dram_size = platform_memory_size();
|
|
+
|
|
/* change emmc read buffer to DRAM */
|
|
boot_dev_spec->buffer.offset = 0x41000000;
|
|
boot_dev_spec->buffer.length = 0x1000000;
|
|
diff --git a/plat/mediatek/mt8188/drivers/libdram/libdram.h b/plat/mediatek/mt8188/drivers/libdram/libdram.h
|
|
new file mode 100644
|
|
index 000000000..311d3a25c
|
|
--- /dev/null
|
|
+++ b/plat/mediatek/mt8188/drivers/libdram/libdram.h
|
|
@@ -0,0 +1,14 @@
|
|
+/*
|
|
+ * Copyright (c) 2025 Grinn sp. z o.o
|
|
+ *
|
|
+ * SPDX-License-Identifier: BSD-3-Clause
|
|
+ */
|
|
+
|
|
+#ifndef LIBDRAM_H
|
|
+#define LIBDRAM_H
|
|
+
|
|
+#include <stdint.h>
|
|
+
|
|
+unsigned long long platform_memory_size(void);
|
|
+
|
|
+#endif /* LIBDRAM_H */
|
|
diff --git a/plat/mediatek/mt8188/drivers/libdram/rules.mk b/plat/mediatek/mt8188/drivers/libdram/rules.mk
|
|
new file mode 100644
|
|
index 000000000..38f23c3dd
|
|
--- /dev/null
|
|
+++ b/plat/mediatek/mt8188/drivers/libdram/rules.mk
|
|
@@ -0,0 +1,12 @@
|
|
+#
|
|
+# Copyright (c) 2025, Grinn sp. z o.o. All rights reserved.
|
|
+#
|
|
+# SPDX-License-Identifier: BSD-3-Clause
|
|
+#
|
|
+
|
|
+LOCAL_DIR := $(call GET_LOCAL_DIR)
|
|
+
|
|
+MODULE := libdram
|
|
+
|
|
+PLAT_INCLUDES += -I${LOCAL_DIR}/
|
|
+$(eval $(call MAKE_MODULE,$(MODULE),$(LOCAL_SRCS-y),$(MTK_BL)))
|
|
diff --git a/plat/mediatek/mt8188/include/platform_def.h b/plat/mediatek/mt8188/include/platform_def.h
|
|
index 23bc1ad7c..cfa0d3728 100644
|
|
--- a/plat/mediatek/mt8188/include/platform_def.h
|
|
+++ b/plat/mediatek/mt8188/include/platform_def.h
|
|
@@ -303,6 +303,8 @@
|
|
#define BL2_BASE (0x201000)
|
|
#define BL2_LIMIT (0x400000)
|
|
|
|
+#define BOOT_ARGUMENT_LOCATION (0x40000100)
|
|
+
|
|
#define MAX_IO_DEVICES U(3)
|
|
#define MAX_IO_HANDLES U(4)
|
|
#define MAX_IO_BLOCK_DEVICES 1
|
|
diff --git a/plat/mediatek/mt8188/platform_bl2.mk b/plat/mediatek/mt8188/platform_bl2.mk
|
|
index a851dc98b..421f2c824 100644
|
|
--- a/plat/mediatek/mt8188/platform_bl2.mk
|
|
+++ b/plat/mediatek/mt8188/platform_bl2.mk
|
|
@@ -25,6 +25,7 @@ BL2_SOURCES += lib/cpus/aarch64/cortex_a55.S \
|
|
${MTK_PLAT}/common/mtk_rgu.c
|
|
|
|
MODULES-BL2-y += $(MTK_PLAT)/drivers/uart
|
|
+MODULES-BL2-y += $(MTK_PLAT_SOC)/drivers/libdram
|
|
MODULES-BL2-y += ${MTK_PLAT}/drivers/wdt
|
|
MODULES-BL2-y += ${MTK_PLAT_SOC}/drivers/pll
|
|
MODULES-BL2-y += $(MTK_PLAT_SOC)/drivers/pmic_bl2
|