genio: mt8195: atf: patch: add TF-A RAM size autodetection pass to bl33
- With this, bl2 will pass down the DRAM size it gets from libdram down to bl33 (u-boot proper) via a magic location - This is a rework of the implementation for another MTK plat (GRINN)
This commit is contained in:
parent
ca4fe3da9a
commit
5911f02880
@ -0,0 +1,111 @@
|
||||
From 6ea06df6886453c312c0a7094f46372cb9803106 Mon Sep 17 00:00:00 2001
|
||||
From: Ricardo Pardini <ricardo@pardini.net>
|
||||
Date: Sun, 4 Jan 2026 01:56:47 +0100
|
||||
Subject: [PATCH] plat: mediatek: mt8195: 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.
|
||||
All credit to Bartosz Bilas' work for the mt8188.
|
||||
|
||||
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
|
||||
---
|
||||
plat/mediatek/mt8195/bl2_plat_setup.c | 5 +++++
|
||||
plat/mediatek/mt8195/drivers/libdram/libdram.h | 14 ++++++++++++++
|
||||
plat/mediatek/mt8195/drivers/libdram/rules.mk | 12 ++++++++++++
|
||||
plat/mediatek/mt8195/include/platform_def.h | 2 ++
|
||||
plat/mediatek/mt8195/platform.mk | 1 +
|
||||
5 files changed, 34 insertions(+)
|
||||
create mode 100644 plat/mediatek/mt8195/drivers/libdram/libdram.h
|
||||
create mode 100644 plat/mediatek/mt8195/drivers/libdram/rules.mk
|
||||
|
||||
diff --git a/plat/mediatek/mt8195/bl2_plat_setup.c b/plat/mediatek/mt8195/bl2_plat_setup.c
|
||||
index 85e524827..ea157d885 100644
|
||||
--- a/plat/mediatek/mt8195/bl2_plat_setup.c
|
||||
+++ b/plat/mediatek/mt8195/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);
|
||||
@@ -429,6 +430,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 storage read buffer to DRAM */
|
||||
boot_dev_spec->buffer.offset = 0x41000000;
|
||||
boot_dev_spec->buffer.length = 0x1000000;
|
||||
diff --git a/plat/mediatek/mt8195/drivers/libdram/libdram.h b/plat/mediatek/mt8195/drivers/libdram/libdram.h
|
||||
new file mode 100644
|
||||
index 000000000..311d3a25c
|
||||
--- /dev/null
|
||||
+++ b/plat/mediatek/mt8195/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/mt8195/drivers/libdram/rules.mk b/plat/mediatek/mt8195/drivers/libdram/rules.mk
|
||||
new file mode 100644
|
||||
index 000000000..38f23c3dd
|
||||
--- /dev/null
|
||||
+++ b/plat/mediatek/mt8195/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/mt8195/include/platform_def.h b/plat/mediatek/mt8195/include/platform_def.h
|
||||
index 187fd1eac..95e45a4d0 100644
|
||||
--- a/plat/mediatek/mt8195/include/platform_def.h
|
||||
+++ b/plat/mediatek/mt8195/include/platform_def.h
|
||||
@@ -202,6 +202,8 @@
|
||||
#define BL2_BASE (0x201000)
|
||||
#define BL2_LIMIT (0x400000)
|
||||
|
||||
+#define BOOT_ARGUMENT_LOCATION (0x40000100) // Gotta match u-boot's arch/arm/include/asm/arch-mediatek/misc.h
|
||||
+
|
||||
#define MAX_IO_DEVICES U(3)
|
||||
#define MAX_IO_HANDLES U(4)
|
||||
#define MAX_IO_BLOCK_DEVICES 1
|
||||
diff --git a/plat/mediatek/mt8195/platform.mk b/plat/mediatek/mt8195/platform.mk
|
||||
index f62b8551d..f860ffd34 100644
|
||||
--- a/plat/mediatek/mt8195/platform.mk
|
||||
+++ b/plat/mediatek/mt8195/platform.mk
|
||||
@@ -103,6 +103,7 @@ endif
|
||||
endif
|
||||
|
||||
MODULES-BL2-y += ${MTK_PLAT}/common/drivers/blkdev
|
||||
+MODULES-BL2-y += $(MTK_PLAT_SOC)/drivers/libdram
|
||||
|
||||
$(eval $(call add_define,PLAT_PARTITION_BLOCK_SIZE))
|
||||
|
||||
--
|
||||
2.52.0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user