]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm: mediatek: mt7988: fix gd->bd->bi_dram[0].size
authorDavid Lechner <dlechner@baylibre.com>
Mon, 15 Jun 2026 19:23:34 +0000 (14:23 -0500)
committerDavid Lechner <dlechner@baylibre.com>
Wed, 24 Jun 2026 15:06:16 +0000 (10:06 -0500)
Use board_get_usable_ram_top() instead of get_effective_memsize() to
set gd->ram_top to something <= 4GiB.

Both board_get_usable_ram_top() and get_effective_memsize() are used to
set gd->ram_top in setup_dest_addr(). However, get_effective_memsize()
also sets gd->bd->bi_dram[0].size in dram_init_banksize(), which is
undesirable.

Prior to commit bddd6bbef3dc ("arm: mediatek: mt7988:
drop dram_init_banksize()"), gd->bd->bi_dram[0].size was overridden in
a board-specific dram_init_banksize() implementation. When that was
removed get_effective_memsize() set gd->bd->bi_dram[0].size to the wrong
value because of CFG_MAX_MEM_MAPPED.

Rather than continue to use an old-style CFG_ option and the potentially
confusing overriding of gd->bd->bi_dram[0].size (it is difficult to see
which order the functions that set it are called), we can just use
board_get_usable_ram_top() to set gd->ram_top to the correct value
instead. This is possible now, thanks to LMB_LIMIT_DMA_BELOW_RAM_TOP
being set by default for 64-bit Mediatek ARM SoCs.

The CFG_MAX_MEM_MAPPED option is removed since it is no longer needed.
The config header and Kconfig option are also removed since that was
the last CFG_ option.

Reported-by: Rudy Andram <rmandrad@gmail.com>
Closes: https://lore.kernel.org/u-boot/20260602162233.2418471-1-rmandrad@gmail.com/
Fixes: bddd6bbef3dc ("arm: mediatek: mt7988: drop dram_init_banksize()")
Link: https://patch.msgid.link/20260615-mtk-fix-ram-size-v2-4-f72cfc52ce58@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
arch/arm/mach-mediatek/Kconfig
arch/arm/mach-mediatek/mt7988/init.c
board/mediatek/mt7988/MAINTAINERS
include/configs/mt7988.h [deleted file]

index 054b1bf92bfafd552ed764f764ff523e913172f8..799c630fed3a05b5cd2a463821b899128827a339 100644 (file)
@@ -199,7 +199,6 @@ config SYS_CONFIG_NAME
        default "mt7629" if TARGET_MT7629
        default "mt7981" if TARGET_MT7981
        default "mt7986" if TARGET_MT7986
-       default "mt7988" if TARGET_MT7988
        default "mt8183" if TARGET_MT8183
        default "mt8512" if TARGET_MT8512
        default "mt8516" if TARGET_MT8516
index 7f4d934bfe97885b1e12a0ba240052901f55aa9b..5b37a91cd72f9c9b08927809f79d92c249421bac 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <fdtdec.h>
 #include <init.h>
+#include <linux/kernel.h>
 #include <linux/sizes.h>
 #include <asm/armv8/mmu.h>
 #include <asm/global_data.h>
@@ -26,6 +27,15 @@ int dram_init(void)
        return 0;
 }
 
+phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
+{
+       /*
+        * Limit gd->ram_top not exceeding SZ_4G. Because some peripherals like
+        * MMC requires DMA buffer allocated below SZ_4G.
+        */
+       return min(gd->ram_top, SZ_4G);
+}
+
 void reset_cpu(ulong addr)
 {
        psci_system_reset();
index a45bfff26cae5cc9962b13debcb21c816d8ea367..c7e30342e5cfcda3cf79442d8b179af20554b3b6 100644 (file)
@@ -2,6 +2,5 @@ MT7988
 M:     Sam Shih <sam.shih@mediatek.com>
 S:     Maintained
 F:     board/mediatek/mt7988
-F:     include/configs/mt7988.h
 F:     configs/mt7988_rfb_defconfig
 F:     configs/mt7988_sd_rfb_defconfig
diff --git a/include/configs/mt7988.h b/include/configs/mt7988.h
deleted file mode 100644 (file)
index e63825a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Configuration for MediaTek MT7988 SoC
- *
- * Copyright (C) 2022 MediaTek Inc.
- * Author: Sam Shih <sam.shih@mediatek.com>
- */
-
-#ifndef __MT7988_H
-#define __MT7988_H
-
-#define CFG_MAX_MEM_MAPPED             0xC0000000
-
-#endif