summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <[email protected]>2026-03-19 15:00:15 -0500
committerDavid Lechner <[email protected]>2026-04-06 18:39:10 -0500
commitaf4cba9a05aad97f956b21e8e9060e0307bd9afc (patch)
tree89515ac17fdbf9cf0acf2d7784d168a83068e1c3
parente620d592e8079d407ce6f1694a9ddc8586d580cc (diff)
arm: mediatek: mt8195: fix gd->ram_top limit
Fix the implementation of the gd->ram_top limit for mt8195. The intention of the comment about MMC/DMA is correct, but the implementation was wrong. gd->mon_len is set to the code size of U-Boot, so trying to set it to limit gd->ram_top does not make sense. Instead, there is already a get_effective_memsize() weak function that we can override to implement the required limit on the usable memory size. This is used to set gd->ram_top in setup_dest_addr(). The comment about the extra SZ_1M needing to be reserved is not correct as U-Boot already takes care of this (with the actual size of U-Boot) in the various board_f functions, so it is removed. This fixes DMA not working on MMC on mt8195. Reviewed-by: Julien Stephan <[email protected]> Tested-by: Julien Stephan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: David Lechner <[email protected]>
-rw-r--r--arch/arm/mach-mediatek/mt8195/init.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/arch/arm/mach-mediatek/mt8195/init.c b/arch/arm/mach-mediatek/mt8195/init.c
index 6b47ca4b059..e31d4eec0fb 100644
--- a/arch/arm/mach-mediatek/mt8195/init.c
+++ b/arch/arm/mach-mediatek/mt8195/init.c
@@ -9,6 +9,7 @@
#include <asm/armv8/mmu.h>
#include <asm/system.h>
#include <dm/uclass.h>
+#include <linux/kernel.h>
#include <linux/sizes.h>
#include <wdt.h>
@@ -16,23 +17,16 @@ DECLARE_GLOBAL_DATA_PTR;
int dram_init(void)
{
- int ret;
-
- ret = fdtdec_setup_mem_size_base();
- if (ret)
- return ret;
+ return fdtdec_setup_mem_size_base();
+}
+phys_size_t get_effective_memsize(void)
+{
/*
- * Limit gd->ram_top not exceeding SZ_4G. Some periphals like mmc
- * requires DMA buffer allocated below SZ_4G.
- *
- * Note: SZ_1M is for adjusting gd->relocaddr, the reserved memory for
- * u-boot itself.
+ * Limit gd->ram_top not exceeding SZ_4G. Because some peripherals like
+ * MMC requires DMA buffer allocated below SZ_4G.
*/
- if (gd->ram_base + gd->ram_size >= SZ_4G)
- gd->mon_len = (gd->ram_base + gd->ram_size + SZ_1M) - SZ_4G;
-
- return 0;
+ return min(SZ_4G - gd->ram_base, gd->ram_size);
}
int mtk_soc_early_init(void)